# lhknguyen15/fomed-api architecture

> Architecture diagram of the GitHub repository lhknguyen15/fomed-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lhknguyen15/fomed-api
- Repository: https://github.com/lhknguyen15/fomed-api

## Overview

FoMed is a clinic-management backend API. Patients and clinic staff send requests to its endpoints; authentication and domain services handle booking and appointment status, doctor schedules, patient/doctor profiles, and clinical records including prescriptions, service orders and lab results. Services access SQL Server through repositories and a Unit of Work, while JWTs support authenticated and role-restricted requests. The README identifies billing and catalog modules as product areas, though their implementation was not sampled; their links are therefore limited to the documented API structure.

Main entry points: [`FoMed-API/FoMed.Api/Program.cs`](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Program.cs) (API host), [`FoMed-API/FoMed.Infrastructure/UnitOfWork/UnitOfWork.cs`](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Infrastructure/UnitOfWork/UnitOfWork.cs) (Unit of Work), [`FoMed-API/FoMed.Application/Services/Auth/AuthService.cs`](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Auth/AuthService.cs) (Auth service), [`FoMed-API/FoMed.Api/Controllers/AuthController.cs`](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/AuthController.cs) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_program["API host<br/>[Program.cs]"]
  node_authctl["Authentication<br/>[AuthController.cs]"]
  node_authsvc["Auth service<br/>[AuthService.cs]"]
  node_jwt["JWT tokens<br/>[JwtTokenService.cs]"]
end

subgraph group_care["Appointments and schedules"]
  node_appointmentctl["Appointments API"]
  node_appointmentsvc["Appointment service"]
  node_schedulectl["Schedule API"]
  node_schedulesvc["Schedule service"]
end

subgraph group_clinical["Clinical and billing"]
  node_clinicalctl["Clinical API"]
  node_clinical["Clinical service<br/>[ClinicalService.cs]"]
  node_invoicectl["Invoice API"]
  node_billing["Billing service<br/>[BillingService.cs]"]
end

subgraph group_people["People and catalog"]
  node_doctorctl["Doctor API"]
  node_doctorservice["Doctor service<br/>[DoctorService.cs]"]
  node_patientctl["Patient API"]
  node_profilectl["Profile API"]
  node_catalogctl["Public catalog"]
end

subgraph group_data["Persistence"]
  node_uow["Unit of Work<br/>[UnitOfWork.cs]"]
  node_apptrepo["Appointment repository"]
  node_db[("Clinic database<br/>[FoMedDbContext.cs]")]
end

node_client(("API clients"))

node_client -->|"sends requests"| node_program
node_program -->|"routes"| node_authctl
node_program -->|"routes"| node_appointmentctl
node_program -->|"routes"| node_schedulectl
node_program -->|"routes"| node_clinicalctl
node_program -->|"routes"| node_invoicectl
node_program -->|"routes"| node_doctorctl
node_program -->|"routes"| node_patientctl
node_program -->|"routes"| node_profilectl
node_program -->|"routes"| node_catalogctl
node_authctl -->|"invokes"| node_authsvc
node_authsvc -->|"reads and writes"| node_uow
node_authsvc -->|"creates token"| node_jwt
node_appointmentctl -->|"invokes"| node_appointmentsvc
node_appointmentsvc -->|"reads and writes"| node_uow
node_schedulectl -->|"invokes"| node_schedulesvc
node_schedulesvc -->|"reads and writes"| node_uow
node_clinicalctl -->|"invokes"| node_clinical
node_clinical -->|"queries and writes"| node_db
node_invoicectl -->|"invokes"| node_billing
node_doctorctl -->|"invokes"| node_doctorservice
node_doctorservice -->|"accesses data"| node_uow
node_patientctl -.->|"accesses data"| node_uow
node_profilectl -.->|"accesses data"| node_uow
node_catalogctl -.->|"accesses data"| node_uow
node_uow -->|"provides repository"| node_apptrepo
node_apptrepo -->|"queries and writes"| node_db

