# charliexbr/cremed architecture

> Architecture diagram of the GitHub repository charliexbr/cremed, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/charliexbr/cremed
- Repository: https://github.com/charliexbr/cremed

## Overview

1. A Java-based backend – found under the “CareMed” folder – that is built using a framework like Spring Boot. This module follows a clear MVC pattern with controllers (e.g., HospitalsController, OrderController, etc.), services, DAO/mappers, entities, and DTOs. It is responsible for handling order management, hospital information, payment interfacing, SMS functionality, and even AI consultation services by interfacing with an AI module.

2. A WeChat mini program frontend – under “peizhengproject-main” – which uses Vue/uni-app conventions (with .vue files, pages, and uni_modules). This side handles user interfaces such as the homepage, order filling, payment, chat, and user profiles. The frontend code also includes various components for navigation, interactive selectors, drag-drop features, and resembles a typical mini program structure.

##### Main components
- Backend Service: Represent the “CareMed” Java backend as a separate service or group. Inside this, include sub-components such as:
– Controllers (e.g., HospitalsController, OrderController, IndexController, etc.)
– Services (the business logic for order management, user info, hospitals)
– DAOs/Mappers (responsible for database operations)
– Entities & DTOs (data structures for orders, users, hospitals, etc.)
– Utility classes (e.g., JwtUtil for authentication/authorization)
- Database: Use the accompanycaredb.sql as an indicator of the relational database structure that holds user data, order records, hospital listings, etc.
- External Services/Integrations: Include payment gateways (likely integrated through WeChat Pay), SMS service, and any AI consultation module (as per the README’s “AI咨询助手” mention).

##### Relationships and interactions
– Order placement (代跑取药, 上门助浴, etc.)
– Payment processes
– AI consultation interactions
– User login (via SMS verification) and profile management.
- Backend interacting with the database (CRUD operations for orders, users, hospitals).
- SMS and payment integrations as external systems interacting with the backend.

##### Architectural patterns
- MVC design on the backend. Optionally, group components into a “Controller Layer”, “Service Layer”, and “Data Access Layer.”
- For the frontend, indicate that it is a uni-app or Vue-based mini program with clearly separated pages and reusable components (such as NavBar, dtPicker, share, etc.)

##### Technology and framework labels
- For the backend, mark “Java”, “Spring Boot,” “Maven” (pom.xml) and list MyBatis (if that is used in DAO implementations).
- For the frontend, add “uni-app”, “Vue”, and note that it integrates with WeChat’s mini program ecosystem.
- Payment service integration and AI services, as described in the README.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "WeChat Mini Program Frontend" 
        FE1["App.vue"]:::frontend
        FE2["main.js"]:::frontend
        FE3["manifest.json"]:::frontend
        FE4["Pages"]:::frontend
        FE5["Reusable Components"]:::frontend
        FE["Uni-app Frontend"]:::frontend
        FE1 --> FE
        FE2 --> FE
        FE3 --> FE
        FE4 --> FE
        FE5 --> FE
    end

    %% Backend Layer
    subgraph "Java Backend (CareMed)" 
        %% Controller Layer
        subgraph "Controller Layer"
            C1["HospitalsController"]:::backend
            C2["OrderController"]:::backend
            C3["IndexController"]:::backend
            C4["SmsController"]:::backend
            C5["UserInfoController"]:::backend
        end
        %% Service Layer
        subgraph "Service Layer"
            S1["HospitalsService"]:::backend
            S2["OrderService"]:::backend
            S3["IndexService"]:::backend
            S4["UserInfoService"]:::backend
        end
        %% Data Access Layer
        subgraph "Data Access Layer"
            D1["HospitalsMapper"]:::backend
            D2["OrderMapper"]:::backend
            D3["IndexMapper"]:::backend
            D4["UserInfoMapper"]:::backend
        end
        %% Data Models
        subgraph "Data Models"
            M1["Entities"]:::backend
            M2["DTOs"]:::backend
        end
        U1["JwtUtil"]:::backend
    end

    %% External Integrations and Database
    ext1["Payment Gateway"]:::external
    ext2["SMS Service"]:::external
    ext3["AI Consultation"]:::external
    DB["Database (accompanycaredb.sql)"]:::database

    %% Connections from Frontend to Backend Controllers
    FE -->|"API Request"| C1
    FE -->|"API Request"| C2
    FE -->|"API Request"| C3
    FE -->|"API Request"| C4
    FE -->|"API Request"| C5

    %% Backend Internal Flow
    C1 -->|"calls"| S1
    C2 -->|"calls"| S2
    C3 -->|"calls"| S3
    C4 -->|"calls"| S4
    C5 -->|"calls"| S4

    S1 -->|"invokes"| D1
    S2 -->|"invokes"| D2
    S3 -->|"invokes"| D3
    S4 -->|"invokes"| D4

    D1 -->|"CRUD"| DB
    D2 -->|"CRUD"| DB
    D3 -->|"CRUD"| DB
    D4 -->|"CRUD"| DB

    %% External Service Integrations from Controllers
    C2 ---|"Payment"| ext1
    C4 ---|"SMS"| ext2
    C3 ---|"AI_query"| ext3

    %% Click Events for Frontend
    click FE1 "https://github.com/charliexbr/cremed/blob/master/peizhengproject-main/App.vue"
    click FE2 "https://github.com/charliexbr/cremed/blob/master/peizhengproject-main/main.js"
    click FE3 "https://github.com/charliexbr/cremed/blob/master/peizhengproject-main/manifest.json"
    click FE4 "https://github.com/charliexbr/cremed/tree/master/peizhengproject-main/pages"
    click FE5 "https://github.com/charliexbr/cremed/tree/master/peizhengproject-main/components"

    %% Click Events for Backend - Controllers
    click C1 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/controller/HospitalsController.java"
    click C2 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/controller/OrderController.java"
    click C3 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/controller/IndexController.java"
    click C4 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/controller/SmsController.java"
    click C5 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/controller/UserInfoController.java"

    %% Click Events for Backend - Services
    click S1 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/service/HospitalsService.java"
    click S2 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/service/OrderService.java"
    click S3 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/service/IndexService.java"
    click S4 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/service/UserInfoService.java"

    %% Click Events for Backend - DAOs/Mappers
    click D1 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/dao/HospitalsMapper.java"
    click D2 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/dao/OrderMapper.java"
    click D3 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/dao/IndexMapper.java"
    click D4 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/dao/UserInfoMapper.java"

    %% Click Events for Data Models
    click M1 "https://github.com/charliexbr/cremed/tree/master/CareMed/src/main/java/com/peiz/caremed/entity"
    click M2 "https://github.com/charliexbr/cremed/tree/master/CareMed/src/main/java/com/peiz/caremed/dto"

    %% Click Event for Utility
    click U1 "https://github.com/charliexbr/cremed/blob/master/CareMed/src/main/java/com/peiz/caremed/utils/JwtUtil.java"

    %% Click Event for Database
    click DB "https://github.com/charliexbr/cremed/blob/master/accompanycaredb.sql"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef backend fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px;
    classDef external fill:#fff3e0,stroke:#e65100,stroke-width:2px;
    classDef database fill:#fce4ec,stroke:#880e4f,stroke-width:2px;
```
