# adityakeerti/anand-kosh architecture

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

- Interactive diagram: https://gitdiagram.com/adityakeerti/anand-kosh
- Repository: https://github.com/adityakeerti/anand-kosh

## Overview

Anand Kosh is a role-aware clinical portal for patient records and medical documents. Staff create or update patient profiles, then upload and manage categorized records; observers have read-only access, while administrators also use reporting, scheduling, reminders, and migration tools. The Next.js portal exposes API route handlers backed by Prisma/PostgreSQL, with Google Drive used for document files and patient folders. The README identifies the main portal controller, but its UI-to-endpoint wiring is not shown in the sampled source, so those links are omitted.

Main entry points: [`src/lib/db.ts`](https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/db.ts) (Database client), [`src/app/api/patients`](https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/patients) (Patient records API), [`src/lib/auth.ts`](https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/auth.ts) (Auth and roles), [`src/app/api/documents`](https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/documents) (Document API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Portal"]
  node_ui["Portal interface<br/>[page.tsx]"]
end

subgraph group_identity["Identity"]
  node_auth_routes["Authentication API"]
  node_auth_lib["Auth and roles<br/>[auth.ts]"]
end

subgraph group_clinical["Clinical Records"]
  node_patient_api["Patient records API"]
  node_document_api["Document API"]
  node_disease_api["Disease catalogue API<br/>[route.ts]"]
  node_disease_lib["Disease tracking<br/>[diseases.ts]"]
end

subgraph group_operations["Clinic Operations"]
  node_calendar_api["Calendar API"]
  node_reminder_api["Reminder API"]
  node_checklist_api["Checklist API"]
  node_report_api["Reports API<br/>[route.ts]"]
  node_migration_api["Migration API<br/>[route.ts]"]
end

subgraph group_runtime["Runtime Services"]
  node_audit_lib["Audit logging<br/>[audit.ts]"]
  node_db_lib["Database client<br/>[db.ts]"]
  node_schema[("Clinical data schema<br/>[schema.prisma]")]
  node_drive_lib["Drive integration<br/>[drive.ts]"]
end

node_user(("Clinical user"))
node_postgres[("Neon PostgreSQL")]
node_drive[("Google Drive")]

node_user -->|"uses"| node_ui
node_auth_routes -->|"checks identity"| node_auth_lib
node_patient_api -->|"checks access"| node_auth_lib
node_document_api -->|"checks access"| node_auth_lib
node_migration_api -->|"checks access"| node_auth_lib
node_patient_api -->|"reads and writes"| node_db_lib
node_document_api -->|"reads and writes"| node_db_lib
node_calendar_api -->|"reads and writes"| node_db_lib
node_reminder_api -->|"reads and writes"| node_db_lib
node_checklist_api -->|"reads and writes"| node_db_lib
node_report_api -->|"queries metrics"| node_db_lib
node_migration_api -->|"migrates records"| node_db_lib
node_db_lib -->|"connects"| node_postgres
node_schema -->|"defines data"| node_postgres
node_patient_api -->|"provisions folders"| node_drive_lib
node_document_api -->|"stores files"| node_drive_lib
node_patient_api -->|"records diseases"| node_disease_lib
node_disease_api -->|"uses catalogue"| node_disease_lib
node_patient_api -->|"logs changes"| node_audit_lib
node_auth_routes -->|"logs sign-in"| node_audit_lib
node_drive_lib -.->|"stores files"| node_drive

click node_ui "https://github.com/adityakeerti/anand-kosh/blob/main/src/app/page.tsx"
click node_auth_routes "https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/auth"
click node_auth_lib "https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/auth.ts"
click node_patient_api "https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/patients"
click node_document_api "https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/documents"
click node_disease_api "https://github.com/adityakeerti/anand-kosh/blob/main/src/app/api/diseases/route.ts"
click node_disease_lib "https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/diseases.ts"
click node_calendar_api "https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/calendar"
click node_reminder_api "https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/reminders"
click node_checklist_api "https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/checklist"
click node_report_api "https://github.com/adityakeerti/anand-kosh/blob/main/src/app/api/reports/route.ts"
click node_migration_api "https://github.com/adityakeerti/anand-kosh/blob/main/src/app/api/migrate/route.ts"
click node_audit_lib "https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/audit.ts"
click node_db_lib "https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/db.ts"
click node_schema "https://github.com/adityakeerti/anand-kosh/blob/main/prisma/schema.prisma"
click node_drive_lib "https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/drive.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_ui,node_user toneBlue
class node_auth_routes,node_auth_lib,node_postgres,node_drive toneAmber
class node_patient_api,node_document_api,node_disease_api,node_disease_lib toneMint
class node_calendar_api,node_reminder_api,node_checklist_api,node_report_api,node_migration_api toneRose
class node_audit_lib,node_db_lib,node_schema,node_drive_lib toneIndigo
```

## Components

### Portal

- [Portal interface](https://github.com/adityakeerti/anand-kosh/blob/main/src/app/page.tsx): `src/app/page.tsx`

### Identity

- [Authentication API](https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/auth): `src/app/api/auth`
- [Auth and roles](https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/auth.ts): `src/lib/auth.ts`

### Clinical Records

- [Patient records API](https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/patients): `src/app/api/patients`
- [Document API](https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/documents): `src/app/api/documents`
- [Disease catalogue API](https://github.com/adityakeerti/anand-kosh/blob/main/src/app/api/diseases/route.ts): `src/app/api/diseases/route.ts`
- [Disease tracking](https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/diseases.ts): `src/lib/diseases.ts`

### Clinic Operations

- [Calendar API](https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/calendar): `src/app/api/calendar`
- [Reminder API](https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/reminders): `src/app/api/reminders`
- [Checklist API](https://github.com/adityakeerti/anand-kosh/tree/main/src/app/api/checklist): `src/app/api/checklist`
- [Reports API](https://github.com/adityakeerti/anand-kosh/blob/main/src/app/api/reports/route.ts): `src/app/api/reports/route.ts`
- [Migration API](https://github.com/adityakeerti/anand-kosh/blob/main/src/app/api/migrate/route.ts): `src/app/api/migrate/route.ts`

### Runtime Services

- [Audit logging](https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/audit.ts): `src/lib/audit.ts`
- [Database client](https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Clinical data schema](https://github.com/adityakeerti/anand-kosh/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- [Drive integration](https://github.com/adityakeerti/anand-kosh/blob/main/src/lib/drive.ts): `src/lib/drive.ts`

### Other components

- **Clinical user**
- **Neon PostgreSQL**
- **Google Drive**

## Connections

- Clinical user → Portal interface: uses
- Authentication API → Auth and roles: checks identity
- Patient records API → Auth and roles: checks access
- Document API → Auth and roles: checks access
- Migration API → Auth and roles: checks access
- Patient records API → Database client: reads and writes
- Document API → Database client: reads and writes
- Calendar API → Database client: reads and writes
- Reminder API → Database client: reads and writes
- Checklist API → Database client: reads and writes
- Reports API → Database client: queries metrics
- Migration API → Database client: migrates records
- Database client → Neon PostgreSQL: connects
- Clinical data schema → Neon PostgreSQL: defines data
- Patient records API → Drive integration: provisions folders
- Document API → Drive integration: stores files
- Patient records API → Disease tracking: records diseases
- Disease catalogue API → Disease tracking: uses catalogue
- Patient records API → Audit logging: logs changes
- Authentication API → Audit logging: logs sign-in
- Drive integration → Google Drive: stores files
