# suryanshswarn09/nirmaya architecture

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

- Interactive diagram: https://gitdiagram.com/suryanshswarn09/nirmaya
- Repository: https://github.com/suryanshswarn09/nirmaya

## Overview

NIRMAYA is a health-record interoperability platform spanning a patient vault, provider EMR, diagnostic gateway, clinical scheduling, and FHIR/ABDM-aligned exchange. The workflow runs from role-based sign-in and profile access through appointment booking and clinical or lab record creation, with records persisted in the relational database and represented in FHIR formats. Edges are limited to relationships established by the README or shown in the excerpts and SOURCE INDEX; unsampled feature internals and external integrations are therefore shown only where documented.

Main entry points: [`backend/app/api/v1/router.py`](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/router.py) (API routing), [`backend/app/services`](https://github.com/suryanshswarn09/nirmaya/tree/main/backend/app/services) (Domain services), [`backend/app/fhir/transformers.py`](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/fhir/transformers.py) (FHIR schemas and transforms), [`backend/app/main.py`](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_web["Role portals"]
  node_auth_ui["Sign-in and registration<br/>[page.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and access"]
  node_auth["Authentication endpoints<br/>[auth.py]"]
  node_access["Token and role access<br/>[dependencies.py]"]
  node_router["API routing<br/>[router.py]"]
  node_app["FastAPI application<br/>[main.py]"]
end

subgraph group_clinical["Clinical workflows"]
  node_patient["Patient vault<br/>[patients.py]"]
  node_doctors["Doctor discovery<br/>[doctors.py]"]
  node_appointments["Appointment booking<br/>[appointments.py]"]
  node_slots["Slot generation and holds<br/>[slot_engine.py]"]
  node_conditions["Clinical conditions<br/>[conditions.py]"]
  node_observations["Vitals and observations<br/>[observations.py]"]
  node_notes["SOAP notes<br/>[soap_notes.py]"]
  node_diagnostics["Lab orders and reports<br/>[diagnostics.py]"]
  node_services["Domain services"]
end

subgraph group_interop["Interoperability"]
  node_fhir["FHIR schemas and transforms<br/>[transformers.py]"]
  node_abdm["ABDM exchange"]
end

subgraph group_persistence["Persistence"]
  node_models["Clinical data models"]
  node_database[("Relational database<br/>[session.py]")]
  node_supabase[("Supabase auth and storage")]
end

node_users(("Patients, doctors, labs"))

node_users -->|"use portals"| node_web
node_web -->|"sign in"| node_auth_ui
node_auth_ui -.->|"submit credentials"| node_api_client
node_api_client -.->|"call API"| node_app
node_app -->|"mount routes"| node_router
node_router -->|"route auth"| node_auth
node_router -->|"route patients"| node_patient
node_router -->|"route doctors"| node_doctors
node_router -->|"route appointments"| node_appointments
node_router -->|"route conditions"| node_conditions
node_router -->|"route observations"| node_observations
node_router -->|"route notes"| node_notes
node_router -->|"route diagnostics"| node_diagnostics
node_auth -->|"use identity checks"| node_access
node_users -->|"authenticate"| node_auth
node_doctors -->|"generate availability"| node_slots
node_appointments -->|"use domain services"| node_services
node_appointments -->|"hold slots"| node_slots
node_conditions -->|"use condition service"| node_services
node_diagnostics -->|"use diagnostic service"| node_services
node_conditions -->|"FHIR exchange"| node_fhir
node_diagnostics -->|"FHIR exchange"| node_fhir
node_models -->|"transform records"| node_fhir
node_services -.->|"operate on entities"| node_models
node_slots -->|"read and write slots"| node_database
node_services -.->|"persist records"| node_database
node_models -->|"map entities"| node_database
node_fhir -.->|"standards exchange"| node_abdm
node_app -.->|"integrate auth and storage"| node_supabase

click node_web "https://github.com/suryanshswarn09/nirmaya/tree/main/frontend/src/app"
click node_auth_ui "https://github.com/suryanshswarn09/nirmaya/blob/main/frontend/src/app/login/page.tsx"
click node_api_client "https://github.com/suryanshswarn09/nirmaya/blob/main/frontend/src/lib/api.ts"
click node_auth "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/auth.py"
click node_access "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/core/dependencies.py"
click node_router "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/router.py"
click node_app "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/main.py"
click node_patient "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/patients.py"
click node_doctors "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/doctors.py"
click node_appointments "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/appointments.py"
click node_slots "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/services/slot_engine.py"
click node_conditions "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/conditions.py"
click node_observations "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/observations.py"
click node_notes "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/soap_notes.py"
click node_diagnostics "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/diagnostics.py"
click node_fhir "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/fhir/transformers.py"
click node_abdm "https://github.com/suryanshswarn09/nirmaya/tree/main/backend/app/abdm"
click node_services "https://github.com/suryanshswarn09/nirmaya/tree/main/backend/app/services"
click node_models "https://github.com/suryanshswarn09/nirmaya/tree/main/backend/app/models"
click node_database "https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/db/session.py"

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_auth_ui,node_api_client toneBlue
class node_auth,node_access,node_router,node_app toneAmber
class node_patient,node_doctors,node_appointments,node_slots,node_conditions,node_observations,node_notes,node_diagnostics,node_services toneMint
class node_fhir,node_abdm toneRose
class node_models,node_database,node_supabase,node_users toneIndigo
```

## Components

### Web experience

- [Role portals](https://github.com/suryanshswarn09/nirmaya/tree/main/frontend/src/app): `frontend/src/app`
- [Sign-in and registration](https://github.com/suryanshswarn09/nirmaya/blob/main/frontend/src/app/login/page.tsx): `frontend/src/app/login/page.tsx`
- [API client](https://github.com/suryanshswarn09/nirmaya/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### API and access

- [Authentication endpoints](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/auth.py): `backend/app/api/v1/endpoints/auth.py`
- [Token and role access](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/core/dependencies.py): `backend/app/core/dependencies.py`
- [API routing](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`
- [FastAPI application](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/main.py): `backend/app/main.py`

### Clinical workflows

- [Patient vault](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/patients.py): `backend/app/api/v1/endpoints/patients.py`
- [Doctor discovery](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/doctors.py): `backend/app/api/v1/endpoints/doctors.py`
- [Appointment booking](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/appointments.py): `backend/app/api/v1/endpoints/appointments.py`
- [Slot generation and holds](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/services/slot_engine.py): `backend/app/services/slot_engine.py`
- [Clinical conditions](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/conditions.py): `backend/app/api/v1/endpoints/conditions.py`
- [Vitals and observations](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/observations.py): `backend/app/api/v1/endpoints/observations.py`
- [SOAP notes](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/soap_notes.py): `backend/app/api/v1/endpoints/soap_notes.py`
- [Lab orders and reports](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/api/v1/endpoints/diagnostics.py): `backend/app/api/v1/endpoints/diagnostics.py`
- [Domain services](https://github.com/suryanshswarn09/nirmaya/tree/main/backend/app/services): `backend/app/services`

### Interoperability

- [FHIR schemas and transforms](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/fhir/transformers.py): `backend/app/fhir/transformers.py`
- [ABDM exchange](https://github.com/suryanshswarn09/nirmaya/tree/main/backend/app/abdm): `backend/app/abdm`

### Persistence

- [Clinical data models](https://github.com/suryanshswarn09/nirmaya/tree/main/backend/app/models): `backend/app/models`
- [Relational database](https://github.com/suryanshswarn09/nirmaya/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- **Supabase auth and storage**

### Other components

- **Patients, doctors, labs**

## Connections

- Patients, doctors, labs → Role portals: use portals (evidence: `README.md`)
- Role portals → Sign-in and registration: sign in (evidence: `README.md`)
- Sign-in and registration → API client: submit credentials
- API client → FastAPI application: call API
- FastAPI application → API routing: mount routes (evidence: `backend/app/main.py`)
- API routing → Authentication endpoints: route auth (evidence: `backend/app/api/v1/router.py`)
- API routing → Patient vault: route patients (evidence: `backend/app/api/v1/router.py`)
- API routing → Doctor discovery: route doctors (evidence: `backend/app/api/v1/router.py`)
- API routing → Appointment booking: route appointments (evidence: `backend/app/api/v1/router.py`)
- API routing → Clinical conditions: route conditions (evidence: `backend/app/api/v1/router.py`)
- API routing → Vitals and observations: route observations (evidence: `backend/app/api/v1/router.py`)
- API routing → SOAP notes: route notes (evidence: `backend/app/api/v1/router.py`)
- API routing → Lab orders and reports: route diagnostics (evidence: `backend/app/api/v1/router.py`)
- Authentication endpoints → Token and role access: use identity checks (evidence: `backend/app/api/v1/endpoints/auth.py`)
- Patients, doctors, labs → Authentication endpoints: authenticate (evidence: `README.md`)
- Doctor discovery → Slot generation and holds: generate availability (evidence: `backend/app/api/v1/endpoints/doctors.py`)
- Appointment booking → Domain services: use domain services (evidence: `backend/app/api/v1/endpoints/appointments.py`)
- Appointment booking → Slot generation and holds: hold slots (evidence: `backend/app/api/v1/endpoints/appointments.py`)
- Clinical conditions → Domain services: use condition service (evidence: `backend/app/api/v1/endpoints/conditions.py`)
- Lab orders and reports → Domain services: use diagnostic service (evidence: `backend/app/api/v1/endpoints/diagnostics.py`)
- Clinical conditions → FHIR schemas and transforms: FHIR exchange (evidence: `backend/app/api/v1/endpoints/conditions.py`)
- Lab orders and reports → FHIR schemas and transforms: FHIR exchange (evidence: `backend/app/api/v1/endpoints/diagnostics.py`)
- Clinical data models → FHIR schemas and transforms: transform records (evidence: `backend/app/fhir/transformers.py`)
- Domain services → Clinical data models: operate on entities (evidence: `backend/app/services/slot_engine.py`)
- Slot generation and holds → Relational database: read and write slots (evidence: `backend/app/services/slot_engine.py`)
- Domain services → Relational database: persist records
- Clinical data models → Relational database: map entities (evidence: `backend/app/models/appointment.py`)
- FHIR schemas and transforms → ABDM exchange: standards exchange
- FastAPI application → Supabase auth and storage: integrate auth and storage (evidence: `README.md`)
