# shitij07/prescriptionsetu architecture

> Architecture diagram of the GitHub repository shitij07/prescriptionsetu, 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/shitij07/prescriptionsetu
- Repository: https://github.com/shitij07/prescriptionsetu

## Overview

PrescriptionSetu turns prescription text or images into medication candidates, requires caregiver verification before activating them, then schedules reminders and tracks patient replies for caregiver escalation. The dashboard supports prescription review and operational views; backend routes, parsing, verification, reminders, adherence, and retention form the main product layers. Several route and dashboard implementations were not sampled, so only documented or source-supported wiring is shown; translation is documented but has no dedicated directory in the supplied tree.

Main entry points: [`apps/api/src/app.ts`](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/app.ts) (Express API application), [`apps/api/src/db/connection.ts`](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/db/connection.ts) (PostgreSQL data store), [`apps/api/src/routes/prescriptions.ts`](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/routes/prescriptions.ts) (Prescription routes), [`apps/api/src/reminders/service.ts`](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/reminders/service.ts) (Reminder generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Caregiver dashboard"]
  node_dashboard_pages["Review and patient views"]
  node_upload_modal["Prescription upload"]
  node_api_client["Dashboard API client<br/>[api.ts]"]
end

subgraph group_clinical["Clinical processing"]
  node_app["Express API application<br/>[app.ts]"]
  node_prescription_routes["Prescription routes<br/>[prescriptions.ts]"]
  node_ocr{{"OCR provider seam<br/>[types.ts]"}}
  node_parser["Deterministic shorthand parser<br/>[parse.ts]"]
  node_repository["Prescription persistence<br/>[repository.ts]"]
  node_database[("PostgreSQL data store<br/>[connection.ts]")]
  node_verification["Verification gate<br/>[gate.ts]"]
  node_medication_routes["Medication routes<br/>[medications.ts]"]
end

subgraph group_delivery["Reminders and delivery"]
  node_reminder_service["Reminder generation<br/>[service.ts]"]
  node_scheduler["Reminder scheduler<br/>[scheduler.ts]"]
  node_queue["BullMQ job queue<br/>[queue.ts]"]
  node_worker["Reminder worker<br/>[worker.ts]"]
  node_translation{{"Translation providers"}}
  node_delivery_provider{{"WhatsApp / console provider<br/>[types.ts]"}}
end

subgraph group_adherence["Adherence tracking"]
  node_adherence_routes["Adherence routes<br/>[adherence.ts]"]
  node_adherence_service["Reply classification and stats<br/>[service.ts]"]
  node_classifier["Keyword classifier<br/>[classifier.ts]"]
end

subgraph group_governance["Privacy and audit"]
  node_retention["Erasure and image retention<br/>[service.ts]"]
  node_audit_routes["Audit routes<br/>[audit.ts]"]
  node_logger["Sanitized structured logging<br/>[logger.ts]"]
end

node_caregiver(("Caregiver / verifier"))
node_patient(("Patient"))
node_redis[("Redis")]

node_caregiver -->|"uploads prescription"| node_upload_modal
node_upload_modal -->|"submits upload"| node_api_client
node_api_client -->|"calls API"| node_app
node_app -->|"dispatches requests"| node_prescription_routes
node_prescription_routes -->|"requests OCR"| node_ocr
node_prescription_routes -->|"parses OCR text"| node_parser
node_prescription_routes -->|"saves candidates"| node_repository
node_parser -->|"returns candidates"| node_prescription_routes
node_repository -->|"writes records"| node_database
node_dashboard_pages -->|"loads review data"| node_api_client
node_caregiver -->|"reviews candidates"| node_dashboard_pages
node_app -->|"dispatches requests"| node_medication_routes
node_medication_routes -->|"confirms or rejects"| node_verification
node_verification -->|"guards and updates"| node_database
node_verification -->|"activates reminders"| node_reminder_service
node_reminder_service -->|"calculates times"| node_scheduler
node_reminder_service -->|"persists reminders"| node_database
node_reminder_service -->|"enqueues jobs"| node_queue
node_queue -->|"stores jobs"| node_redis
node_redis -->|"dispatches jobs"| node_worker
node_worker -->|"checks live state"| node_database
node_worker -.->|"translates reminder"| node_translation
node_worker -->|"sends message"| node_delivery_provider
node_delivery_provider -->|"delivers reminder"| node_patient
node_patient -->|"replies to reminder"| node_adherence_routes
node_app -->|"dispatches requests"| node_adherence_routes
node_adherence_routes -->|"records reply"| node_adherence_service
node_adherence_service -->|"classifies reply"| node_classifier
node_adherence_service -->|"reads and writes logs"| node_database
node_adherence_service -->|"escalates attention"| node_delivery_provider
node_app -->|"dispatches requests"| node_audit_routes
node_audit_routes -->|"reads audit data"| node_database
node_retention -->|"scrubs patient data"| node_database
node_app -->|"logs requests and errors"| node_logger

click node_dashboard_pages "https://github.com/shitij07/prescriptionsetu/tree/master/apps/dashboard/src/app"
click node_upload_modal "https://github.com/shitij07/prescriptionsetu/blob/master/apps/dashboard/src/components/UploadPrescriptionModal.tsx"
click node_api_client "https://github.com/shitij07/prescriptionsetu/blob/master/apps/dashboard/src/lib/api.ts"
click node_app "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/app.ts"
click node_prescription_routes "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/routes/prescriptions.ts"
click node_ocr "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/ocr/types.ts"
click node_parser "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/parser/parse.ts"
click node_repository "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/db/repository.ts"
click node_database "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/db/connection.ts"
click node_verification "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/verification/gate.ts"
click node_medication_routes "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/routes/medications.ts"
click node_reminder_service "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/reminders/service.ts"
click node_scheduler "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/reminders/scheduler.ts"
click node_queue "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/reminders/queue.ts"
click node_worker "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/reminders/worker.ts"
click node_translation "https://github.com/shitij07/prescriptionsetu/tree/master/apps/api/src"
click node_delivery_provider "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/delivery/types.ts"
click node_adherence_routes "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/routes/adherence.ts"
click node_adherence_service "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/adherence/service.ts"
click node_classifier "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/adherence/classifier.ts"
click node_retention "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/retention/service.ts"
click node_audit_routes "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/routes/audit.ts"
click node_logger "https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/logging/logger.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_dashboard_pages,node_upload_modal,node_api_client toneBlue
class node_app,node_prescription_routes,node_ocr,node_parser,node_repository,node_database,node_verification,node_medication_routes,node_redis toneAmber
class node_reminder_service,node_scheduler,node_queue,node_worker,node_translation,node_delivery_provider toneMint
class node_adherence_routes,node_adherence_service,node_classifier toneRose
class node_retention,node_audit_routes,node_logger,node_caregiver,node_patient toneIndigo
```

## Components

### Caregiver dashboard

- [Review and patient views](https://github.com/shitij07/prescriptionsetu/tree/master/apps/dashboard/src/app): `apps/dashboard/src/app`
- [Prescription upload](https://github.com/shitij07/prescriptionsetu/blob/master/apps/dashboard/src/components/UploadPrescriptionModal.tsx): `apps/dashboard/src/components/UploadPrescriptionModal.tsx`
- [Dashboard API client](https://github.com/shitij07/prescriptionsetu/blob/master/apps/dashboard/src/lib/api.ts): `apps/dashboard/src/lib/api.ts`

### Clinical processing

- [Express API application](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/app.ts): `apps/api/src/app.ts`
- [Prescription routes](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/routes/prescriptions.ts): `apps/api/src/routes/prescriptions.ts`
- [OCR provider seam](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/ocr/types.ts): `apps/api/src/ocr/types.ts`
- [Deterministic shorthand parser](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/parser/parse.ts): `apps/api/src/parser/parse.ts`
- [Prescription persistence](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/db/repository.ts): `apps/api/src/db/repository.ts`
- [PostgreSQL data store](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/db/connection.ts): `apps/api/src/db/connection.ts`
- [Verification gate](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/verification/gate.ts): `apps/api/src/verification/gate.ts`
- [Medication routes](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/routes/medications.ts): `apps/api/src/routes/medications.ts`

### Reminders and delivery

- [Reminder generation](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/reminders/service.ts): `apps/api/src/reminders/service.ts`
- [Reminder scheduler](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/reminders/scheduler.ts): `apps/api/src/reminders/scheduler.ts`
- [BullMQ job queue](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/reminders/queue.ts): `apps/api/src/reminders/queue.ts`
- [Reminder worker](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/reminders/worker.ts): `apps/api/src/reminders/worker.ts`
- [Translation providers](https://github.com/shitij07/prescriptionsetu/tree/master/apps/api/src): `apps/api/src`
- [WhatsApp / console provider](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/delivery/types.ts): `apps/api/src/delivery/types.ts`

### Adherence tracking

- [Adherence routes](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/routes/adherence.ts): `apps/api/src/routes/adherence.ts`
- [Reply classification and stats](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/adherence/service.ts): `apps/api/src/adherence/service.ts`
- [Keyword classifier](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/adherence/classifier.ts): `apps/api/src/adherence/classifier.ts`

### Privacy and audit

- [Erasure and image retention](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/retention/service.ts): `apps/api/src/retention/service.ts`
- [Audit routes](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/routes/audit.ts): `apps/api/src/routes/audit.ts`
- [Sanitized structured logging](https://github.com/shitij07/prescriptionsetu/blob/master/apps/api/src/logging/logger.ts): `apps/api/src/logging/logger.ts`

### Other components

- **Caregiver / verifier**
- **Patient**
- **Redis**

## Connections

- Caregiver / verifier → Prescription upload: uploads prescription
- Prescription upload → Dashboard API client: submits upload
- Dashboard API client → Express API application: calls API
- Express API application → Prescription routes: dispatches requests
- Prescription routes → OCR provider seam: requests OCR
- Prescription routes → Deterministic shorthand parser: parses OCR text
- Prescription routes → Prescription persistence: saves candidates
- Deterministic shorthand parser → Prescription routes: returns candidates
- Prescription persistence → PostgreSQL data store: writes records
- Review and patient views → Dashboard API client: loads review data
- Caregiver / verifier → Review and patient views: reviews candidates
- Express API application → Medication routes: dispatches requests
- Medication routes → Verification gate: confirms or rejects
- Verification gate → PostgreSQL data store: guards and updates
- Verification gate → Reminder generation: activates reminders
- Reminder generation → Reminder scheduler: calculates times
- Reminder generation → PostgreSQL data store: persists reminders
- Reminder generation → BullMQ job queue: enqueues jobs
- BullMQ job queue → Redis: stores jobs
- Redis → Reminder worker: dispatches jobs
- Reminder worker → PostgreSQL data store: checks live state
- Reminder worker → Translation providers: translates reminder
- Reminder worker → WhatsApp / console provider: sends message
- WhatsApp / console provider → Patient: delivers reminder
- Patient → Adherence routes: replies to reminder
- Express API application → Adherence routes: dispatches requests
- Adherence routes → Reply classification and stats: records reply
- Reply classification and stats → Keyword classifier: classifies reply
- Reply classification and stats → PostgreSQL data store: reads and writes logs
- Reply classification and stats → WhatsApp / console provider: escalates attention
- Express API application → Audit routes: dispatches requests
- Audit routes → PostgreSQL data store: reads audit data
- Erasure and image retention → PostgreSQL data store: scrubs patient data
- Express API application → Sanitized structured logging: logs requests and errors
