# aasish3187/carelens architecture

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

- Interactive diagram: https://gitdiagram.com/aasish3187/carelens
- Repository: https://github.com/aasish3187/carelens

## Overview

CareLens is a personal health copilot that turns uploaded medical records into structured, clinically checked facts, then presents them as longitudinal patient views, grounded evidence, medication-safety insights, and FHIR/ABHA outputs. The main workflow runs from document upload through multimodal extraction and deterministic interpretation into stored patient records and user-facing views. The README also documents 3D organ mapping and multilingual summaries. Some backend and UI modules are unsampled; those capabilities are included, but uncertain implementation links are omitted or shown as unverified.

Main entry points: [`backend/app/api/documents.py`](https://github.com/aasish3187/carelens/blob/main/backend/app/api/documents.py) (Document API), [`backend/app/api/router.py`](https://github.com/aasish3187/carelens/blob/main/backend/app/api/router.py) (API router), [`backend/app/database.py`](https://github.com/aasish3187/carelens/blob/main/backend/app/database.py) (Health record database), [`backend/app/api/patients.py`](https://github.com/aasish3187/carelens/blob/main/backend/app/api/patients.py) (Patient API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Patient experience"]
  node_webapp["CareLens dashboard<br/>[App.tsx]"]
  node_navigation["App navigation<br/>[routes.tsx]"]
  node_upload_ui["Document upload<br/>[Upload.tsx]"]
  node_patient_hook["Patient data hook<br/>[usePatientData.ts]"]
  node_evidence_ui["Evidence Studio<br/>[EvidenceStudio.tsx]"]
  node_document_viewer["Document viewer<br/>[DocumentViewer.tsx]"]
  node_body_twin["3D body twin<br/>[BodyTwin3D.tsx]"]
  node_language["Language support<br/>[strings.ts]"]
end

subgraph group_ingestion["Document intelligence"]
  node_document_api["Document API<br/>[documents.py]"]
  node_extraction["Vision extraction<br/>[extract_vlm.py]"]
  node_ocr["OCR engine<br/>[ocr_engine.py]"]
end

subgraph group_clinical["Clinical interpretation"]
  node_rules["Clinical rules<br/>[rules_engine.py]"]
  node_organ_mapping["Organ mapping<br/>[organ_mapper.py]"]
  node_drug_normaliser["Drug normalisation<br/>[drug_normaliser.py]"]
  node_polypharmacy["Medication collision checks<br/>[polypharmacy.py]"]
  node_summaries["Grounded summaries<br/>[summarise.py]"]
  node_translation["Regional translation<br/>[translate.py]"]
end

subgraph group_records["Health records and exchange"]
  node_api_router["API router<br/>[router.py]"]
  node_patient_api["Patient API<br/>[patients.py]"]
  node_database[("Health record database<br/>[database.py]")]
  node_record_models["Record models<br/>[database.py]"]
  node_fhir_api["FHIR export API<br/>[fhir.py]"]
  node_bundle["FHIR bundle builder<br/>[bundle_builder.py]"]
  node_abha_api["ABHA API<br/>[abha.py]"]
  node_abha_mock["Mock ABHA<br/>[mock_abha.py]"]
  node_backend["FastAPI application<br/>[main.py]"]
end

node_patient(("Patient"))

node_patient -->|"uses"| node_webapp
node_webapp -->|"renders routes"| node_navigation
node_navigation -->|"routes to"| node_upload_ui
node_navigation -->|"routes to"| node_evidence_ui
node_patient -->|"uploads records"| node_upload_ui
node_upload_ui -.->|"submits document"| node_document_api
node_document_api -->|"invokes extraction"| node_extraction
node_extraction -.->|"uses OCR"| node_ocr
node_document_api -->|"persists records"| node_database
node_database -->|"uses models"| node_record_models
node_document_api -->|"requests summary"| node_summaries
node_document_api -->|"requests translation"| node_translation
node_document_api -.->|"validates facts"| node_rules
node_rules -.->|"maps organ systems"| node_organ_mapping
node_patient_api -->|"reads records"| node_database
node_patient_api -->|"checks collisions"| node_polypharmacy
node_polypharmacy -.->|"normalises drugs"| node_drug_normaliser
node_patient_hook -.->|"fetches summary"| node_patient_api
node_evidence_ui -->|"loads patient data"| node_patient_hook
node_evidence_ui -->|"renders evidence"| node_document_viewer
node_body_twin -.->|"visualises organ risk"| node_organ_mapping
node_patient -->|"requests export"| node_fhir_api
node_fhir_api -->|"reads records"| node_database
node_fhir_api -->|"builds bundle"| node_bundle
node_patient -->|"requests health card"| node_abha_api
node_abha_api -->|"reads patient"| node_database
node_abha_api -.->|"uses ABHA service"| node_abha_mock
node_patient -->|"selects language"| node_language
node_backend -->|"mounts API routes"| node_api_router
node_api_router -->|"registers route"| node_document_api
node_api_router -->|"registers route"| node_patient_api
node_api_router -->|"registers route"| node_fhir_api
node_api_router -->|"registers route"| node_abha_api

click node_webapp "https://github.com/aasish3187/carelens/blob/main/frontend/src/App.tsx"
click node_navigation "https://github.com/aasish3187/carelens/blob/main/frontend/src/routes.tsx"
click node_upload_ui "https://github.com/aasish3187/carelens/blob/main/frontend/src/pages/Upload.tsx"
click node_patient_hook "https://github.com/aasish3187/carelens/blob/main/frontend/src/hooks/usePatientData.ts"
click node_evidence_ui "https://github.com/aasish3187/carelens/blob/main/frontend/src/pages/EvidenceStudio.tsx"
click node_document_viewer "https://github.com/aasish3187/carelens/blob/main/frontend/src/components/DocumentViewer.tsx"
click node_body_twin "https://github.com/aasish3187/carelens/blob/main/frontend/src/components/BodyTwin3D.tsx"
click node_language "https://github.com/aasish3187/carelens/blob/main/frontend/src/i18n/strings.ts"
click node_api_router "https://github.com/aasish3187/carelens/blob/main/backend/app/api/router.py"
click node_document_api "https://github.com/aasish3187/carelens/blob/main/backend/app/api/documents.py"
click node_extraction "https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/extract_vlm.py"
click node_ocr "https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/ocr_engine.py"
click node_rules "https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/rules_engine.py"
click node_organ_mapping "https://github.com/aasish3187/carelens/blob/main/organ_mapper.py"
click node_drug_normaliser "https://github.com/aasish3187/carelens/blob/main/backend/app/data_loaders/drug_normaliser.py"
click node_polypharmacy "https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/polypharmacy.py"
click node_summaries "https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/summarise.py"
click node_translation "https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/translate.py"
click node_patient_api "https://github.com/aasish3187/carelens/blob/main/backend/app/api/patients.py"
click node_database "https://github.com/aasish3187/carelens/blob/main/backend/app/database.py"
click node_record_models "https://github.com/aasish3187/carelens/blob/main/backend/app/models/database.py"
click node_fhir_api "https://github.com/aasish3187/carelens/blob/main/backend/app/api/fhir.py"
click node_bundle "https://github.com/aasish3187/carelens/blob/main/backend/app/fhir/bundle_builder.py"
click node_abha_api "https://github.com/aasish3187/carelens/blob/main/backend/app/api/abha.py"
click node_abha_mock "https://github.com/aasish3187/carelens/blob/main/backend/app/fhir/mock_abha.py"
click node_backend "https://github.com/aasish3187/carelens/blob/main/backend/app/main.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_webapp,node_navigation,node_upload_ui,node_patient_hook,node_evidence_ui,node_document_viewer,node_body_twin,node_language toneBlue
class node_document_api,node_extraction,node_ocr toneAmber
class node_rules,node_organ_mapping,node_drug_normaliser,node_polypharmacy,node_summaries,node_translation toneMint
class node_api_router,node_patient_api,node_database,node_record_models,node_fhir_api,node_bundle,node_abha_api,node_abha_mock,node_backend toneRose
class node_patient toneIndigo
```

## Components

### Patient experience

- [CareLens dashboard](https://github.com/aasish3187/carelens/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [App navigation](https://github.com/aasish3187/carelens/blob/main/frontend/src/routes.tsx): `frontend/src/routes.tsx`
- [Document upload](https://github.com/aasish3187/carelens/blob/main/frontend/src/pages/Upload.tsx): `frontend/src/pages/Upload.tsx`
- [Patient data hook](https://github.com/aasish3187/carelens/blob/main/frontend/src/hooks/usePatientData.ts): `frontend/src/hooks/usePatientData.ts`
- [Evidence Studio](https://github.com/aasish3187/carelens/blob/main/frontend/src/pages/EvidenceStudio.tsx): `frontend/src/pages/EvidenceStudio.tsx`
- [Document viewer](https://github.com/aasish3187/carelens/blob/main/frontend/src/components/DocumentViewer.tsx): `frontend/src/components/DocumentViewer.tsx`
- [3D body twin](https://github.com/aasish3187/carelens/blob/main/frontend/src/components/BodyTwin3D.tsx): `frontend/src/components/BodyTwin3D.tsx`
- [Language support](https://github.com/aasish3187/carelens/blob/main/frontend/src/i18n/strings.ts): `frontend/src/i18n/strings.ts`

### Document intelligence

- [Document API](https://github.com/aasish3187/carelens/blob/main/backend/app/api/documents.py): `backend/app/api/documents.py`
- [Vision extraction](https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/extract_vlm.py): `backend/app/pipeline/extract_vlm.py`
- [OCR engine](https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/ocr_engine.py): `backend/app/pipeline/ocr_engine.py`

### Clinical interpretation

- [Clinical rules](https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/rules_engine.py): `backend/app/pipeline/rules_engine.py`
- [Organ mapping](https://github.com/aasish3187/carelens/blob/main/organ_mapper.py): `organ_mapper.py`
- [Drug normalisation](https://github.com/aasish3187/carelens/blob/main/backend/app/data_loaders/drug_normaliser.py): `backend/app/data_loaders/drug_normaliser.py`
- [Medication collision checks](https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/polypharmacy.py): `backend/app/pipeline/polypharmacy.py`
- [Grounded summaries](https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/summarise.py): `backend/app/pipeline/summarise.py`
- [Regional translation](https://github.com/aasish3187/carelens/blob/main/backend/app/pipeline/translate.py): `backend/app/pipeline/translate.py`

### Health records and exchange

- [API router](https://github.com/aasish3187/carelens/blob/main/backend/app/api/router.py): `backend/app/api/router.py`
- [Patient API](https://github.com/aasish3187/carelens/blob/main/backend/app/api/patients.py): `backend/app/api/patients.py`
- [Health record database](https://github.com/aasish3187/carelens/blob/main/backend/app/database.py): `backend/app/database.py`
- [Record models](https://github.com/aasish3187/carelens/blob/main/backend/app/models/database.py): `backend/app/models/database.py`
- [FHIR export API](https://github.com/aasish3187/carelens/blob/main/backend/app/api/fhir.py): `backend/app/api/fhir.py`
- [FHIR bundle builder](https://github.com/aasish3187/carelens/blob/main/backend/app/fhir/bundle_builder.py): `backend/app/fhir/bundle_builder.py`
- [ABHA API](https://github.com/aasish3187/carelens/blob/main/backend/app/api/abha.py): `backend/app/api/abha.py`
- [Mock ABHA](https://github.com/aasish3187/carelens/blob/main/backend/app/fhir/mock_abha.py): `backend/app/fhir/mock_abha.py`
- [FastAPI application](https://github.com/aasish3187/carelens/blob/main/backend/app/main.py): `backend/app/main.py`

### Other components

- **Patient**

## Connections

- Patient → CareLens dashboard: uses (evidence: `README.md`)
- CareLens dashboard → App navigation: renders routes (evidence: `frontend/src/App.tsx`)
- App navigation → Document upload: routes to (evidence: `frontend/src/routes.tsx`)
- App navigation → Evidence Studio: routes to (evidence: `frontend/src/routes.tsx`)
- Patient → Document upload: uploads records (evidence: `README.md`)
- Document upload → Document API: submits document
- Document API → Vision extraction: invokes extraction (evidence: `backend/app/api/documents.py`)
- Vision extraction → OCR engine: uses OCR
- Document API → Health record database: persists records (evidence: `backend/app/api/documents.py`)
- Health record database → Record models: uses models (evidence: `backend/app/database.py`)
- Document API → Grounded summaries: requests summary (evidence: `backend/app/api/documents.py`)
- Document API → Regional translation: requests translation (evidence: `backend/app/api/documents.py`)
- Document API → Clinical rules: validates facts
- Clinical rules → Organ mapping: maps organ systems
- Patient API → Health record database: reads records (evidence: `backend/app/api/patients.py`)
- Patient API → Medication collision checks: checks collisions (evidence: `backend/app/api/patients.py`)
- Medication collision checks → Drug normalisation: normalises drugs
- Patient data hook → Patient API: fetches summary
- Evidence Studio → Patient data hook: loads patient data (evidence: `frontend/src/pages/EvidenceStudio.tsx`)
- Evidence Studio → Document viewer: renders evidence (evidence: `frontend/src/pages/EvidenceStudio.tsx`)
- 3D body twin → Organ mapping: visualises organ risk
- Patient → FHIR export API: requests export (evidence: `README.md`)
- FHIR export API → Health record database: reads records (evidence: `backend/app/api/fhir.py`)
- FHIR export API → FHIR bundle builder: builds bundle (evidence: `backend/app/api/fhir.py`)
- Patient → ABHA API: requests health card (evidence: `README.md`)
- ABHA API → Health record database: reads patient (evidence: `backend/app/api/abha.py`)
- ABHA API → Mock ABHA: uses ABHA service
- Patient → Language support: selects language (evidence: `README.md`)
- FastAPI application → API router: mounts API routes (evidence: `backend/app/main.py`)
- API router → Document API: registers route (evidence: `backend/app/api/router.py`)
- API router → Patient API: registers route (evidence: `backend/app/api/router.py`)
- API router → FHIR export API: registers route (evidence: `backend/app/api/router.py`)
- API router → ABHA API: registers route (evidence: `backend/app/api/router.py`)
