Skip to content

Architecture Overview ​

The server (server/) is the business hub of the whole system: both the admin console and the mini program access it through REST endpoints under the /api/v1 prefix.

Tech Stack ​

ComponentChoiceVersion
Language / runtimeJava21
Application frameworkSpring Boot4.1.x
Data accessSpring Data JPA (Hibernate)bundled with Boot
DatabaseMySQL8.0
CacheCaffeine (local cache)3.3.x
AuthenticationSpring Security + JWT (jjwt)0.13.x
API docsKnife4j (OpenAPI 3, Chinese UI)4.5.0
BuildMaven Wrapper-

Layered Structure ​

Source Layers ​

For the responsibility-oriented source layer map, module/state inventory, call surface, and split rationale, see Source layer analysis. Its term definitions are collected in the Glossary.

LayerImplementationConfiguration schemaDedicated protocol fileCopy location
Request orchestrationserver/src/main/java/com/sinomed/config/SecurityConfig.javaserver/src/main/resources/application.ymlNo; OpenAPI is generatedNot applicable
Resource controllersserver/src/main/java/com/sinomed/controller/PrescriptionController.javaSpringdoc scans com.sinomed.controllerNoAdmin locale/page code
Application servicesserver/src/main/java/com/sinomed/service/impl/SettlementServiceImpl.javaJPA/annotations and selected service @Value keysNoAdmin locale/page code
Persistenceserver/src/main/java/com/sinomed/config/PersistenceConfig.javaserver/src/main/resources/application.ymlserver/init/init.sql is bootstrap, not runtime schemaNot applicable
Clinical referenceserver/src/main/java/com/sinomed/service/FormulaService.javaJPA entity schemaNoAdmin locale/page code
Clinical operationsserver/src/main/java/com/sinomed/service/AppointmentService.javaJPA entity schemaNoAdmin locale/page code
Financial settlementserver/src/main/java/com/sinomed/service/CardService.javaJPA entity schemaNoAdmin locale/page code
Channel integrationserver/src/main/java/com/sinomed/service/WxMpServiceProvider.javaserver/src/main/resources/application.ymlCallback XML behavior is code-ownedChannel-facing strings in services
Content and peripheralsdesktop/src-tauri/src/main.rsdesktop/src-tauri/src/config.rsdesktop/src-tauri/templates/*.htmldesktop/ui/index.html
Interaction runtimesweb/src/app.tsx, app/src/app.ts, kiosk/src/App.tsx, tablet/src/App.tsxweb/config/config.ts, app/config/index.ts, Vite configsREST client modulesLocale/page/token CSS files
Platform lifecycleserver/src/main/java/com/sinomed/seed/DemoSeedRunner.javacompose.yml, CI workflows, demo.seedNoNot applicable

The code under the com.sinomed package follows a classic layered organization:

PackageResponsibility
controllerREST endpoint layer: parameter reception, validation, and the permission entry point; no business rules
service / service.implBusiness layer: business rules, data assembly, cache annotations
repositoryData access layer: Spring Data JPA interfaces
entityData model: one-to-one with database tables (ddl-auto creates tables automatically)
voOutput view objects (View)
paramsInput parameter objects
configConfiguration classes: security, cache, JPA, API docs, encryption
securityJWT filter, issuance / verification, role and permission definitions
exceptionMapping of global exceptions to HTTP status codes
utilUtilities: date ranges, attendance calculation, phone number validation

Modules and Business Chains ​

The source-layer vocabulary used below is defined in the Glossary; the detailed responsibility map is in Source layer analysis.

Judging from the endpoints and pages, the system's current main chains are:

text
顾客建档 → 创建诊疗单(四诊/脉象/取穴/诊断与调理方案) → 复诊调阅历史
卡项维护 → 订单(自助机下单 / 前台建单 → 待接待 → 接单 / 完成 / 取消)
每日报表 ← 每日总结 / 员工复盘 / 顾客回访(到期提醒)
收费结算 ← 订单收款(储值 / 微信 / 支付宝 / 现金 / 次卡抵扣) → 小票套打 / 月度收费报表
员工签到 → 打卡记录 → 今日/按月考勤统计(运营辅助)
ModuleControllerStatus
Patient (create a patient record / query / update / delete / medical history)CustomerControllerAvailable
Treatment record (TCM four examinations record)TreatControllerAvailable
Acupoint dictionary (point selection by name/pinyin search)AcupointControllerAvailable
Appointments (booking / scheduling grid / check-in)AppointmentControllerAvailable
Feedback (daily summary / staff retrospective / patient follow-up)ReviewControllerAvailable
Service cardItemControllerAvailable
User authentication (login / register / current user)UserControllerAvailable
Staff and attendance (clinic operations)StaffController, StaffLeaveControllerAvailable (leave implemented)
Staff recurring shift table (staff × weekday shift reference)StaffShiftControllerAvailable
Orders (Kiosk ordering / front-desk creation / status flow)OrderControllerAvailable
Chinese medicine prescriptions (writing / decoction service and paste flows / real-time pricing / compatibility and allergy review)PrescriptionControllerAvailable
Syndrome prescription templatesPrescriptionTemplateControllerAvailable
External therapy prescription templates (common combinations for ear points/application/moxibustion/cupping)TherapyTemplateControllerAvailable
Formula library (bring in the whole formula by name/pinyin search)FormulaControllerAvailable
Herb dictionary (pricing data for prescription writing)HerbControllerAvailable
Processed herb stock-in/stock-out (ledger registration / balance and expiry warnings)HerbStockControllerAvailable
Charging/settlement and stored value (payment / top-up ledger)SettlementController, RechargeControllerAvailable
Payment QR code images (WeChat/Alipay merchant code images)PayQrCodeControllerAvailable (reads data/payqrcodes/ to serve images, no payment gateway)
Visit cards (issue a card / deactivate / write-off ledger)CardControllerAvailable
Settlement receipt overprint (80mm HTML, overridable templates)ReceiptPrintController, PrintTemplateControllerAvailable
Kiosk (unauthenticated ordering / self-service scheduling)KioskControllerAvailable
Advertising screen and queue callingAdsController, CallControllerAvailable
WeChat official account (callback routing, auto-reply rules, custom menus + push, material ledger local/remote, fan binding and web auth, account configuration)WxOfficialAccountController, WxMpServiceProvider (WxJava SDK thin wrapper)Available (real outbound gated by official-account credentials; design doc design/wechat-official-account.md)
Frontend error reportingTraceControllerSimple log recording

Note when reading the API documentation

Staff leave is implemented (/api/v1/staff/leave/; recording convention: it does not change login status and there is no approval flow). Stock-in/stock-out inventory and online payment are planned features. Treat the "Status" column on this page as authoritative and avoid inferring available features from endpoint names.

Authentication and Permissions ​

  • Login goes through POST /api/v1/user/login; on success both the response body and headers return the access token (1 day) and refresh token (7 days), all Bearer JWTs.
  • Except for login and API documentation paths, all endpoints require Authorization: Bearer <token>.
  • Roles are divided by the staff table's role field: role == 0 yields the admin permission set, 1-9 is management (the MANAGER permission set), ≥10 is ordinary staff (USER); staff with status <= 0 (departed) cannot log in.
  • Permission strings (admin:* / management:*) are defined in code; method-level authorization is partially enabled — the staff management write endpoints (POST/PUT/DELETE /api/v1/staff) carry @PreAuthorize("hasRole('ADMIN')") and unauthorized attempts return 403; the other endpoints work with just a login.
  • The admin / 123 administrator account is created automatically the first time someone logs in as admin (built-in bcrypt password); the demo seed creates only the three staff accounts gu/shen/su.

Cross-Cutting Mechanisms ​

  • Audit fields: all entities carry create_time / update_time (card_adjusts only create_time), maintained automatically by JPA Auditing.
  • Cache: by-id queries go through the Caffeine cache (about 50 minutes expiry by default); updates/deletes of service cards and treatment records already carry @CacheEvict for active invalidation; invalidation is still single-key granular, leaving a short window of stale reads — a known item pending optimization.
  • Pagination: current starts at 1; the uniform response structure is { data, total, pages, success }.
  • Exceptions: a global advice maps parameter errors to 400, authentication failures to 401, account lockout to 403, and everything else to 500.
  • API docs: the Knife4j Chinese UI, scanning com.sinomed.controller, entry point /doc.html.

Last updated: