# kerolos-nashat/dentai-api architecture

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

- Interactive diagram: https://gitdiagram.com/kerolos-nashat/dentai-api
- Repository: https://github.com/kerolos-nashat/dentai-api

## Overview

This is a NestJS clinic-management API, despite the generic Nest starter README. Its broad workflow spans staff and patient authentication, scheduling and patient records, then operational follow-up such as billing, notifications, and analytics. The tree also shows patient self-service, a WhatsApp bot, AI assistance, inventory, and a waitlist. The graph preserves these product branches, but most unsampled modules are shown only as registered capabilities; their internal calls are not inferred. Evidence is limited to the supplied source excerpts and SOURCE INDEX references.

Main entry points: [`src/app.module.ts`](https://github.com/kerolos-nashat/dentai-api/blob/main/src/app.module.ts) (Application modules), [`src/modules/llm/llm.service.ts`](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/llm/llm.service.ts) (LLM provider client), [`src/modules/patient-auth/patient-auth.service.ts`](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/patient-auth/patient-auth.service.ts) (Patient OTP login), [`src/main.ts`](https://github.com/kerolos-nashat/dentai-api/blob/main/src/main.ts) (Nest bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_main["Nest bootstrap<br/>[main.ts]"]
  node_app["Application modules<br/>[app.module.ts]"]
end

subgraph group_identity["Identity and access"]
  node_staff_auth["Staff authentication"]
  node_patient_auth["Patient OTP login"]
  node_users["Staff users<br/>[user.entity.ts]"]
end

subgraph group_care["Clinical operations"]
  node_patients["Patient records"]
  node_patient_entity["Patient data<br/>[patient.entity.ts]"]
  node_appointments["Appointment scheduling"]
  node_appointment_entity["Appointment data"]
  node_availability["Doctor availability"]
  node_patient_portal["Patient portal"]
  node_procedures["Procedures and durations"]
  node_waitlist["Waitlist offers"]
end

subgraph group_operations["Clinic operations"]
  node_billing["Invoices and payments"]
  node_inventory["Clinical inventory"]
  node_notifications["Reminders and messaging"]
  node_push["Push notifications"]
end

subgraph group_intelligence["AI and insight"]
  node_analytics["Analytics and forecasts"]
  node_agent["AI agent"]
  node_patient_bot["Patient messaging bot"]
  node_knowledge["Knowledge retrieval"]
  node_llm["LLM provider client<br/>[llm.service.ts]"]
  node_trace["LLM trace records"]
end

node_client(("API clients"))
node_gemini["Gemini API"]
node_iti["ITI gateway"]

node_client -->|"sends requests"| node_main
node_main -->|"starts"| node_app
node_app -->|"registers"| node_staff_auth
node_app -->|"registers"| node_patient_auth
node_app -->|"registers"| node_patients
node_app -->|"registers"| node_appointments
node_app -->|"registers"| node_availability
node_app -->|"registers"| node_patient_portal
node_app -->|"registers"| node_procedures
node_app -->|"registers"| node_waitlist
node_app -->|"registers"| node_billing
node_app -->|"registers"| node_inventory
node_app -->|"registers"| node_notifications
node_app -->|"registers"| node_push
node_app -->|"registers"| node_analytics
node_app -->|"registers"| node_agent
node_app -->|"registers"| node_patient_bot
node_app -->|"registers"| node_knowledge
node_app -->|"registers"| node_llm
node_patient_auth -->|"queries patients"| node_patients
node_patient_auth -->|"sends codes"| node_notifications
node_patient_portal -.->|"serves portal"| node_client
node_appointments -.->|"serves scheduling"| node_client
node_llm -->|"records calls"| node_trace
node_llm -->|"calls provider"| node_gemini
node_llm -->|"calls gateway"| node_iti

click node_main "https://github.com/kerolos-nashat/dentai-api/blob/main/src/main.ts"
click node_app "https://github.com/kerolos-nashat/dentai-api/blob/main/src/app.module.ts"
click node_staff_auth "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/auth"
click node_patient_auth "https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/patient-auth/patient-auth.service.ts"
click node_users "https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/users/entities/user.entity.ts"
click node_patients "https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/patients/patients.service.ts"
click node_patient_entity "https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/patients/entities/patient.entity.ts"
click node_appointments "https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/appointments/appointments.controller.ts"
click node_appointment_entity "https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/appointments/entities/appointment.entity.ts"
click node_availability "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/availability"
click node_patient_portal "https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/patient-portal/patient-portal.controller.ts"
click node_procedures "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/procedures"
click node_waitlist "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/waitlist"
click node_billing "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/billing"
click node_inventory "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/inventory"
click node_notifications "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/notifications"
click node_push "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/push"
click node_analytics "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/analytics"
click node_agent "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/agent"
click node_patient_bot "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/patient-bot"
click node_knowledge "https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/knowledge-base"
click node_llm "https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/llm/llm.service.ts"
click node_trace "https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/llm/entities/llm-trace.entity.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_main,node_app,node_client toneBlue
class node_staff_auth,node_patient_auth,node_users toneAmber
class node_patients,node_patient_entity,node_appointments,node_appointment_entity,node_availability,node_patient_portal,node_procedures,node_waitlist,node_gemini toneMint
class node_billing,node_inventory,node_notifications,node_push toneRose
class node_analytics,node_agent,node_patient_bot,node_knowledge,node_llm,node_trace,node_iti toneIndigo
```

## Components

### Application entry

- [Nest bootstrap](https://github.com/kerolos-nashat/dentai-api/blob/main/src/main.ts): `src/main.ts`
- [Application modules](https://github.com/kerolos-nashat/dentai-api/blob/main/src/app.module.ts): `src/app.module.ts`

### Identity and access

- [Staff authentication](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/auth): `src/modules/auth`
- [Patient OTP login](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/patient-auth/patient-auth.service.ts): `src/modules/patient-auth/patient-auth.service.ts`
- [Staff users](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/users/entities/user.entity.ts): `src/modules/users/entities/user.entity.ts`

### Clinical operations

- [Patient records](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/patients/patients.service.ts): `src/modules/patients/patients.service.ts`
- [Patient data](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/patients/entities/patient.entity.ts): `src/modules/patients/entities/patient.entity.ts`
- [Appointment scheduling](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/appointments/appointments.controller.ts): `src/modules/appointments/appointments.controller.ts`
- [Appointment data](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/appointments/entities/appointment.entity.ts): `src/modules/appointments/entities/appointment.entity.ts`
- [Doctor availability](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/availability): `src/modules/availability`
- [Patient portal](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/patient-portal/patient-portal.controller.ts): `src/modules/patient-portal/patient-portal.controller.ts`
- [Procedures and durations](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/procedures): `src/modules/procedures`
- [Waitlist offers](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/waitlist): `src/modules/waitlist`

### Clinic operations

- [Invoices and payments](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/billing): `src/modules/billing`
- [Clinical inventory](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/inventory): `src/modules/inventory`
- [Reminders and messaging](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/notifications): `src/modules/notifications`
- [Push notifications](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/push): `src/modules/push`

### AI and insight

- [Analytics and forecasts](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/analytics): `src/modules/analytics`
- [AI agent](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/agent): `src/modules/agent`
- [Patient messaging bot](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/patient-bot): `src/modules/patient-bot`
- [Knowledge retrieval](https://github.com/kerolos-nashat/dentai-api/tree/main/src/modules/knowledge-base): `src/modules/knowledge-base`
- [LLM provider client](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/llm/llm.service.ts): `src/modules/llm/llm.service.ts`
- [LLM trace records](https://github.com/kerolos-nashat/dentai-api/blob/main/src/modules/llm/entities/llm-trace.entity.ts): `src/modules/llm/entities/llm-trace.entity.ts`

### Other components

- **API clients**
- **Gemini API**
- **ITI gateway**

## Connections

- API clients → Nest bootstrap: sends requests (evidence: `src/main.ts`)
- Nest bootstrap → Application modules: starts (evidence: `src/main.ts`)
- Application modules → Staff authentication: registers (evidence: `src/app.module.ts`)
- Application modules → Patient OTP login: registers (evidence: `src/app.module.ts`)
- Application modules → Patient records: registers (evidence: `src/app.module.ts`)
- Application modules → Appointment scheduling: registers (evidence: `src/app.module.ts`)
- Application modules → Doctor availability: registers (evidence: `src/app.module.ts`)
- Application modules → Patient portal: registers (evidence: `src/app.module.ts`)
- Application modules → Procedures and durations: registers (evidence: `src/app.module.ts`)
- Application modules → Waitlist offers: registers (evidence: `src/app.module.ts`)
- Application modules → Invoices and payments: registers (evidence: `src/app.module.ts`)
- Application modules → Clinical inventory: registers (evidence: `src/app.module.ts`)
- Application modules → Reminders and messaging: registers (evidence: `src/app.module.ts`)
- Application modules → Push notifications: registers (evidence: `src/app.module.ts`)
- Application modules → Analytics and forecasts: registers (evidence: `src/app.module.ts`)
- Application modules → AI agent: registers (evidence: `src/app.module.ts`)
- Application modules → Patient messaging bot: registers (evidence: `src/app.module.ts`)
- Application modules → Knowledge retrieval: registers (evidence: `src/app.module.ts`)
- Application modules → LLM provider client: registers (evidence: `src/app.module.ts`)
- Patient OTP login → Patient records: queries patients (evidence: `src/modules/patient-auth/patient-auth.service.ts`)
- Patient OTP login → Reminders and messaging: sends codes (evidence: `src/modules/patient-auth/patient-auth.service.ts`)
- Patient portal → API clients: serves portal
- Appointment scheduling → API clients: serves scheduling
- LLM provider client → LLM trace records: records calls (evidence: `src/modules/llm/llm.service.ts`)
- LLM provider client → Gemini API: calls provider (evidence: `src/modules/llm/llm.service.ts`)
- LLM provider client → ITI gateway: calls gateway (evidence: `src/modules/llm/llm.service.ts`)
