# nasrullaunais/carelanka architecture

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

- Interactive diagram: https://gitdiagram.com/nasrullaunais/carelanka
- Repository: https://github.com/nasrullaunais/carelanka

## Overview

CareLanka is a hospital operations platform with a staff-facing web UI and an ASP.NET API. Its principal workflows span patient registration and care, emergency call dispatch, equipment and pharmacy operations, and staff scheduling and coverage; authentication and persistence support these domains. The sampled code confirms the ward-coverage request path, patient self-service calls, equipment controller delegation, and emergency UI routing. Other domain areas are represented from the repository tree and source index; their internal links are left unasserted where implementation excerpts were unavailable.

Main entry points: [`api/Data/CareLankaDbContext.cs`](https://github.com/nasrullaunais/carelanka/blob/main/api/Data/CareLankaDbContext.cs) (Hospital database), [`api/Controllers/Common/AuthController.cs`](https://github.com/nasrullaunais/carelanka/blob/main/api/Controllers/Common/AuthController.cs) (Authentication endpoints), [`api/Services/Common/AuthService.cs`](https://github.com/nasrullaunais/carelanka/blob/main/api/Services/Common/AuthService.cs) (Authentication service), [`api/Services/Staff/WardCoverageService.cs`](https://github.com/nasrullaunais/carelanka/blob/main/api/Services/Staff/WardCoverageService.cs) (Coverage calculation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Staff and patient access"]
  node_web["Web application<br/>[App.tsx]"]
  node_emergency_ui["Emergency workspace"]
end

subgraph group_identity["Identity and API foundation"]
  node_api["HTTP API<br/>[Program.cs]"]
  node_auth_endpoints["Authentication endpoints<br/>[AuthController.cs]"]
  node_auth_service["Authentication service<br/>[AuthService.cs]"]
  node_auth_policy["Authorization policies<br/>[Policies.cs]"]
  node_common_errors["API errors<br/>[MessageCode.cs]"]
  node_common_dtos["Common API contracts"]
  node_database[("Hospital database")]
  node_refresh_tokens["Refresh token records<br/>[RefreshToken.cs]"]
  node_common_service_contract["Authentication contract<br/>[IAuthService.cs]"]
  node_common_exceptions["API exception types<br/>[ApiException.cs]"]
  node_principal_roles["Principal roles<br/>[PrincipalRole.cs]"]
end

subgraph group_patient["Patient care"]
  node_patient_endpoints["Patient endpoints<br/>[MeController.cs]"]
  node_patient_services["Patient services"]
  node_patient_contracts["Patient care contracts"]
end

subgraph group_emergency["Emergency response"]
  node_emergency_endpoints["Emergency endpoints"]
  node_emergency_services["Emergency call workflow"]
  node_dispatch_record["Dispatch records<br/>[Dispatch.cs]"]
  node_proposal_worker["Proposal worker"]
  node_proposal_executor["Proposal executor"]
end

subgraph group_operations["Hospital operations"]
  node_equipment_endpoints["Equipment endpoints"]
  node_equipment_services["Equipment services"]
  node_staff_endpoints["Staff endpoints"]
  node_coverage_endpoint["Ward coverage endpoint"]
  node_coverage_service["Coverage calculation"]
  node_staff_data["Staffing records"]
end

node_staff_users(("Staff users"))
node_patients(("Patients"))

node_staff_users -.->|"use"| node_web
node_patients -.->|"use"| node_web
node_web -->|"routes to"| node_emergency_ui
node_emergency_ui -.->|"uses API"| node_emergency_endpoints
node_staff_users -->|"manage response"| node_emergency_ui
node_api -->|"configures"| node_auth_policy
node_api -->|"registers handler"| node_common_errors
node_auth_endpoints -->|"calls"| node_auth_service
node_auth_service -->|"reads and writes"| node_database
node_auth_endpoints -->|"accepts and returns"| node_common_dtos
node_auth_service -->|"uses records"| node_refresh_tokens
node_auth_endpoints -->|"uses contract"| node_common_service_contract
node_patient_endpoints -->|"calls"| node_patient_services
node_patient_endpoints -->|"accepts and returns"| node_patient_contracts
node_patient_services -.->|"uses"| node_database
node_emergency_services -->|"uses"| node_database
node_emergency_services -->|"works with"| node_dispatch_record
node_proposal_worker -->|"runs"| node_proposal_executor
node_equipment_endpoints -->|"calls"| node_equipment_services
node_equipment_services -.->|"uses"| node_database
node_staff_endpoints -.->|"manages"| node_staff_data
node_coverage_endpoint -->|"calls"| node_coverage_service
node_coverage_service -->|"queries"| node_database
node_coverage_service -->|"evaluates shifts"| node_staff_data

click node_web "https://github.com/nasrullaunais/carelanka/blob/main/web-ui/src/App.tsx"
click node_emergency_ui "https://github.com/nasrullaunais/carelanka/blob/main/web-ui/src/features/emergency/emergency-routes.tsx"
click node_api "https://github.com/nasrullaunais/carelanka/blob/main/api/Program.cs"
click node_auth_endpoints "https://github.com/nasrullaunais/carelanka/blob/main/api/Controllers/Common/AuthController.cs"
click node_auth_service "https://github.com/nasrullaunais/carelanka/blob/main/api/Services/Common/AuthService.cs"
click node_auth_policy "https://github.com/nasrullaunais/carelanka/blob/main/api/Common/Auth/Policies.cs"
click node_common_errors "https://github.com/nasrullaunais/carelanka/blob/main/api/Common/Errors/MessageCode.cs"
click node_common_dtos "https://github.com/nasrullaunais/carelanka/tree/main/api/DTOs/Common"
click node_database "https://github.com/nasrullaunais/carelanka/blob/main/api/Data/CareLankaDbContext.cs"
click node_refresh_tokens "https://github.com/nasrullaunais/carelanka/blob/main/api/Data/Entities/Common/RefreshToken.cs"
click node_patient_endpoints "https://github.com/nasrullaunais/carelanka/blob/main/api/Controllers/Patient/MeController.cs"
click node_patient_services "https://github.com/nasrullaunais/carelanka/tree/main/api/Services/Patient"
click node_patient_contracts "https://github.com/nasrullaunais/carelanka/tree/main/api/DTOs/Patient"
click node_emergency_endpoints "https://github.com/nasrullaunais/carelanka/tree/main/api/Controllers/Emergency"
click node_emergency_services "https://github.com/nasrullaunais/carelanka/blob/main/api/Services/Emergency/EmergencyCallService.cs"
click node_dispatch_record "https://github.com/nasrullaunais/carelanka/blob/main/api/Data/Entities/Emergency/Dispatch.cs"
click node_proposal_worker "https://github.com/nasrullaunais/carelanka/blob/main/api/Agents/Emergency/DispatchProposalWorker.cs"
click node_proposal_executor "https://github.com/nasrullaunais/carelanka/blob/main/api/Agents/Emergency/DispatchProposalExecutor.cs"
click node_equipment_endpoints "https://github.com/nasrullaunais/carelanka/blob/main/api/Controllers/Equipment/EquipmentItemsController.cs"
click node_equipment_services "https://github.com/nasrullaunais/carelanka/tree/main/api/Services/Equipment"
click node_staff_endpoints "https://github.com/nasrullaunais/carelanka/tree/main/api/Controllers/Staff"
click node_coverage_endpoint "https://github.com/nasrullaunais/carelanka/blob/main/api/Controllers/Staff/WardCoverageController.cs"
click node_coverage_service "https://github.com/nasrullaunais/carelanka/blob/main/api/Services/Staff/WardCoverageService.cs"
click node_staff_data "https://github.com/nasrullaunais/carelanka/tree/main/api/Data/Entities/Staff"
click node_common_service_contract "https://github.com/nasrullaunais/carelanka/blob/main/api/Services/Common/IAuthService.cs"
click node_common_exceptions "https://github.com/nasrullaunais/carelanka/blob/main/api/Common/Exceptions/ApiException.cs"
click node_principal_roles "https://github.com/nasrullaunais/carelanka/blob/main/api/Data/Enums/PrincipalRole.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_web,node_emergency_ui,node_staff_users toneBlue
class node_api,node_auth_endpoints,node_auth_service,node_auth_policy,node_common_errors,node_common_dtos,node_database,node_refresh_tokens,node_common_service_contract,node_common_exceptions,node_principal_roles toneAmber
class node_patient_endpoints,node_patient_services,node_patient_contracts toneMint
class node_emergency_endpoints,node_emergency_services,node_dispatch_record,node_proposal_worker,node_proposal_executor toneRose
class node_equipment_endpoints,node_equipment_services,node_staff_endpoints,node_coverage_endpoint,node_coverage_service,node_staff_data,node_patients toneIndigo
```

## Components

### Staff and patient access

- [Web application](https://github.com/nasrullaunais/carelanka/blob/main/web-ui/src/App.tsx): `web-ui/src/App.tsx`
- [Emergency workspace](https://github.com/nasrullaunais/carelanka/blob/main/web-ui/src/features/emergency/emergency-routes.tsx): `web-ui/src/features/emergency/emergency-routes.tsx`

### Identity and API foundation

- [HTTP API](https://github.com/nasrullaunais/carelanka/blob/main/api/Program.cs): `api/Program.cs`
- [Authentication endpoints](https://github.com/nasrullaunais/carelanka/blob/main/api/Controllers/Common/AuthController.cs): `api/Controllers/Common/AuthController.cs`
- [Authentication service](https://github.com/nasrullaunais/carelanka/blob/main/api/Services/Common/AuthService.cs): `api/Services/Common/AuthService.cs`
- [Authorization policies](https://github.com/nasrullaunais/carelanka/blob/main/api/Common/Auth/Policies.cs): `api/Common/Auth/Policies.cs`
- [API errors](https://github.com/nasrullaunais/carelanka/blob/main/api/Common/Errors/MessageCode.cs): `api/Common/Errors/MessageCode.cs`
- [Common API contracts](https://github.com/nasrullaunais/carelanka/tree/main/api/DTOs/Common): `api/DTOs/Common`
- [Hospital database](https://github.com/nasrullaunais/carelanka/blob/main/api/Data/CareLankaDbContext.cs): `api/Data/CareLankaDbContext.cs`
- [Refresh token records](https://github.com/nasrullaunais/carelanka/blob/main/api/Data/Entities/Common/RefreshToken.cs): `api/Data/Entities/Common/RefreshToken.cs`
- [Authentication contract](https://github.com/nasrullaunais/carelanka/blob/main/api/Services/Common/IAuthService.cs): `api/Services/Common/IAuthService.cs`
- [API exception types](https://github.com/nasrullaunais/carelanka/blob/main/api/Common/Exceptions/ApiException.cs): `api/Common/Exceptions/ApiException.cs`
- [Principal roles](https://github.com/nasrullaunais/carelanka/blob/main/api/Data/Enums/PrincipalRole.cs): `api/Data/Enums/PrincipalRole.cs`

### Patient care

- [Patient endpoints](https://github.com/nasrullaunais/carelanka/blob/main/api/Controllers/Patient/MeController.cs): `api/Controllers/Patient/MeController.cs`
- [Patient services](https://github.com/nasrullaunais/carelanka/tree/main/api/Services/Patient): `api/Services/Patient`
- [Patient care contracts](https://github.com/nasrullaunais/carelanka/tree/main/api/DTOs/Patient): `api/DTOs/Patient`

### Emergency response

- [Emergency endpoints](https://github.com/nasrullaunais/carelanka/tree/main/api/Controllers/Emergency): `api/Controllers/Emergency`
- [Emergency call workflow](https://github.com/nasrullaunais/carelanka/blob/main/api/Services/Emergency/EmergencyCallService.cs): `api/Services/Emergency/EmergencyCallService.cs`
- [Dispatch records](https://github.com/nasrullaunais/carelanka/blob/main/api/Data/Entities/Emergency/Dispatch.cs): `api/Data/Entities/Emergency/Dispatch.cs`
- [Proposal worker](https://github.com/nasrullaunais/carelanka/blob/main/api/Agents/Emergency/DispatchProposalWorker.cs): `api/Agents/Emergency/DispatchProposalWorker.cs`
- [Proposal executor](https://github.com/nasrullaunais/carelanka/blob/main/api/Agents/Emergency/DispatchProposalExecutor.cs): `api/Agents/Emergency/DispatchProposalExecutor.cs`

### Hospital operations

- [Equipment endpoints](https://github.com/nasrullaunais/carelanka/blob/main/api/Controllers/Equipment/EquipmentItemsController.cs): `api/Controllers/Equipment/EquipmentItemsController.cs`
- [Equipment services](https://github.com/nasrullaunais/carelanka/tree/main/api/Services/Equipment): `api/Services/Equipment`
- [Staff endpoints](https://github.com/nasrullaunais/carelanka/tree/main/api/Controllers/Staff): `api/Controllers/Staff`
- [Ward coverage endpoint](https://github.com/nasrullaunais/carelanka/blob/main/api/Controllers/Staff/WardCoverageController.cs): `api/Controllers/Staff/WardCoverageController.cs`
- [Coverage calculation](https://github.com/nasrullaunais/carelanka/blob/main/api/Services/Staff/WardCoverageService.cs): `api/Services/Staff/WardCoverageService.cs`
- [Staffing records](https://github.com/nasrullaunais/carelanka/tree/main/api/Data/Entities/Staff): `api/Data/Entities/Staff`

### Other components

- **Staff users**
- **Patients**

## Connections

- Staff users → Web application: use
- Patients → Web application: use
- Web application → Emergency workspace: routes to (evidence: `web-ui/src/App.tsx`)
- Emergency workspace → Emergency endpoints: uses API
- Staff users → Emergency workspace: manage response (evidence: `web-ui/src/features/emergency/emergency-routes.tsx`)
- HTTP API → Authorization policies: configures (evidence: `api/Program.cs`)
- HTTP API → API errors: registers handler (evidence: `api/Program.cs`)
- Authentication endpoints → Authentication service: calls (evidence: `api/Controllers/Common/AuthController.cs`)
- Authentication service → Hospital database: reads and writes (evidence: `api/Services/Common/AuthService.cs`)
- Authentication endpoints → Common API contracts: accepts and returns (evidence: `api/Controllers/Common/AuthController.cs`)
- Authentication service → Refresh token records: uses records (evidence: `api/Services/Common/AuthService.cs`)
- Authentication endpoints → Authentication contract: uses contract (evidence: `api/Controllers/Common/AuthController.cs`)
- Patient endpoints → Patient services: calls (evidence: `api/Controllers/Patient/MeController.cs`)
- Patient endpoints → Patient care contracts: accepts and returns (evidence: `api/Controllers/Patient/MeController.cs`)
- Patient services → Hospital database: uses
- Emergency call workflow → Hospital database: uses (evidence: `api/Services/Emergency/EmergencyCallService.cs`)
- Emergency call workflow → Dispatch records: works with (evidence: `api/Services/Emergency/EmergencyCallService.cs`)
- Proposal worker → Proposal executor: runs (evidence: `api/Agents/Emergency/DispatchProposalWorker.cs`)
- Equipment endpoints → Equipment services: calls (evidence: `api/Controllers/Equipment/EquipmentItemsController.cs`)
- Equipment services → Hospital database: uses
- Staff endpoints → Staffing records: manages
- Ward coverage endpoint → Coverage calculation: calls (evidence: `api/Controllers/Staff/WardCoverageController.cs`)
- Coverage calculation → Hospital database: queries (evidence: `api/Services/Staff/WardCoverageService.cs`)
- Coverage calculation → Staffing records: evaluates shifts (evidence: `api/Services/Staff/WardCoverageService.cs`)
