# namanh2508/nt208.p23-group-4 architecture

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

- Interactive diagram: https://gitdiagram.com/namanh2508/nt208.p23-group-4
- Repository: https://github.com/namanh2508/nt208.p23-group-4

## Overview

##### Main Components
- Frontend (Client Applications):
– React-based web application found in the “fe” folder for interactive UI components.
– Static HTML pages in “hospital” for various public and administrative interfaces.
- Backend Services (Hospital Management System):
– Django project (“hospital_web”) which encompasses multiple Django apps such as UserManagement, api, and hospitalManagement.
– This area includes REST APIs that serve the frontend and handle business logic.
- Database:
– PostgreSQL as the relational database, used to store structured data such as user records, appointment details, and EHR.
- API Gateway:
– An entry point for the clients; from the readme, it acts as the contact point for routing, authentication, and rate limiting.
- Core Services (as identified in the Readme’s component descriptions):
– Services like Auth Service, Appointment Service, EHR Service, Consultation Service, Prescription Service, Billing Service, and Notification Service.
- Infrastructure & External Services:
– Messaging or asynchronous communication (message queues for notification, etc.).
– Integration with external payment gateways, video conferencing services, SMS/Email gateways, and possibly even a search engine.
– Potential integration with the Google Calendar API for scheduling tasks like exercise reminders.

##### Relationships and Interactions
- Data flows exist between client applications (web/mobile) and the API Gateway.
- The API Gateway then routes incoming requests to the appropriate backend service.
- Backend services interact with the PostgreSQL database to retrieve and store data.
- External services (e.g., Payment Gateway, Video Conferencing) are called by the respective backend services.
- Additionally, the system may use asynchronous messaging (via a Message Queue) for operations like notifications or appointment confirmations.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Frontend and backend are clearly separated; the backend is also modularized into distinct Django apps that correspond to specific business functionalities.
- API-Driven Communication: The API Gateway funnels all requests and responses, ensuring a unified access point cloud security and scalability.
- Microservices/Multi-Service Architecture: While implemented as Django apps within a single project, the design suggests discrete “services” (Auth, Appointment, etc.) that could later be decoupled.
- Scalability and Maintainability: The use of standardized technologies like React and Django REST Framework, combined with external integrations for notifications, payment, and video, assures that each layer is designed for independent scaling and easy maintenance.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["React Web Application"]:::frontend
        SH["Static HTML Interfaces"]:::frontend
    end

    %% API Gateway
    AG["API Gateway"]:::gateway

    %% Backend Layer
    subgraph "Backend Layer"
        DJ["Django Project"]:::backend
        subgraph "Django Apps"
            UM["User Management Service"]:::backend
            API["API Endpoints & Services"]:::backend
            HM["Hospital Management"]:::backend
        end
        subgraph "Core Services"
            AS["Auth Service"]:::service
            APS["Appointment Service"]:::service
            EHS["EHR Service"]:::service
            CS["Consultation Service"]:::service
            PS["Prescription Service"]:::service
            BS["Billing Service"]:::service
            NS["Notification Service"]:::service
        end
    end

    %% Data and Infrastructure
    subgraph "Data & Infrastructure"
        DB["PostgreSQL Database"]:::database
        MQ["Message Queue"]:::infra
    end

    %% External Services
    subgraph "External Services"
        PG["Payment Gateway"]:::external
        VC["Video Conferencing Service"]:::external
        SE["SMS/Email Gateway"]:::external
        GC["Google Calendar API"]:::external
        SV["Search Engine"]:::external
    end

    %% Connections: Frontend to API Gateway
    FE -->|"sends request"| AG
    SH -->|"sends request"| AG

    %% API Gateway to Backend
    AG -->|"routes request"| DJ

    %% Django Project interactions
    DJ -->|"handles auth"| UM
    DJ -->|"handles API"| API
    DJ -->|"handles management"| HM
    DJ -->|"delegates to"| AS
    DJ -->|"delegates to"| APS
    DJ -->|"delegates to"| EHS
    DJ -->|"delegates to"| CS
    DJ -->|"delegates to"| PS
    DJ -->|"delegates to"| BS
    DJ -->|"delegates to"| NS

    %% Core Services and Data interactions
    AS -->|"stores data"| DB
    APS -->|"updates records"| DB
    EHS -->|"reads/writes patient data"| DB
    CS -->|"sends notifications"| MQ
    PS -->|"writes prescriptions"| DB
    BS -->|"processes payments"| DB
    NS -->|"queues notifications"| MQ

    %% Core Services to External Services
    APS -->|"integrates with"| PG
    CS -->|"integrates with"| VC
    NS -->|"integrates with"| SE
    APS -->|"syncs with"| GC
    NS -->|"queries"| SV

    %% Click Events
    click FE "https://github.com/namanh2508/nt208.p23-group-4/tree/main/fe"
    click SH "https://github.com/namanh2508/nt208.p23-group-4/tree/main/hospital"
    click DJ "https://github.com/namanh2508/nt208.p23-group-4/tree/main/hospital_web/hospital_web"
    click UM "https://github.com/namanh2508/nt208.p23-group-4/tree/main/hospital_web/UserManagement"
    click API "https://github.com/namanh2508/nt208.p23-group-4/tree/main/hospital_web/api"
    click HM "https://github.com/namanh2508/nt208.p23-group-4/tree/main/hospital_web/hospitalManagement"

    %% Styles
    classDef frontend fill:#F7DC6F,stroke:#A93226,stroke-width:2px;
    classDef gateway fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef backend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef service fill:#E8DAEF,stroke:#884EA0,stroke-width:2px;
    classDef database fill:#ABEBF9,stroke:#117864,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#229954,stroke-width:2px;
    classDef infra fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
```
