# umamaheshmindaguditi9/enterprise-app-sparsa architecture

> Architecture diagram of the GitHub repository umamaheshmindaguditi9/enterprise-app-sparsa, 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/umamaheshmindaguditi9/enterprise-app-sparsa
- Repository: https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa

## Overview

Sparsa Homeoclinic is a two-tier clinic-management application. Reception creates patients and cases; doctors record clinical notes and prescriptions, pharmacy handles dispensing, and PRO staff bill and record payments. The React client calls a FastAPI service backed by MongoDB, with optional object storage and messaging integrations. The graph preserves AI assistance, reminders, analytics, exports, and package billing. Some subsystem details are documented but their source was not excerpted, so those links are shown only where supported by the README or source index.

Main entry points: [`backend/server.py`](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/server.py) (FastAPI service), [`backend/core.py`](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/core.py) (Access and audit), [`backend/routers/ai.py`](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/ai.py) (AI assistance), [`backend/routers/admin.py`](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/admin.py) (Administration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["React application<br/>[App.js]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_workflow["Patient workflow"]
  node_patients["Patient records<br/>[patients.py]"]
  node_cases["Case workflow<br/>[cases.py]"]
  node_pharmacy["Pharmacy workflow<br/>[pharmacy.py]"]
end

subgraph group_clinical["Clinical services"]
  node_ai["AI assistance<br/>[ai.py]"]
  node_clinical_context["Clinical context"]
  node_fir["FIR parsing<br/>[fir_parsing.py]"]
  node_prompts["AI prompts<br/>[prompts.py]"]
end

subgraph group_operations["Clinic operations"]
  node_payments["Visit payments<br/>[payments.py]"]
  node_packages["Package billing<br/>[package_service.py]"]
  node_package_routes["Package endpoints<br/>[packages.py]"]
  node_package_billing["Package payments<br/>[package_billing.py]"]
  node_attachments["Attachment endpoints<br/>[attachments.py]"]
  node_storage["Object storage<br/>[storage.py]"]
  node_reminders["Reminders<br/>[reminders.py]"]
  node_messaging["Messaging integrations<br/>[messaging.py]"]
  node_dashboards["Dashboards and analytics<br/>[dashboards.py]"]
  node_financial_reporting["Financial reporting"]
  node_admin["Administration<br/>[admin.py]"]
  node_exports["Data exports<br/>[exports.py]"]
end

subgraph group_shared["Shared infrastructure"]
  node_server["FastAPI service<br/>[server.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_core["Access and audit<br/>[core.py]"]
  node_mongo[("MongoDB")]
end

node_staff(("Clinic staff"))
node_object_store[("Emergent object storage")]
node_external_messaging["Twilio / WhatsApp"]
node_scheduler["Background reminders"]

node_staff -->|"uses"| node_web
node_web -->|"makes requests"| node_api
node_api -->|"calls API"| node_server
node_server -->|"mounts router"| node_auth
node_server -->|"mounts router"| node_patients
node_server -->|"mounts router"| node_cases
node_server -->|"mounts router"| node_pharmacy
node_server -->|"mounts router"| node_payments
node_server -->|"mounts router"| node_reminders
node_server -->|"mounts router"| node_attachments
node_server -->|"mounts router"| node_ai
node_server -->|"mounts router"| node_dashboards
node_server -->|"mounts router"| node_package_routes
node_server -->|"mounts router"| node_package_billing
node_server -->|"mounts router"| node_admin
node_server -->|"mounts router"| node_exports
node_auth -->|"uses security helpers"| node_core
node_auth -->|"reads and updates users"| node_mongo
node_patients -->|"stores patient records"| node_mongo
node_cases -->|"uses access helpers"| node_core
node_cases -.->|"manages cases"| node_mongo
node_pharmacy -.->|"manages dispensing"| node_mongo
node_payments -.->|"records payments"| node_mongo
node_package_routes -->|"uses package service"| node_packages
node_package_billing -->|"uses package service"| node_packages
node_packages -->|"updates package ledger"| node_mongo
node_ai -->|"builds context"| node_clinical_context
node_ai -->|"selects prompts"| node_prompts
node_ai -->|"parses clinical notes"| node_fir
node_prompts -->|"references parsing"| node_fir
node_attachments -->|"uses storage helper"| node_storage
node_storage -->|"uploads and downloads"| node_object_store
node_reminders -->|"sends notifications"| node_messaging
node_messaging -.->|"integrates with"| node_external_messaging
node_server -.->|"runs reminder tasks"| node_scheduler
node_dashboards -->|"uses reporting"| node_financial_reporting
node_financial_reporting -->|"uses shared infrastructure"| node_core
node_dashboards -->|"aggregates clinic data"| node_mongo
node_admin -->|"uses shared infrastructure"| node_core
node_admin -->|"configures messaging"| node_messaging
node_admin -.->|"manages clinic data"| node_mongo
node_exports -->|"uses shared infrastructure"| node_core

click node_web "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/frontend/src/App.js"
click node_api "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/frontend/src/lib/api.js"
click node_server "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/server.py"
click node_auth "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/auth.py"
click node_core "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/core.py"
click node_patients "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/patients.py"
click node_cases "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/cases.py"
click node_pharmacy "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/pharmacy.py"
click node_payments "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/payments.py"
click node_packages "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/package_service.py"
click node_package_routes "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/packages.py"
click node_package_billing "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/package_billing.py"
click node_ai "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/ai.py"
click node_clinical_context "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/clinical_context.py"
click node_fir "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/fir_parsing.py"
click node_prompts "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/prompts.py"
click node_attachments "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/attachments.py"
click node_storage "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/storage.py"
click node_reminders "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/reminders.py"
click node_messaging "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/messaging.py"
click node_dashboards "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/dashboards.py"
click node_financial_reporting "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/financial_reporting.py"
click node_admin "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/admin.py"
click node_exports "https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/exports.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,node_api toneBlue
class node_patients,node_cases,node_pharmacy,node_object_store toneAmber
class node_ai,node_clinical_context,node_fir,node_prompts toneMint
class node_payments,node_packages,node_package_routes,node_package_billing,node_attachments,node_storage,node_reminders,node_messaging,node_dashboards,node_financial_reporting,node_admin,node_exports,node_scheduler toneRose
class node_server,node_auth,node_core,node_mongo,node_staff,node_external_messaging toneIndigo
```

## Components

### Web client

- [React application](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [API client](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`

### Patient workflow

- [Patient records](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/patients.py): `backend/routers/patients.py`
- [Case workflow](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/cases.py): `backend/routers/cases.py`
- [Pharmacy workflow](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/pharmacy.py): `backend/routers/pharmacy.py`

### Clinical services

- [AI assistance](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/ai.py): `backend/routers/ai.py`
- [Clinical context](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/clinical_context.py): `backend/clinical_context.py`
- [FIR parsing](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/fir_parsing.py): `backend/fir_parsing.py`
- [AI prompts](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/prompts.py): `backend/prompts.py`

### Clinic operations

- [Visit payments](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/payments.py): `backend/routers/payments.py`
- [Package billing](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/package_service.py): `backend/package_service.py`
- [Package endpoints](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/packages.py): `backend/routers/packages.py`
- [Package payments](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/package_billing.py): `backend/routers/package_billing.py`
- [Attachment endpoints](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/attachments.py): `backend/routers/attachments.py`
- [Object storage](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/storage.py): `backend/storage.py`
- [Reminders](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/reminders.py): `backend/routers/reminders.py`
- [Messaging integrations](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/messaging.py): `backend/messaging.py`
- [Dashboards and analytics](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/dashboards.py): `backend/routers/dashboards.py`
- [Financial reporting](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/financial_reporting.py): `backend/financial_reporting.py`
- [Administration](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/admin.py): `backend/routers/admin.py`
- [Data exports](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/exports.py): `backend/routers/exports.py`

### Shared infrastructure

- [FastAPI service](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/server.py): `backend/server.py`
- [Authentication](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/routers/auth.py): `backend/routers/auth.py`
- [Access and audit](https://github.com/umamaheshmindaguditi9/enterprise-app-sparsa/blob/main/backend/core.py): `backend/core.py`
- **MongoDB**

### Other components

- **Clinic staff**
- **Emergent object storage**
- **Twilio / WhatsApp**
- **Background reminders**

## Connections

- Clinic staff → React application: uses (evidence: `README.md`)
- React application → API client: makes requests (evidence: `README.md`)
- API client → FastAPI service: calls API (evidence: `README.md`)
- FastAPI service → Authentication: mounts router (evidence: `backend/server.py`)
- FastAPI service → Patient records: mounts router (evidence: `backend/server.py`)
- FastAPI service → Case workflow: mounts router (evidence: `backend/server.py`)
- FastAPI service → Pharmacy workflow: mounts router (evidence: `backend/server.py`)
- FastAPI service → Visit payments: mounts router (evidence: `backend/server.py`)
- FastAPI service → Reminders: mounts router (evidence: `backend/server.py`)
- FastAPI service → Attachment endpoints: mounts router (evidence: `backend/server.py`)
- FastAPI service → AI assistance: mounts router (evidence: `backend/server.py`)
- FastAPI service → Dashboards and analytics: mounts router (evidence: `backend/server.py`)
- FastAPI service → Package endpoints: mounts router (evidence: `backend/server.py`)
- FastAPI service → Package payments: mounts router (evidence: `backend/server.py`)
- FastAPI service → Administration: mounts router (evidence: `backend/server.py`)
- FastAPI service → Data exports: mounts router (evidence: `backend/server.py`)
- Authentication → Access and audit: uses security helpers (evidence: `backend/routers/auth.py`)
- Authentication → MongoDB: reads and updates users (evidence: `backend/routers/auth.py`)
- Patient records → MongoDB: stores patient records (evidence: `backend/routers/patients.py`)
- Case workflow → Access and audit: uses access helpers (evidence: `backend/routers/cases.py`)
- Case workflow → MongoDB: manages cases
- Pharmacy workflow → MongoDB: manages dispensing
- Visit payments → MongoDB: records payments
- Package endpoints → Package billing: uses package service (evidence: `backend/routers/packages.py`)
- Package payments → Package billing: uses package service (evidence: `backend/routers/package_billing.py`)
- Package billing → MongoDB: updates package ledger (evidence: `backend/package_service.py`)
- AI assistance → Clinical context: builds context (evidence: `backend/routers/ai.py`)
- AI assistance → AI prompts: selects prompts (evidence: `backend/routers/ai.py`)
- AI assistance → FIR parsing: parses clinical notes (evidence: `backend/routers/ai.py`)
- AI prompts → FIR parsing: references parsing (evidence: `backend/prompts.py`)
- Attachment endpoints → Object storage: uses storage helper (evidence: `backend/routers/attachments.py`)
- Object storage → Emergent object storage: uploads and downloads (evidence: `backend/storage.py`)
- Reminders → Messaging integrations: sends notifications (evidence: `backend/routers/reminders.py`)
- Messaging integrations → Twilio / WhatsApp: integrates with (evidence: `README.md`)
- FastAPI service → Background reminders: runs reminder tasks (evidence: `README.md`)
- Dashboards and analytics → Financial reporting: uses reporting (evidence: `backend/routers/dashboards.py`)
- Financial reporting → Access and audit: uses shared infrastructure (evidence: `backend/financial_reporting.py`)
- Dashboards and analytics → MongoDB: aggregates clinic data (evidence: `backend/routers/dashboards.py`)
- Administration → Access and audit: uses shared infrastructure (evidence: `backend/routers/admin.py`)
- Administration → Messaging integrations: configures messaging (evidence: `backend/routers/admin.py`)
- Administration → MongoDB: manages clinic data
- Data exports → Access and audit: uses shared infrastructure (evidence: `backend/routers/exports.py`)
