# manu-7/diagnosense architecture

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

- Interactive diagram: https://gitdiagram.com/manu-7/diagnosense
- Repository: https://github.com/manu-7/diagnosense

## Overview

DiagnoSense connects patient symptom triage and diagnostic bookings with center-side report processing and patient-facing results. The frontend routes role-specific journeys through a shared API client; the FastAPI backend handles catalog, booking, and report requests, while Celery supports asynchronous report analysis and notifications. Report analysis combines measured values, rule-based anomaly checks, retrieval-grounded explanations, and private PDF storage. README capability descriptions supplement sampled code for unsampled routes; edges are limited to relationships shown in excerpts, the SOURCE INDEX, or README.

Main entry points: [`backend/app/routers/reports.py`](https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/reports.py) (Report endpoints), [`backend/app/tasks/tasks.py`](https://github.com/manu-7/diagnosense/blob/main/backend/app/tasks/tasks.py) (Async tasks), [`backend/app/main.py`](https://github.com/manu-7/diagnosense/blob/main/backend/app/main.py) (FastAPI app), [`frontend/src/App.jsx`](https://github.com/manu-7/diagnosense/blob/main/frontend/src/App.jsx) (Web app routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web_app["Web app routes<br/>[App.jsx]"]
  node_auth_context["Auth context<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>[client.js]"]
  node_patient_journey["Patient pages"]
  node_center_journey["Center pages"]
end

subgraph group_api["Backend API"]
  node_backend_api["FastAPI app<br/>[main.py]"]
  node_auth_routes["Authentication<br/>[auth.py]"]
  node_center_routes["Center catalog<br/>[centers.py]"]
  node_ai_routes["Symptom triage<br/>[ai.py]"]
  node_booking_routes["Bookings and payment<br/>[bookings.py]"]
  node_report_routes["Report endpoints<br/>[reports.py]"]
end

subgraph group_analysis["Report analysis"]
  node_ai_service["AI and anomaly rules<br/>[ai_service.py]"]
  node_rag_service["Reference retrieval<br/>[rag_service.py]"]
  node_embedding["Text embeddings"]
  node_extraction["Lab value extraction"]
  node_pdf_service["PDF generation"]
  node_tasks["Async tasks<br/>[tasks.py]"]
end

subgraph group_data["Data and integrations"]
  node_models["Domain models"]
  node_report_schema["Report schema<br/>[report.py]"]
  node_database[("PostgreSQL and pgvector<br/>[database.py]")]
  node_redis[("Redis cache and broker<br/>[redis_client.py]")]
  node_object_storage[("Report object storage<br/>[storage_service.py]")]
  node_payment_provider["Razorpay"]
  node_llm_provider["Groq LLM"]
  node_email_service["Email delivery<br/>[email_service.py]"]
end

node_patient(("Patient"))
node_center_user(("Center user"))

node_patient -->|"uses"| node_web_app
node_center_user -->|"uses"| node_web_app
node_web_app -->|"routes to"| node_patient_journey
node_web_app -->|"routes to"| node_center_journey
node_web_app -.->|"provides auth"| node_auth_context
node_auth_context -->|"calls"| node_api_client
node_patient_journey -->|"requests data"| node_api_client
node_center_journey -->|"requests data"| node_api_client
node_api_client -->|"HTTPS REST"| node_backend_api
node_backend_api -->|"registers"| node_auth_routes
node_backend_api -->|"registers"| node_center_routes
node_backend_api -->|"registers"| node_ai_routes
node_backend_api -->|"registers"| node_booking_routes
node_backend_api -->|"registers"| node_report_routes
node_ai_routes -->|"requests recommendations"| node_ai_service
node_ai_routes -->|"caches catalogue"| node_redis
node_booking_routes -->|"creates and verifies payment"| node_payment_provider
node_booking_routes -->|"queues notifications"| node_tasks
node_booking_routes -->|"reads and writes bookings"| node_models
node_report_routes -->|"reads and writes reports"| node_models
node_report_routes -->|"uses"| node_report_schema
node_report_routes -->|"generates PDF"| node_pdf_service
node_report_routes -->|"uploads and signs access"| node_object_storage
node_report_routes -->|"flags anomalies"| node_ai_service
node_report_routes -->|"requests explanation"| node_rag_service
node_report_routes -->|"queues analysis"| node_tasks
node_tasks -->|"downloads report"| node_object_storage
node_tasks -->|"extracts values"| node_extraction
node_tasks -->|"flags anomalies"| node_ai_service
node_tasks -->|"requests explanation"| node_rag_service
node_tasks -->|"persists analysis"| node_database
node_tasks -->|"sends notifications"| node_email_service
node_rag_service -->|"embeds query"| node_embedding
node_rag_service -->|"retrieves snippets"| node_database
node_rag_service -->|"grounds explanation"| node_ai_service
node_ai_service -->|"requests generation"| node_llm_provider
node_database -.->|"stores domain data"| node_models

click node_web_app "https://github.com/manu-7/diagnosense/blob/main/frontend/src/App.jsx"
click node_auth_context "https://github.com/manu-7/diagnosense/blob/main/frontend/src/context/AuthContext.jsx"
click node_api_client "https://github.com/manu-7/diagnosense/blob/main/frontend/src/api/client.js"
click node_patient_journey "https://github.com/manu-7/diagnosense/tree/main/frontend/src/pages"
click node_center_journey "https://github.com/manu-7/diagnosense/tree/main/frontend/src/pages"
click node_backend_api "https://github.com/manu-7/diagnosense/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/auth.py"
click node_center_routes "https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/centers.py"
click node_ai_routes "https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/ai.py"
click node_booking_routes "https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/bookings.py"
click node_report_routes "https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/reports.py"
click node_models "https://github.com/manu-7/diagnosense/tree/main/backend/app/models"
click node_report_schema "https://github.com/manu-7/diagnosense/blob/main/backend/app/schemas/report.py"
click node_ai_service "https://github.com/manu-7/diagnosense/blob/main/backend/app/services/ai_service.py"
click node_rag_service "https://github.com/manu-7/diagnosense/blob/main/backend/app/services/rag_service.py"
click node_embedding "https://github.com/manu-7/diagnosense/blob/main/backend/app/services/embedding_service.py"
click node_extraction "https://github.com/manu-7/diagnosense/blob/main/backend/app/services/extraction_service.py"
click node_pdf_service "https://github.com/manu-7/diagnosense/blob/main/backend/app/services/pdf_report_service.py"
click node_tasks "https://github.com/manu-7/diagnosense/blob/main/backend/app/tasks/tasks.py"
click node_database "https://github.com/manu-7/diagnosense/blob/main/backend/app/database.py"
click node_redis "https://github.com/manu-7/diagnosense/blob/main/backend/app/core/redis_client.py"
click node_object_storage "https://github.com/manu-7/diagnosense/blob/main/backend/app/services/storage_service.py"
click node_email_service "https://github.com/manu-7/diagnosense/blob/main/backend/app/services/email_service.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_app,node_auth_context,node_api_client,node_patient_journey,node_center_journey,node_center_user toneBlue
class node_backend_api,node_auth_routes,node_center_routes,node_ai_routes,node_booking_routes,node_report_routes toneAmber
class node_ai_service,node_rag_service,node_embedding,node_extraction,node_pdf_service,node_tasks toneMint
class node_models,node_report_schema,node_database,node_redis,node_object_storage,node_payment_provider,node_llm_provider,node_email_service toneRose
class node_patient toneIndigo
```

## Components

### Web client

- [Web app routes](https://github.com/manu-7/diagnosense/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth context](https://github.com/manu-7/diagnosense/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/manu-7/diagnosense/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`
- [Patient pages](https://github.com/manu-7/diagnosense/tree/main/frontend/src/pages): `frontend/src/pages`
- [Center pages](https://github.com/manu-7/diagnosense/tree/main/frontend/src/pages): `frontend/src/pages`

### Backend API

- [FastAPI app](https://github.com/manu-7/diagnosense/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Center catalog](https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/centers.py): `backend/app/routers/centers.py`
- [Symptom triage](https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/ai.py): `backend/app/routers/ai.py`
- [Bookings and payment](https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/bookings.py): `backend/app/routers/bookings.py`
- [Report endpoints](https://github.com/manu-7/diagnosense/blob/main/backend/app/routers/reports.py): `backend/app/routers/reports.py`

### Report analysis

- [AI and anomaly rules](https://github.com/manu-7/diagnosense/blob/main/backend/app/services/ai_service.py): `backend/app/services/ai_service.py`
- [Reference retrieval](https://github.com/manu-7/diagnosense/blob/main/backend/app/services/rag_service.py): `backend/app/services/rag_service.py`
- [Text embeddings](https://github.com/manu-7/diagnosense/blob/main/backend/app/services/embedding_service.py): `backend/app/services/embedding_service.py`
- [Lab value extraction](https://github.com/manu-7/diagnosense/blob/main/backend/app/services/extraction_service.py): `backend/app/services/extraction_service.py`
- [PDF generation](https://github.com/manu-7/diagnosense/blob/main/backend/app/services/pdf_report_service.py): `backend/app/services/pdf_report_service.py`
- [Async tasks](https://github.com/manu-7/diagnosense/blob/main/backend/app/tasks/tasks.py): `backend/app/tasks/tasks.py`

### Data and integrations

- [Domain models](https://github.com/manu-7/diagnosense/tree/main/backend/app/models): `backend/app/models`
- [Report schema](https://github.com/manu-7/diagnosense/blob/main/backend/app/schemas/report.py): `backend/app/schemas/report.py`
- [PostgreSQL and pgvector](https://github.com/manu-7/diagnosense/blob/main/backend/app/database.py): `backend/app/database.py`
- [Redis cache and broker](https://github.com/manu-7/diagnosense/blob/main/backend/app/core/redis_client.py): `backend/app/core/redis_client.py`
- [Report object storage](https://github.com/manu-7/diagnosense/blob/main/backend/app/services/storage_service.py): `backend/app/services/storage_service.py`
- **Razorpay**
- **Groq LLM**
- [Email delivery](https://github.com/manu-7/diagnosense/blob/main/backend/app/services/email_service.py): `backend/app/services/email_service.py`

### Other components

- **Patient**
- **Center user**

## Connections

- Patient → Web app routes: uses
- Center user → Web app routes: uses
- Web app routes → Patient pages: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Center pages: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Auth context: provides auth
- Auth context → API client: calls (evidence: `frontend/src/context/AuthContext.jsx`)
- Patient pages → API client: requests data (evidence: `frontend/src/pages/ReportDetail.jsx`)
- Center pages → API client: requests data (evidence: `frontend/src/pages/CenterBookings.jsx`)
- API client → FastAPI app: HTTPS REST
- FastAPI app → Authentication: registers (evidence: `backend/app/main.py`)
- FastAPI app → Center catalog: registers (evidence: `backend/app/main.py`)
- FastAPI app → Symptom triage: registers (evidence: `backend/app/main.py`)
- FastAPI app → Bookings and payment: registers (evidence: `backend/app/main.py`)
- FastAPI app → Report endpoints: registers (evidence: `backend/app/main.py`)
- Symptom triage → AI and anomaly rules: requests recommendations (evidence: `backend/app/routers/ai.py`)
- Symptom triage → Redis cache and broker: caches catalogue (evidence: `backend/app/routers/ai.py`)
- Bookings and payment → Razorpay: creates and verifies payment
- Bookings and payment → Async tasks: queues notifications (evidence: `backend/app/routers/bookings.py`)
- Bookings and payment → Domain models: reads and writes bookings (evidence: `backend/app/routers/bookings.py`)
- Report endpoints → Domain models: reads and writes reports (evidence: `backend/app/routers/reports.py`)
- Report endpoints → Report schema: uses (evidence: `backend/app/routers/reports.py`)
- Report endpoints → PDF generation: generates PDF (evidence: `backend/app/routers/reports.py`)
- Report endpoints → Report object storage: uploads and signs access (evidence: `backend/app/routers/reports.py`)
- Report endpoints → AI and anomaly rules: flags anomalies (evidence: `backend/app/routers/reports.py`)
- Report endpoints → Reference retrieval: requests explanation (evidence: `backend/app/routers/reports.py`)
- Report endpoints → Async tasks: queues analysis (evidence: `backend/app/routers/reports.py`)
- Async tasks → Report object storage: downloads report (evidence: `backend/app/tasks/tasks.py`)
- Async tasks → Lab value extraction: extracts values (evidence: `backend/app/tasks/tasks.py`)
- Async tasks → AI and anomaly rules: flags anomalies (evidence: `backend/app/tasks/tasks.py`)
- Async tasks → Reference retrieval: requests explanation (evidence: `backend/app/tasks/tasks.py`)
- Async tasks → PostgreSQL and pgvector: persists analysis (evidence: `backend/app/tasks/tasks.py`)
- Async tasks → Email delivery: sends notifications (evidence: `backend/app/tasks/tasks.py`)
- Reference retrieval → Text embeddings: embeds query (evidence: `backend/app/services/rag_service.py`)
- Reference retrieval → PostgreSQL and pgvector: retrieves snippets (evidence: `backend/app/services/rag_service.py`)
- Reference retrieval → AI and anomaly rules: grounds explanation (evidence: `backend/app/services/rag_service.py`)
- AI and anomaly rules → Groq LLM: requests generation
- PostgreSQL and pgvector → Domain models: stores domain data (evidence: `backend/app/models/reference_snippet.py`)
