# phamquangvinhfpt/dr-dentist-api architecture

> Architecture diagram of the GitHub repository phamquangvinhfpt/dr-dentist-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phamquangvinhfpt/dr-dentist-api
- Repository: https://github.com/phamquangvinhfpt/dr-dentist-api

## Overview

##### Main Components Identification

The system should be represented as a layered architecture with the following main components:

a. Core Layer:
- Application (Business Logic)
- Domain (Entities and Business Rules)
- Shared (Common Components)

b. Infrastructure Layer:
- Persistence (Database Access)
- Identity (Authentication/Authorization)
- Notifications (SignalR)
- Caching (Redis)
- Background Jobs (Hangfire)

c. API Layer:
- Controllers
- Middleware
- Configuration

##### Key Relationships and Interactions

a. Client Applications → API Layer:
- REST API endpoints
- SignalR real-time connections
- Authentication/Authorization flows

b. API Layer → Core Layer:
- Command/Query flow
- Business logic execution
- Domain entity manipulation

c. Core Layer → Infrastructure Layer:
- Database operations
- External service integration
- Caching operations

##### Specific Components

a. External Services:
- PostgreSQL Database
- Redis Cache
- SMS Service
- Email Service
- File Storage

b. Security Components:
- JWT Authentication
- Role-based Authorization
- Tenant Management

c. Background Processing:
- Hangfire Job Scheduler
- Queue Workers

##### Specific Features

- Multi-tenant architecture
- Real-time notifications system
- Appointment management
- Medical records handling
- Payment processing
- Customer service workflow
- Document management

##### Additional Elements

- Data flow directions
- Security boundaries
- Caching layers
- Scalable components

- Clean Architecture principles
- Microservice-ready design
- Security-first approach
- Real-time communication capabilities
- Scalability considerations

Remember to maintain a balance between detail and clarity, focusing on the dental clinic domain-specific features while showing the technical architecture that supports them.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CL[Client Applications]:::client
    end

    subgraph Gateway
        LB[API Gateway/Load Balancer]:::gateway
    end

    subgraph "Host Layer"
        CO["Controllers"]:::host
        MW["Middleware"]:::host
        AD["API Documentation"]:::host
    end

    subgraph "Application Layer"
        AP["Application Services"]:::application
        subgraph "Business Components"
            direction TB
            AM["Appointment Management"]:::business
            MR["Medical Records"]:::business
            CS["Customer Services"]:::business
            TP["Treatment Plans"]:::business
            PM["Payment Management"]:::business
            UM["User Management"]:::business
            NT["Notification System"]:::business
        end
    end

    subgraph "Domain Layer"
        DM["Domain Model"]:::domain
        EN["Entities"]:::domain
        VO["Value Objects"]:::domain
        DS["Domain Services"]:::domain
    end

    subgraph "Infrastructure Layer"
        direction TB
        subgraph "Data Persistence"
            PG["PostgreSQL Database"]:::database
            RC["Redis Cache"]:::cache
        end

        subgraph "External Services"
            direction TB
            EM["Email Service"]:::external
            SM["SMS Service"]:::external
            FS["File Storage"]:::external
            CP["ReCAPTCHA"]:::external
        end

        subgraph "Background Processing"
            HF["Hangfire Jobs"]:::background
            SR["SignalR"]:::realtime
        end

        subgraph "Security"
            AT["Authentication"]:::security
            MT["Multitenancy"]:::security
        end
    end

    %% Connections
    CL --> LB
    LB --> CO
    CO --> MW
    CO --> AD
    MW --> AP
    AP --> DM
    DM --> PG
    DM --> RC
    AP --> EM
    AP --> SM
    AP --> FS
    AP --> CP
    AP --> HF
    AP --> SR
    MT --> PG

    %% Click Events
    click CO "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Host/Controllers/"
    click AP "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Core/Application/"
    click DM "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Core/Domain/"
    click PG "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/Persistence/"
    click RC "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/Caching/"
    click SR "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/Notifications/"
    click HF "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/BackgroundJobs/"
    click EM "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/Mailing/"
    click SM "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/SpeedSMS/"
    click FS "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/FileStorage/"
    click CP "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/reCAPTCHAv3/"
    click AT "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/Auth/"
    click MT "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/Multitenancy/"
    click MW "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/Middleware/"
    click AD "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Infrastructure/OpenApi/"
    click AM "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Core/Application/Appointments/"
    click MR "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Core/Application/MedicalRecords/"
    click CS "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Core/Application/CustomerServices/"
    click TP "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Core/Application/TreatmentPlan/"
    click PM "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Core/Application/Payments/"
    click UM "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Core/Application/Identity/"
    click NT "https://github.com/phamquangvinhfpt/dr-dentist-api/tree/main/src/Core/Application/Notifications/"

    %% Styles
    classDef client fill:#B2D7DA
    classDef gateway fill:#95B1DB
    classDef host fill:#9FBBCC
    classDef application fill:#7FB77E
    classDef business fill:#90B77D
    classDef domain fill:#52734D
    classDef database fill:#FFC090
    classDef cache fill:#FFCF96
    classDef external fill:#F6D7A7
    classDef background fill:#C8E3D4
    classDef security fill:#FF9B9B
    classDef realtime fill:#87AAAA

    %% Legend
    subgraph Legend
        L1[Client]:::client
        L2[Gateway]:::gateway
        L3[Host]:::host
        L4[Application]:::application
        L5[Domain]:::domain
        L6[Database]:::database
        L7[External Services]:::external
        L8[Background Jobs]:::background
        L9[Security]:::security
        L10[Real-time]:::realtime
    end
```
