# syed-mohammad-wasique-junaid/swasthyavault architecture

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

- Interactive diagram: https://gitdiagram.com/syed-mohammad-wasique-junaid/swasthyavault
- Repository: https://github.com/syed-mohammad-wasique-junaid/swasthyavault

## Overview

SwasthyaVault is a patient-facing health-record platform with a doctor-facing, consent-governed view. Its intended workflow is to upload records, extract and summarize their contents, organize health history, and manage sharing. The sampled backend confirms API routing, document storage, AI analysis, timeline creation, and consent-related doctor access patterns, though some routes still use temporary fixed user IDs. The README describes offline Tesseract/Ollama processing; implementation details for those integrations and several frontend-to-API connections were not shown, so those links are marked unverified.

Main entry points: [`backend/app/main.py`](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/database.py`](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/app/database.py) (Relational database), [`backend/ai/service.py`](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/ai/service.py) (OCR and summarization), [`backend/auth/routes.py`](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/auth/routes.py) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_patient_ui["Patient portal<br/>[page.tsx]"]
  node_locker_ui["Health locker<br/>[page.tsx]"]
  node_timeline_ui["Timeline view<br/>[page.tsx]"]
  node_consent_ui["Consent controls<br/>[page.tsx]"]
  node_doctor_ui["Doctor dashboard<br/>[page.tsx]"]
  node_patient_detail_ui["Patient record view<br/>[page.tsx]"]
  node_auth_ui["Sign-in and registration<br/>[AuthContext.tsx]"]
end

subgraph group_api["API and access"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_auth_routes["Authentication<br/>[routes.py]"]
  node_patient_routes["Patient profiles<br/>[routes.py]"]
  node_doctor_routes["Doctor access<br/>[routes.py]"]
  node_consent_routes["Consent management<br/>[routes.py]"]
  node_security["Token security<br/>[security.py]"]
end

subgraph group_records["Health records"]
  node_document_routes["Document management<br/>[routes.py]"]
  node_timeline_routes["Health timeline<br/>[routes.py]"]
  node_database[("Relational database<br/>[database.py]")]
  node_document_files[("Uploaded files")]
end

subgraph group_processing["Document processing"]
  node_ai_routes["AI analysis endpoint<br/>[routes.py]"]
  node_ai_service["OCR and summarization<br/>[service.py]"]
  node_ai_prompts["AI prompts<br/>[prompts.py]"]
end

node_patient(("Patient"))
node_doctor(("Doctor"))
node_tesseract["Tesseract OCR"]
node_ollama["Ollama model"]

node_patient -->|"signs in"| node_auth_ui
node_doctor -->|"signs in"| node_auth_ui
node_patient -->|"manages records"| node_patient_ui
node_doctor -->|"reviews records"| node_doctor_ui
node_auth_ui -.->|"authenticates"| node_auth_routes
node_patient_ui -.->|"manages profile"| node_patient_routes
node_locker_ui -.->|"uploads and retrieves"| node_document_routes
node_timeline_ui -.->|"views history"| node_timeline_routes
node_consent_ui -.->|"sets sharing"| node_consent_routes
node_doctor_ui -.->|"lists patients"| node_doctor_routes
node_patient_detail_ui -.->|"requests details"| node_doctor_routes
node_api_app -->|"mounts"| node_auth_routes
node_api_app -->|"mounts"| node_patient_routes
node_api_app -->|"mounts"| node_doctor_routes
node_api_app -->|"mounts"| node_document_routes
node_api_app -->|"mounts"| node_ai_routes
node_api_app -->|"mounts"| node_timeline_routes
node_api_app -->|"mounts"| node_consent_routes
node_auth_routes -->|"hashes and signs"| node_security
node_auth_routes -->|"reads and writes"| node_database
node_patient_routes -->|"reads and writes"| node_database
node_doctor_routes -->|"checks access and reads"| node_database
node_consent_routes -->|"reads and writes"| node_database
node_document_routes -->|"saves upload"| node_document_files
node_document_routes -->|"stores metadata"| node_database
node_ai_routes -->|"reads document and writes event"| node_database
node_ai_routes -->|"extracts and summarizes"| node_ai_service
node_ai_service -->|"uses prompts"| node_ai_prompts
node_ai_service -.->|"extracts text"| node_tesseract
node_ai_service -.->|"generates summary"| node_ollama
node_timeline_routes -->|"reads timeline"| node_database

click node_patient_ui "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/patient/dashboard/page.tsx"
click node_locker_ui "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/patient/dashboard/locker/page.tsx"
click node_timeline_ui "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/patient/dashboard/timeline/page.tsx"
click node_consent_ui "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/patient/dashboard/consent/page.tsx"
click node_doctor_ui "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/doctor/dashboard/page.tsx"
click node_patient_detail_ui "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/doctor/dashboard/patient/%5Bid%5D/page.tsx"
click node_auth_ui "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/context/AuthContext.tsx"
click node_api_app "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/auth/routes.py"
click node_patient_routes "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/patient/routes.py"
click node_doctor_routes "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/doctor/routes.py"
click node_consent_routes "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/consent/routes.py"
click node_security "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/app/security.py"
click node_document_routes "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/documents/routes.py"
click node_timeline_routes "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/timeline/routes.py"
click node_database "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/app/database.py"
click node_ai_routes "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/ai/routes.py"
click node_ai_service "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/ai/service.py"
click node_ai_prompts "https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/ai/prompts.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_patient_ui,node_locker_ui,node_timeline_ui,node_consent_ui,node_doctor_ui,node_patient_detail_ui,node_auth_ui toneBlue
class node_api_app,node_auth_routes,node_patient_routes,node_doctor_routes,node_consent_routes,node_security toneAmber
class node_document_routes,node_timeline_routes,node_database,node_document_files toneMint
class node_ai_routes,node_ai_service,node_ai_prompts toneRose
class node_patient,node_doctor,node_tesseract,node_ollama toneIndigo
```

## Components

### User experience

- [Patient portal](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/patient/dashboard/page.tsx): `frontend/src/app/patient/dashboard/page.tsx`
- [Health locker](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/patient/dashboard/locker/page.tsx): `frontend/src/app/patient/dashboard/locker/page.tsx`
- [Timeline view](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/patient/dashboard/timeline/page.tsx): `frontend/src/app/patient/dashboard/timeline/page.tsx`
- [Consent controls](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/patient/dashboard/consent/page.tsx): `frontend/src/app/patient/dashboard/consent/page.tsx`
- [Doctor dashboard](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/doctor/dashboard/page.tsx): `frontend/src/app/doctor/dashboard/page.tsx`
- [Patient record view](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/app/doctor/dashboard/patient/%5Bid%5D/page.tsx): `frontend/src/app/doctor/dashboard/patient/[id]/page.tsx`
- [Sign-in and registration](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`

### API and access

- [FastAPI application](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/auth/routes.py): `backend/auth/routes.py`
- [Patient profiles](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/patient/routes.py): `backend/patient/routes.py`
- [Doctor access](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/doctor/routes.py): `backend/doctor/routes.py`
- [Consent management](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/consent/routes.py): `backend/consent/routes.py`
- [Token security](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/app/security.py): `backend/app/security.py`

### Health records

- [Document management](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/documents/routes.py): `backend/documents/routes.py`
- [Health timeline](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/timeline/routes.py): `backend/timeline/routes.py`
- [Relational database](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/app/database.py): `backend/app/database.py`
- **Uploaded files**

### Document processing

- [AI analysis endpoint](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/ai/routes.py): `backend/ai/routes.py`
- [OCR and summarization](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/ai/service.py): `backend/ai/service.py`
- [AI prompts](https://github.com/syed-mohammad-wasique-junaid/swasthyavault/blob/main/backend/ai/prompts.py): `backend/ai/prompts.py`

### Other components

- **Patient**
- **Doctor**
- **Tesseract OCR**
- **Ollama model**

## Connections

- Patient → Sign-in and registration: signs in
- Doctor → Sign-in and registration: signs in
- Patient → Patient portal: manages records
- Doctor → Doctor dashboard: reviews records
- Sign-in and registration → Authentication: authenticates
- Patient portal → Patient profiles: manages profile
- Health locker → Document management: uploads and retrieves
- Timeline view → Health timeline: views history
- Consent controls → Consent management: sets sharing
- Doctor dashboard → Doctor access: lists patients
- Patient record view → Doctor access: requests details
- FastAPI application → Authentication: mounts (evidence: `backend/app/main.py`)
- FastAPI application → Patient profiles: mounts (evidence: `backend/app/main.py`)
- FastAPI application → Doctor access: mounts (evidence: `backend/app/main.py`)
- FastAPI application → Document management: mounts (evidence: `backend/app/main.py`)
- FastAPI application → AI analysis endpoint: mounts (evidence: `backend/app/main.py`)
- FastAPI application → Health timeline: mounts (evidence: `backend/app/main.py`)
- FastAPI application → Consent management: mounts (evidence: `backend/app/main.py`)
- Authentication → Token security: hashes and signs (evidence: `backend/auth/routes.py`)
- Authentication → Relational database: reads and writes (evidence: `backend/auth/routes.py`)
- Patient profiles → Relational database: reads and writes (evidence: `backend/patient/routes.py`)
- Doctor access → Relational database: checks access and reads (evidence: `backend/doctor/routes.py`)
- Consent management → Relational database: reads and writes (evidence: `backend/consent/routes.py`)
- Document management → Uploaded files: saves upload (evidence: `backend/documents/routes.py`)
- Document management → Relational database: stores metadata (evidence: `backend/documents/routes.py`)
- AI analysis endpoint → Relational database: reads document and writes event (evidence: `backend/ai/routes.py`)
- AI analysis endpoint → OCR and summarization: extracts and summarizes (evidence: `backend/ai/routes.py`)
- OCR and summarization → AI prompts: uses prompts (evidence: `backend/ai/service.py`)
- OCR and summarization → Tesseract OCR: extracts text
- OCR and summarization → Ollama model: generates summary
- Health timeline → Relational database: reads timeline (evidence: `backend/timeline/routes.py`)