click node_program "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Program.cs"
click node_authctl "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/AuthController.cs"
click node_authsvc "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Auth/AuthService.cs"
click node_jwt "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Infrastructure/Authentication/JwtTokenService.cs"
click node_appointmentctl "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/AppointmentController.cs"
click node_appointmentsvc "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Appointment/AppointmentService.cs"
click node_schedulectl "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/DoctorScheduleController.cs"
click node_schedulesvc "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Doctor/DoctorScheduleService.cs"
click node_clinicalctl "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/ClinicalController.cs"
click node_clinical "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Clinical/ClinicalService.cs"
click node_invoicectl "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/InvoiceController.cs"
click node_billing "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Clinical/BillingService.cs"
click node_doctorctl "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/DoctorController.cs"
click node_doctorservice "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Doctor/DoctorService.cs"
click node_patientctl "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/PatientController.cs"
click node_profilectl "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/ProfileController.cs"
click node_catalogctl "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/PublicCatalogController.cs"
click node_uow "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Infrastructure/UnitOfWork/UnitOfWork.cs"
click node_apptrepo "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Infrastructure/Repositories/AppointmentRepository.cs"
click node_db "https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Infrastructure/DbContext/FoMedDbContext.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_program,node_authctl,node_authsvc,node_jwt,node_client toneBlue
class node_appointmentctl,node_appointmentsvc,node_schedulectl,node_schedulesvc toneAmber
class node_clinicalctl,node_clinical,node_invoicectl,node_billing toneMint
class node_doctorctl,node_doctorservice,node_patientctl,node_profilectl,node_catalogctl toneRose
class node_uow,node_apptrepo,node_db toneIndigo
```

## Components

### API and identity

- [API host](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Program.cs): `FoMed-API/FoMed.Api/Program.cs`
- [Authentication](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/AuthController.cs): `FoMed-API/FoMed.Api/Controllers/AuthController.cs`
- [Auth service](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Auth/AuthService.cs): `FoMed-API/FoMed.Application/Services/Auth/AuthService.cs`
- [JWT tokens](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Infrastructure/Authentication/JwtTokenService.cs): `FoMed-API/FoMed.Infrastructure/Authentication/JwtTokenService.cs`

### Appointments and schedules

- [Appointments API](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/AppointmentController.cs): `FoMed-API/FoMed.Api/Controllers/AppointmentController.cs`
- [Appointment service](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Appointment/AppointmentService.cs): `FoMed-API/FoMed.Application/Services/Appointment/AppointmentService.cs`
- [Schedule API](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/DoctorScheduleController.cs): `FoMed-API/FoMed.Api/Controllers/DoctorScheduleController.cs`
- [Schedule service](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Doctor/DoctorScheduleService.cs): `FoMed-API/FoMed.Application/Services/Doctor/DoctorScheduleService.cs`

### Clinical and billing

- [Clinical API](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/ClinicalController.cs): `FoMed-API/FoMed.Api/Controllers/ClinicalController.cs`
- [Clinical service](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Clinical/ClinicalService.cs): `FoMed-API/FoMed.Application/Services/Clinical/ClinicalService.cs`
- [Invoice API](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/InvoiceController.cs): `FoMed-API/FoMed.Api/Controllers/InvoiceController.cs`
- [Billing service](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Clinical/BillingService.cs): `FoMed-API/FoMed.Application/Services/Clinical/BillingService.cs`

### People and catalog

- [Doctor API](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/DoctorController.cs): `FoMed-API/FoMed.Api/Controllers/DoctorController.cs`
- [Doctor service](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Application/Services/Doctor/DoctorService.cs): `FoMed-API/FoMed.Application/Services/Doctor/DoctorService.cs`
- [Patient API](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/PatientController.cs): `FoMed-API/FoMed.Api/Controllers/PatientController.cs`
- [Profile API](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/ProfileController.cs): `FoMed-API/FoMed.Api/Controllers/ProfileController.cs`
- [Public catalog](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Api/Controllers/PublicCatalogController.cs): `FoMed-API/FoMed.Api/Controllers/PublicCatalogController.cs`

### Persistence

- [Unit of Work](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Infrastructure/UnitOfWork/UnitOfWork.cs): `FoMed-API/FoMed.Infrastructure/UnitOfWork/UnitOfWork.cs`
- [Appointment repository](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Infrastructure/Repositories/AppointmentRepository.cs): `FoMed-API/FoMed.Infrastructure/Repositories/AppointmentRepository.cs`
- [Clinic database](https://github.com/lhknguyen15/fomed-api/blob/main/FoMed-API/FoMed.Infrastructure/DbContext/FoMedDbContext.cs): `FoMed-API/FoMed.Infrastructure/DbContext/FoMedDbContext.cs`

### Other components

- **API clients**

## Connections

- API clients → API host: sends requests
- API host → Authentication: routes
- API host → Appointments API: routes
- API host → Schedule API: routes
- API host → Clinical API: routes
- API host → Invoice API: routes
- API host → Doctor API: routes
- API host → Patient API: routes
- API host → Profile API: routes
- API host → Public catalog: routes
- Authentication → Auth service: invokes
- Auth service → Unit of Work: reads and writes
- Auth service → JWT tokens: creates token
- Appointments API → Appointment service: invokes
- Appointment service → Unit of Work: reads and writes
- Schedule API → Schedule service: invokes
- Schedule service → Unit of Work: reads and writes
- Clinical API → Clinical service: invokes
- Clinical service → Clinic database: queries and writes
- Invoice API → Billing service: invokes
- Doctor API → Doctor service: invokes
- Doctor service → Unit of Work: accesses data
- Patient API → Unit of Work: accesses data
- Profile API → Unit of Work: accesses data
- Public catalog → Unit of Work: accesses data
- Unit of Work → Appointment repository: provides repository
- Appointment repository → Clinic database: queries and writes
