# r-rahman112/amar-dactar architecture

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

- Interactive diagram: https://gitdiagram.com/r-rahman112/amar-dactar
- Repository: https://github.com/r-rahman112/amar-dactar

## Overview

Amar Daktar is a bilingual medical consultation and health-management platform. Patients authenticate, use AI symptom/report tools, find doctors, book or join paid consultations, and manage records in a consent-controlled vault; doctors and administrators have separate management workflows. The map follows documented UI and server routing, plus sampled API, persistence, moderation, and authentication relationships. Several advertised capabilities are represented from the README; unsampled internals and their wiring are not inferred.

Main entry points: [`src/App.tsx`](https://github.com/r-rahman112/amar-dactar/blob/main/src/App.tsx) (Application shell), [`server.ts`](https://github.com/r-rahman112/amar-dactar/blob/main/server.ts) (HTTP server), [`src/backend/config/db.ts`](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/config/db.ts) (PostgreSQL access), [`src/backend/services/ModerationService.ts`](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/services/ModerationService.ts) (Abuse moderation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Patient experience"]
  node_app["Application shell<br/>[App.tsx]"]
  node_consult["Consultation workspace"]
  node_symptom["Symptom and report tools<br/>[SymptomModal.tsx]"]
  node_vaultui["Health vault<br/>[HealthVault.tsx]"]
  node_dashboards["Role dashboards"]
  node_doctorui["Doctor tools"]
  node_adminui["Admin tools<br/>[AdminDashboard.tsx]"]
end

subgraph group_identity["Identity and language"]
  node_authui["Authentication interface<br/>[AuthUI.tsx]"]
  node_authctx["Session context<br/>[AuthContext.tsx]"]
  node_language["Language context"]
  node_firebase["Firebase authentication<br/>[firebase.ts]"]
end

subgraph group_api["API and consultation"]
  node_client["API client<br/>[apiClient.ts]"]
  node_server["HTTP server<br/>[server.ts]"]
  node_userapi["User and role APIs<br/>[user.routes.ts]"]
  node_apptapi["Appointments and doctors"]
  node_payapi["Payment APIs<br/>[payment.routes.ts]"]
  node_vaultapi["Vault APIs<br/>[vault.routes.ts]"]
  node_aiapi["AI and upload APIs<br/>[ai.routes.ts]"]
  node_live["Live consultation sockets<br/>[socket.ts]"]
end

subgraph group_safety["AI and safety"]
  node_chat["AI chat controller<br/>[ChatController.ts]"]
  node_moderation["Abuse moderation"]
  node_providers["AI provider factory<br/>[AIFactory.ts]"]
end

subgraph group_persistence["Data and notifications"]
  node_db[("PostgreSQL access<br/>[db.ts]")]
  node_notifications["Notifications<br/>[notifications.ts]"]
end

node_patient(("Patient"))
node_doctor(("Doctor"))
node_admin(("Administrator"))
node_ai_service["AI services"]
node_postgres[("PostgreSQL")]

node_patient -->|"uses"| node_app
node_doctor -->|"manages practice"| node_doctorui
node_admin -->|"manages platform"| node_adminui
node_app -->|"opens"| node_consult
node_app -->|"opens"| node_symptom
node_app -->|"opens"| node_vaultui
node_app -->|"routes views"| node_dashboards
node_app -->|"routes views"| node_doctorui
node_app -->|"routes views"| node_adminui
node_authui -->|"uses"| node_authctx
node_authctx -->|"requests sessions"| node_client
node_authctx -->|"observes sign-in"| node_firebase
node_app -->|"provides locale"| node_language
node_consult -->|"calls APIs"| node_client
node_client -.->|"sends requests"| node_server
node_server -->|"mounts routes"| node_userapi
node_server -->|"mounts routes"| node_apptapi
node_server -->|"mounts routes"| node_payapi
node_server -->|"mounts routes"| node_vaultapi
node_server -->|"mounts routes"| node_aiapi
node_server -->|"starts sockets"| node_live
node_userapi -->|"queries"| node_db
node_apptapi -->|"queries"| node_db
node_payapi -->|"queries"| node_db
node_vaultapi -->|"queries"| node_db
node_aiapi -->|"dispatches"| node_chat
node_chat -->|"checks content"| node_moderation
node_moderation -->|"requests AI"| node_providers
node_providers -.->|"selects provider"| node_ai_service
node_moderation -->|"records violations"| node_db
node_db -->|"queries"| node_postgres
node_live -->|"moderates sessions"| node_moderation
node_live -->|"reads and writes"| node_db
node_userapi -->|"notifies admins"| node_notifications
node_notifications -->|"stores notices"| node_db

click node_app "https://github.com/r-rahman112/amar-dactar/blob/main/src/App.tsx"
click node_consult "https://github.com/r-rahman112/amar-dactar/blob/main/src/components/ConsultationWorkspace.tsx"
click node_symptom "https://github.com/r-rahman112/amar-dactar/blob/main/src/components/SymptomModal.tsx"
click node_vaultui "https://github.com/r-rahman112/amar-dactar/blob/main/src/components/HealthVault.tsx"
click node_dashboards "https://github.com/r-rahman112/amar-dactar/blob/main/src/components/PatientDashboard.tsx"
click node_doctorui "https://github.com/r-rahman112/amar-dactar/blob/main/src/components/DoctorDashboard.tsx"
click node_adminui "https://github.com/r-rahman112/amar-dactar/blob/main/src/components/AdminDashboard.tsx"
click node_authui "https://github.com/r-rahman112/amar-dactar/blob/main/src/components/AuthUI.tsx"
click node_authctx "https://github.com/r-rahman112/amar-dactar/blob/main/src/contexts/AuthContext.tsx"
click node_language "https://github.com/r-rahman112/amar-dactar/blob/main/src/contexts/LanguageContext.tsx"
click node_firebase "https://github.com/r-rahman112/amar-dactar/blob/main/src/lib/firebase.ts"
click node_client "https://github.com/r-rahman112/amar-dactar/blob/main/src/apiClient.ts"
click node_server "https://github.com/r-rahman112/amar-dactar/blob/main/server.ts"
click node_userapi "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/routes/user.routes.ts"
click node_apptapi "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/routes/appointment.routes.ts"
click node_payapi "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/routes/payment.routes.ts"
click node_vaultapi "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/routes/vault.routes.ts"
click node_aiapi "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/routes/ai.routes.ts"
click node_live "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/socket.ts"
click node_chat "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/controllers/ChatController.ts"
click node_moderation "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/services/ModerationService.ts"
click node_providers "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/services/ai/AIFactory.ts"
click node_db "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/config/db.ts"
click node_notifications "https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/utils/notifications.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_app,node_consult,node_symptom,node_vaultui,node_dashboards,node_doctorui,node_adminui toneBlue
class node_authui,node_authctx,node_language,node_firebase,node_postgres toneAmber
class node_client,node_server,node_userapi,node_apptapi,node_payapi,node_vaultapi,node_aiapi,node_live toneMint
class node_chat,node_moderation,node_providers toneRose
class node_db,node_notifications,node_patient,node_doctor,node_admin,node_ai_service toneIndigo
```

## Components

### Patient experience

- [Application shell](https://github.com/r-rahman112/amar-dactar/blob/main/src/App.tsx): `src/App.tsx`
- [Consultation workspace](https://github.com/r-rahman112/amar-dactar/blob/main/src/components/ConsultationWorkspace.tsx): `src/components/ConsultationWorkspace.tsx`
- [Symptom and report tools](https://github.com/r-rahman112/amar-dactar/blob/main/src/components/SymptomModal.tsx): `src/components/SymptomModal.tsx`
- [Health vault](https://github.com/r-rahman112/amar-dactar/blob/main/src/components/HealthVault.tsx): `src/components/HealthVault.tsx`
- [Role dashboards](https://github.com/r-rahman112/amar-dactar/blob/main/src/components/PatientDashboard.tsx): `src/components/PatientDashboard.tsx`
- [Doctor tools](https://github.com/r-rahman112/amar-dactar/blob/main/src/components/DoctorDashboard.tsx): `src/components/DoctorDashboard.tsx`
- [Admin tools](https://github.com/r-rahman112/amar-dactar/blob/main/src/components/AdminDashboard.tsx): `src/components/AdminDashboard.tsx`

### Identity and language

- [Authentication interface](https://github.com/r-rahman112/amar-dactar/blob/main/src/components/AuthUI.tsx): `src/components/AuthUI.tsx`
- [Session context](https://github.com/r-rahman112/amar-dactar/blob/main/src/contexts/AuthContext.tsx): `src/contexts/AuthContext.tsx`
- [Language context](https://github.com/r-rahman112/amar-dactar/blob/main/src/contexts/LanguageContext.tsx): `src/contexts/LanguageContext.tsx`
- [Firebase authentication](https://github.com/r-rahman112/amar-dactar/blob/main/src/lib/firebase.ts): `src/lib/firebase.ts`

### API and consultation

- [API client](https://github.com/r-rahman112/amar-dactar/blob/main/src/apiClient.ts): `src/apiClient.ts`
- [HTTP server](https://github.com/r-rahman112/amar-dactar/blob/main/server.ts): `server.ts`
- [User and role APIs](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/routes/user.routes.ts): `src/backend/routes/user.routes.ts`
- [Appointments and doctors](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/routes/appointment.routes.ts): `src/backend/routes/appointment.routes.ts`
- [Payment APIs](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/routes/payment.routes.ts): `src/backend/routes/payment.routes.ts`
- [Vault APIs](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/routes/vault.routes.ts): `src/backend/routes/vault.routes.ts`
- [AI and upload APIs](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/routes/ai.routes.ts): `src/backend/routes/ai.routes.ts`
- [Live consultation sockets](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/socket.ts): `src/backend/socket.ts`

### AI and safety

- [AI chat controller](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/controllers/ChatController.ts): `src/backend/controllers/ChatController.ts`
- [Abuse moderation](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/services/ModerationService.ts): `src/backend/services/ModerationService.ts`
- [AI provider factory](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/services/ai/AIFactory.ts): `src/backend/services/ai/AIFactory.ts`

### Data and notifications

- [PostgreSQL access](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/config/db.ts): `src/backend/config/db.ts`
- [Notifications](https://github.com/r-rahman112/amar-dactar/blob/main/src/backend/utils/notifications.ts): `src/backend/utils/notifications.ts`

### Other components

- **Patient**
- **Doctor**
- **Administrator**
- **AI services**
- **PostgreSQL**

## Connections

- Patient → Application shell: uses
- Doctor → Doctor tools: manages practice
- Administrator → Admin tools: manages platform
- Application shell → Consultation workspace: opens (evidence: `src/App.tsx`)
- Application shell → Symptom and report tools: opens (evidence: `src/App.tsx`)
- Application shell → Health vault: opens (evidence: `src/App.tsx`)
- Application shell → Role dashboards: routes views (evidence: `src/App.tsx`)
- Application shell → Doctor tools: routes views (evidence: `src/App.tsx`)
- Application shell → Admin tools: routes views (evidence: `src/App.tsx`)
- Authentication interface → Session context: uses (evidence: `src/components/AuthUI.tsx`)
- Session context → API client: requests sessions (evidence: `src/contexts/AuthContext.tsx`)
- Session context → Firebase authentication: observes sign-in (evidence: `src/contexts/AuthContext.tsx`)
- Application shell → Language context: provides locale (evidence: `src/main.tsx`)
- Consultation workspace → API client: calls APIs (evidence: `src/components/ConsultationWorkspace.tsx`)
- API client → HTTP server: sends requests
- HTTP server → User and role APIs: mounts routes (evidence: `server.ts`)
- HTTP server → Appointments and doctors: mounts routes (evidence: `server.ts`)
- HTTP server → Payment APIs: mounts routes (evidence: `server.ts`)
- HTTP server → Vault APIs: mounts routes (evidence: `server.ts`)
- HTTP server → AI and upload APIs: mounts routes (evidence: `server.ts`)
- HTTP server → Live consultation sockets: starts sockets (evidence: `server.ts`)
- User and role APIs → PostgreSQL access: queries (evidence: `src/backend/routes/user.routes.ts`)
- Appointments and doctors → PostgreSQL access: queries (evidence: `src/backend/routes/appointment.routes.ts`)
- Payment APIs → PostgreSQL access: queries (evidence: `src/backend/routes/payment.routes.ts`)
- Vault APIs → PostgreSQL access: queries (evidence: `src/backend/routes/vault.routes.ts`)
- AI and upload APIs → AI chat controller: dispatches (evidence: `src/backend/routes/ai.routes.ts`)
- AI chat controller → Abuse moderation: checks content (evidence: `src/backend/controllers/ChatController.ts`)
- Abuse moderation → AI provider factory: requests AI (evidence: `src/backend/services/ModerationService.ts`)
- AI provider factory → AI services: selects provider
- Abuse moderation → PostgreSQL access: records violations (evidence: `src/backend/services/ModerationService.ts`)
- PostgreSQL access → PostgreSQL: queries (evidence: `src/backend/config/db.ts`)
- Live consultation sockets → Abuse moderation: moderates sessions (evidence: `src/backend/socket.ts`)
- Live consultation sockets → PostgreSQL access: reads and writes (evidence: `src/backend/socket.ts`)
- User and role APIs → Notifications: notifies admins (evidence: `src/backend/routes/user.routes.ts`)
- Notifications → PostgreSQL access: stores notices (evidence: `src/backend/utils/notifications.ts`)
