# nguyendaithanh2805/hethonghotrovaquanlyphongkham architecture

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

- Interactive diagram: https://gitdiagram.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham
- Repository: https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham

## Overview

##### Project Context and Main Components
- This is a clinic management and support system, with a full-stack architecture.
- The project is split into three main areas:
– Client: An Angular-based front end that includes separate modules/components for administrative and user functionalities. The structure shows many Angular components (admin, user, navbar, chat, authentication, etc.).
– Server: A C# ASP.NET Core back end following an MVC pattern with well-separated layers (Controllers, Services, Repositories, Models, and DTOs). This layer serves REST API endpoints, handles authorization (with middleware like AuthorizationMiddleware and ExceptionHandlingMiddleware), and orchestrates business logic.
– ML: A Python-based machine learning module that holds pre-trained models (pkl files), data processing scripts, and training scripts. This module appears designed to provide prediction capabilities (for diagnosis, medicine, treatment, etc.) that likely integrate with the server side via a service.

##### Analyzing the File Structure
- Client Side:
– The Client folder contains an Angular project (with angular.json, package.json, etc.) and is further organized into admin and user directories with corresponding components, assets, and routing configuration.
– There is a clear separation where the admin portion uses its own set of components (for dashboard, chat, appointment filtering, etc.) and the user portion handles patient interactions (login, appointment management, notifications, etc.).
- Server Side:
– The server code (in the Server folder) is organized by Controllers, Services, Data/Models, DTOs, Mappers, and Repositories.
– Notice that there is an MVC architecture and layered design. Specific services (AuthService, HoaDonService, etc.), globally applicable components like Middleware, and support for real-time communication (via ChatHub) make up the back end.
– Look also at configuration files (appsettings.json) and the database script (HeThongQuanLyPhongKham_Db.sql), which indicate the use of an SQL database.
- Machine Learning Module:
– The ML folder contains CSV data, pickle models for diagnosis, medicine, treatment, and associated Python scripts (app.py, create_dataset.py, train_models.py). This indicates a separate service for prediction functionality.

##### Detailing Relationships and Data Flow
– HTTP/REST API calls from the Angular Client to the Server.
– Bi-directional communication for real-time features (e.g., Client ⇄ Server ChatHub).
– The Server making direct calls/queries to the Database for persistent data.
– The Server sending request data to the ML module (via the MLService or PredictionController) and receiving prediction results.

##### Highlighting Architectural Patterns
- For the Server:
– Emphasize its layered structure: Controllers <—> Services <—> Repositories <—> Database.
– Point out the use of middleware (for error handling and authorization) and the MVC pattern.
- For the Client:
– Note the separation of concerns between admin and user (possibly even a modular pattern if different modules are lazy-loaded).
- For the ML Component:
– Illustrate the workflow: Data ingestion and processing (using Python scripts), model training/storage (pickle files), and prediction services.
– Mention how this module interfaces (likely via a REST API endpoint provided by the server’s PredictionController).

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Frontend Layer"
        AC("Angular Client (Admin & User Modules)"):::frontend
        AADM("Admin Module Components"):::frontend
        AUSR("User Module Components"):::frontend
        AC --> AADM
        AC --> AUSR
    end

    subgraph "Backend Layer"
        API("ASP.NET Core API Server"):::backend
        subgraph "API Layer"
            CTR("Controllers"):::backend
            MIL("Middlewares"):::backend
            CTR --> MIL
        end
        subgraph "Business Layer"
            SER("Services"):::backend
            REP("Repositories"):::backend
            SER --> REP
        end
        CH("Real-time Chat Hub"):::backend
        API --> CTR
        API --> SER
        API --> CH
    end

    ML("ML Prediction Engine (Python)"):::ml
    DB("SQL Database"):::database

    AC -->|"HTTP_API_Calls"| API
    AC <-->|"Chat_WebSocket"| CH
    API -->|"SQL_Query"| DB
    API <-->|"Prediction_Request_Response"| ML

    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef ml fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef database fill:#F5B7B1,stroke:#922B21,stroke-width:2px;

    click AC "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/tree/main/Client/HeThongHoTroVaQuanLyPhongKham"
    click AADM "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/tree/main/Client/HeThongHoTroVaQuanLyPhongKham/src/app/admins"
    click AUSR "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/tree/main/Client/HeThongHoTroVaQuanLyPhongKham/src/app/users"
    click API "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/tree/main/Server/HeThongHoTroVaQuanLyPhongKham"
    click CTR "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/tree/main/Server/HeThongHoTroVaQuanLyPhongKham/Controllers"
    click MIL "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/tree/main/Server/HeThongHoTroVaQuanLyPhongKham/Middlewares"
    click SER "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/tree/main/Server/HeThongHoTroVaQuanLyPhongKham/Services"
    click REP "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/tree/main/Server/HeThongHoTroVaQuanLyPhongKham/Repositories"
    click CH "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/blob/main/Server/HeThongHoTroVaQuanLyPhongKham/Hubs/ChatHub.cs"
    click ML "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/tree/main/ML"
    click DB "https://github.com/nguyendaithanh2805/hethonghotrovaquanlyphongkham/blob/main/HeThongQuanLyPhongKham_Db.sql"
```
