# trankinhnguyen-ctrl/medicare architecture

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

- Interactive diagram: https://gitdiagram.com/trankinhnguyen-ctrl/medicare
- Repository: https://github.com/trankinhnguyen-ctrl/medicare

## Overview

MediCare is a UI-independent TypeScript mock appointment system, not a deployed HTTP service. Its principal workflow is patient OTP verification and registration/login, followed by browsing doctors and schedules, booking or managing appointments, and viewing notifications. Services implement domain rules over shared in-memory repositories and mock data; API functions expose the operations. The README documents further behavior such as cancellation limits and booking horizons. Edges reflect shown calls, indexed references, or README statements; unsampled modules are represented only where their subsystem and path are supported.

Main entry points: [`src/services/AppointmentService.ts`](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/AppointmentService.ts) (Appointment management), [`src/repositories/repositories.ts`](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/repositories/repositories.ts) (Repositories), [`src/api/context.ts`](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/context.ts) (Service context), [`src/services/AuthService.ts`](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/AuthService.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Function API"]
  node_auth_api["Auth functions<br/>[AuthApi.ts]"]
  node_doctor_api["Doctor functions<br/>[DoctorApi.ts]"]
  node_schedule_api["Schedule functions<br/>[ScheduleApi.ts]"]
  node_appointment_api["Appointment functions<br/>[AppointmentApi.ts]"]
  node_notification_api["Notification functions<br/>[NotificationApi.ts]"]
  node_context["Service context<br/>[context.ts]"]
end

subgraph group_domain["Domain Services"]
  node_auth_service["Authentication<br/>[AuthService.ts]"]
  node_doctor_service["Doctor catalog<br/>[DoctorService.ts]"]
  node_schedule_service["Schedule availability<br/>[ScheduleService.ts]"]
  node_appointment_service["Appointment management"]
  node_notification_service["Notification management"]
end

subgraph group_storage["Mock Data"]
  node_repositories["Repositories<br/>[repositories.ts]"]
  node_mock_data[("In-memory records<br/>[mockData.ts]")]
end

subgraph group_shared["Shared Types"]
  node_entities["Domain entities<br/>[entities.ts]"]
  node_response["API response types<br/>[ApiResponse.ts]"]
  node_errors["Error codes<br/>[ErrorCode.ts]"]
  node_common["Date and ID helpers<br/>[common.ts]"]
end

node_patient(("Patient"))

node_patient -->|"uses"| node_auth_api
node_patient -.->|"browses"| node_doctor_api
node_patient -.->|"checks availability"| node_schedule_api
node_patient -.->|"books and manages"| node_appointment_api
node_patient -.->|"views updates"| node_notification_api
node_auth_api -->|"delegates"| node_auth_service
node_doctor_api -->|"delegates"| node_doctor_service
node_schedule_api -->|"delegates"| node_schedule_service
node_appointment_api -->|"delegates"| node_appointment_service
node_notification_api -->|"delegates"| node_notification_service
node_context -->|"creates"| node_auth_service
node_context -->|"creates"| node_doctor_service
node_context -->|"creates"| node_schedule_service
node_context -->|"creates"| node_appointment_service
node_context -->|"creates"| node_notification_service
node_auth_service -->|"reads and writes"| node_repositories
node_appointment_service -->|"checks session"| node_auth_service
node_appointment_service -->|"reads and writes"| node_repositories
node_schedule_service -->|"reads schedules"| node_repositories
node_doctor_service -->|"reads catalog"| node_repositories
node_notification_service -->|"reads and writes"| node_repositories
node_appointment_service -->|"uses date helpers"| node_common
node_auth_service -->|"uses helpers"| node_common
node_schedule_service -->|"uses date helpers"| node_common
node_repositories -->|"accesses arrays"| node_mock_data
node_mock_data -->|"types records"| node_entities
node_auth_api -->|"returns"| node_response
node_appointment_service -->|"returns"| node_response
node_appointment_service -->|"uses codes"| node_errors
node_common -->|"builds responses"| node_response

click node_auth_api "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/AuthApi.ts"
click node_doctor_api "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/DoctorApi.ts"
click node_schedule_api "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/ScheduleApi.ts"
click node_appointment_api "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/AppointmentApi.ts"
click node_notification_api "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/NotificationApi.ts"
click node_auth_service "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/AuthService.ts"
click node_doctor_service "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/DoctorService.ts"
click node_schedule_service "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/ScheduleService.ts"
click node_appointment_service "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/AppointmentService.ts"
click node_notification_service "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/NotificationService.ts"
click node_context "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/context.ts"
click node_repositories "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/repositories/repositories.ts"
click node_mock_data "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/data/mockData.ts"
click node_entities "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/models/entities.ts"
click node_response "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/common/ApiResponse.ts"
click node_errors "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/common/ErrorCode.ts"
click node_common "https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/utils/common.ts"

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_auth_api,node_doctor_api,node_schedule_api,node_appointment_api,node_notification_api,node_context toneBlue
class node_auth_service,node_doctor_service,node_schedule_service,node_appointment_service,node_notification_service toneAmber
class node_repositories,node_mock_data toneMint
class node_entities,node_response,node_errors,node_common toneRose
class node_patient toneIndigo
```

## Components

### Function API

- [Auth functions](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/AuthApi.ts): `src/api/AuthApi.ts`
- [Doctor functions](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/DoctorApi.ts): `src/api/DoctorApi.ts`
- [Schedule functions](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/ScheduleApi.ts): `src/api/ScheduleApi.ts`
- [Appointment functions](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/AppointmentApi.ts): `src/api/AppointmentApi.ts`
- [Notification functions](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/NotificationApi.ts): `src/api/NotificationApi.ts`
- [Service context](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/context.ts): `src/api/context.ts`

### Domain Services

- [Authentication](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/AuthService.ts): `src/services/AuthService.ts`
- [Doctor catalog](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/DoctorService.ts): `src/services/DoctorService.ts`
- [Schedule availability](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/ScheduleService.ts): `src/services/ScheduleService.ts`
- [Appointment management](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/AppointmentService.ts): `src/services/AppointmentService.ts`
- [Notification management](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/services/NotificationService.ts): `src/services/NotificationService.ts`

### Mock Data

- [Repositories](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/repositories/repositories.ts): `src/repositories/repositories.ts`
- [In-memory records](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/data/mockData.ts): `src/data/mockData.ts`

### Shared Types

- [Domain entities](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/models/entities.ts): `src/models/entities.ts`
- [API response types](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/common/ApiResponse.ts): `src/api/common/ApiResponse.ts`
- [Error codes](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/api/common/ErrorCode.ts): `src/api/common/ErrorCode.ts`
- [Date and ID helpers](https://github.com/trankinhnguyen-ctrl/medicare/blob/main/src/utils/common.ts): `src/utils/common.ts`

### Other components

- **Patient**

## Connections

- Patient → Auth functions: uses (evidence: `README.md`)
- Patient → Doctor functions: browses
- Patient → Schedule functions: checks availability
- Patient → Appointment functions: books and manages
- Patient → Notification functions: views updates
- Auth functions → Authentication: delegates (evidence: `src/api/AuthApi.ts`)
- Doctor functions → Doctor catalog: delegates (evidence: `src/api/DoctorApi.ts`)
- Schedule functions → Schedule availability: delegates (evidence: `src/api/ScheduleApi.ts`)
- Appointment functions → Appointment management: delegates (evidence: `src/api/AppointmentApi.ts`)
- Notification functions → Notification management: delegates (evidence: `src/api/NotificationApi.ts`)
- Service context → Authentication: creates (evidence: `src/api/context.ts`)
- Service context → Doctor catalog: creates (evidence: `src/api/context.ts`)
- Service context → Schedule availability: creates (evidence: `src/api/context.ts`)
- Service context → Appointment management: creates (evidence: `src/api/context.ts`)
- Service context → Notification management: creates (evidence: `src/api/context.ts`)
- Authentication → Repositories: reads and writes (evidence: `src/services/AuthService.ts`)
- Appointment management → Authentication: checks session (evidence: `src/services/AppointmentService.ts`)
- Appointment management → Repositories: reads and writes (evidence: `src/services/AppointmentService.ts`)
- Schedule availability → Repositories: reads schedules (evidence: `src/services/ScheduleService.ts`)
- Doctor catalog → Repositories: reads catalog (evidence: `src/services/DoctorService.ts`)
- Notification management → Repositories: reads and writes (evidence: `src/services/NotificationService.ts`)
- Appointment management → Date and ID helpers: uses date helpers (evidence: `src/services/AppointmentService.ts`)
- Authentication → Date and ID helpers: uses helpers (evidence: `src/services/AuthService.ts`)
- Schedule availability → Date and ID helpers: uses date helpers (evidence: `src/services/ScheduleService.ts`)
- Repositories → In-memory records: accesses arrays (evidence: `src/repositories/repositories.ts`)
- In-memory records → Domain entities: types records (evidence: `src/data/mockData.ts`)
- Auth functions → API response types: returns (evidence: `src/api/AuthApi.ts`)
- Appointment management → API response types: returns (evidence: `src/services/AppointmentService.ts`)
- Appointment management → Error codes: uses codes (evidence: `src/services/AppointmentService.ts`)
- Date and ID helpers → API response types: builds responses (evidence: `src/utils/common.ts`)
