# prxnesh/glucox architecture

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

## Overview

GlucoX is a diabetes-risk intelligence platform. A user signs in, submits clinical measurements or a lab report, and receives a prediction or extracted biomarkers; saved health records then support dashboard history, insights, and personalized chat. The frontend communicates with FastAPI routes, which delegate to services and use ML, OCR, Prisma, and external integrations. The graph follows documented flows and indexed imports; some report, prediction, OCR, and frontend implementation details were not excerpted, so their links rely on the README rather than inspected call sites.

Main entry points: [`backend/app/utils/database.py`](https://github.com/prxnesh/glucox/blob/main/backend/app/utils/database.py) (Database access), [`backend/app/services/prediction_service.py`](https://github.com/prxnesh/glucox/blob/main/backend/app/services/prediction_service.py) (Prediction service), [`backend/app/services/report_service.py`](https://github.com/prxnesh/glucox/blob/main/backend/app/services/report_service.py) (Report service), [`backend/app/services/chat_service.py`](https://github.com/prxnesh/glucox/blob/main/backend/app/services/chat_service.py) (Chat service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Health experience"]
  node_auth_ui["Auth UI<br/>[auth-form.tsx]"]
  node_risk_ui["Risk assessment"]
  node_report_ui["Report upload"]
  node_dashboard_ui["Dashboard and history<br/>[dashboard-view.tsx]"]
  node_assistant_ui["Health assistant"]
  node_profile_ui["Lifestyle profile<br/>[advanced-view.tsx]"]
end

subgraph group_api["API routes"]
  node_auth_route["Auth routes<br/>[auth.py]"]
  node_predict_route["Prediction route<br/>[predict.py]"]
  node_reports_route["Reports route<br/>[reports.py]"]
  node_records_route["Records route<br/>[records.py]"]
  node_chat_route["Chat route<br/>[chat.py]"]
end

subgraph group_services["Domain services"]
  node_auth_service["Auth service<br/>[auth_service.py]"]
  node_prediction_service["Prediction service"]
  node_report_service["Report service<br/>[report_service.py]"]
  node_history_service["History service<br/>[history_service.py]"]
  node_chat_service["Chat service<br/>[chat_service.py]"]
  node_insight_service["Insights and explanations<br/>[insight_service.py]"]
end

subgraph group_engines["Analysis engines"]
  node_ml["ML training and inference<br/>[training.py]"]
  node_ocr["OCR extraction<br/>[extractor.py]"]
end

subgraph group_data["Persistence and context"]
  node_db_access["Database access<br/>[database.py]"]
  node_prisma_client["Prisma client<br/>[client.py]"]
  node_prisma_builder["Query builder<br/>[_builder.py]"]
  node_prisma_engine["Query engine<br/>[_query.py]"]
end

node_user(("User"))
node_ollama["Ollama model"]
node_postgres[("PostgreSQL")]

node_user -->|"uses"| node_auth_ui
node_user -->|"submits vitals"| node_risk_ui
node_user -->|"uploads report"| node_report_ui
node_user -->|"views health"| node_dashboard_ui
node_user -->|"asks questions"| node_assistant_ui
node_user -->|"sets profile"| node_profile_ui
node_auth_ui -->|"sends credentials"| node_auth_route
node_risk_ui -->|"posts vitals"| node_predict_route
node_report_ui -->|"uploads file"| node_reports_route
node_dashboard_ui -->|"requests dashboard"| node_records_route
node_assistant_ui -->|"sends chat"| node_chat_route
node_profile_ui -.->|"provides profile facts"| node_assistant_ui
node_auth_route -->|"delegates"| node_auth_service
node_predict_route -->|"delegates"| node_prediction_service
node_reports_route -->|"analyzes report"| node_report_service
node_records_route -->|"aggregates records"| node_history_service
node_chat_route -->|"delegates"| node_chat_service
node_prediction_service -->|"runs inference"| node_ml
node_prediction_service -.->|"creates insights"| node_insight_service
node_report_service -->|"extracts biomarkers"| node_ocr
node_chat_service -->|"requests reply"| node_ollama
node_auth_service -->|"reads and writes users"| node_db_access
node_chat_service -->|"loads health context"| node_db_access
node_prediction_service -->|"stores health record"| node_db_access
node_report_service -->|"stores extraction"| node_db_access
node_history_service -.->|"reads dashboard data"| node_db_access
node_db_access -->|"uses client"| node_prisma_client
node_prisma_client -->|"builds queries"| node_prisma_builder
node_prisma_client -->|"dispatches queries"| node_prisma_engine
node_prisma_engine -.->|"queries database"| node_postgres

click node_auth_ui "https://github.com/prxnesh/glucox/blob/main/frontend/features/auth/auth-form.tsx"
click node_risk_ui "https://github.com/prxnesh/glucox/blob/main/frontend/features/predict/risk-assessment-form.tsx"
click node_report_ui "https://github.com/prxnesh/glucox/blob/main/frontend/features/reports/report-uploader.tsx"
click node_dashboard_ui "https://github.com/prxnesh/glucox/blob/main/frontend/features/dashboard/dashboard-view.tsx"
click node_assistant_ui "https://github.com/prxnesh/glucox/blob/main/frontend/features/assistant/health-assistant-view.tsx"
click node_profile_ui "https://github.com/prxnesh/glucox/blob/main/frontend/features/advanced/advanced-view.tsx"
click node_auth_route "https://github.com/prxnesh/glucox/blob/main/backend/app/api/routes/auth.py"
click node_predict_route "https://github.com/prxnesh/glucox/blob/main/backend/app/api/routes/predict.py"
click node_reports_route "https://github.com/prxnesh/glucox/blob/main/backend/app/api/routes/reports.py"
click node_records_route "https://github.com/prxnesh/glucox/blob/main/backend/app/api/routes/records.py"
click node_chat_route "https://github.com/prxnesh/glucox/blob/main/backend/app/api/routes/chat.py"
click node_auth_service "https://github.com/prxnesh/glucox/blob/main/backend/app/services/auth_service.py"
click node_prediction_service "https://github.com/prxnesh/glucox/blob/main/backend/app/services/prediction_service.py"
click node_report_service "https://github.com/prxnesh/glucox/blob/main/backend/app/services/report_service.py"
click node_history_service "https://github.com/prxnesh/glucox/blob/main/backend/app/services/history_service.py"
click node_chat_service "https://github.com/prxnesh/glucox/blob/main/backend/app/services/chat_service.py"
click node_insight_service "https://github.com/prxnesh/glucox/blob/main/backend/app/services/insight_service.py"
click node_ml "https://github.com/prxnesh/glucox/blob/main/backend/app/ml/training.py"
click node_ocr "https://github.com/prxnesh/glucox/blob/main/backend/app/ocr/extractor.py"
click node_db_access "https://github.com/prxnesh/glucox/blob/main/backend/app/utils/database.py"
click node_prisma_client "https://github.com/prxnesh/glucox/blob/main/backend/app/prisma_client/client.py"
click node_prisma_builder "https://github.com/prxnesh/glucox/blob/main/backend/app/prisma_client/_builder.py"
click node_prisma_engine "https://github.com/prxnesh/glucox/blob/main/backend/app/prisma_client/engine/_query.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_auth_ui,node_risk_ui,node_report_ui,node_dashboard_ui,node_assistant_ui,node_profile_ui,node_user toneBlue
class node_auth_route,node_predict_route,node_reports_route,node_records_route,node_chat_route,node_postgres toneAmber
class node_auth_service,node_prediction_service,node_report_service,node_history_service,node_chat_service,node_insight_service toneMint
class node_ml,node_ocr toneRose
class node_db_access,node_prisma_client,node_prisma_builder,node_prisma_engine,node_ollama toneIndigo
```

## Components

### Health experience

- [Auth UI](https://github.com/prxnesh/glucox/blob/main/frontend/features/auth/auth-form.tsx): `frontend/features/auth/auth-form.tsx`
- [Risk assessment](https://github.com/prxnesh/glucox/blob/main/frontend/features/predict/risk-assessment-form.tsx): `frontend/features/predict/risk-assessment-form.tsx`
- [Report upload](https://github.com/prxnesh/glucox/blob/main/frontend/features/reports/report-uploader.tsx): `frontend/features/reports/report-uploader.tsx`
- [Dashboard and history](https://github.com/prxnesh/glucox/blob/main/frontend/features/dashboard/dashboard-view.tsx): `frontend/features/dashboard/dashboard-view.tsx`
- [Health assistant](https://github.com/prxnesh/glucox/blob/main/frontend/features/assistant/health-assistant-view.tsx): `frontend/features/assistant/health-assistant-view.tsx`
- [Lifestyle profile](https://github.com/prxnesh/glucox/blob/main/frontend/features/advanced/advanced-view.tsx): `frontend/features/advanced/advanced-view.tsx`

### API routes

- [Auth routes](https://github.com/prxnesh/glucox/blob/main/backend/app/api/routes/auth.py): `backend/app/api/routes/auth.py`
- [Prediction route](https://github.com/prxnesh/glucox/blob/main/backend/app/api/routes/predict.py): `backend/app/api/routes/predict.py`
- [Reports route](https://github.com/prxnesh/glucox/blob/main/backend/app/api/routes/reports.py): `backend/app/api/routes/reports.py`
- [Records route](https://github.com/prxnesh/glucox/blob/main/backend/app/api/routes/records.py): `backend/app/api/routes/records.py`
- [Chat route](https://github.com/prxnesh/glucox/blob/main/backend/app/api/routes/chat.py): `backend/app/api/routes/chat.py`

### Domain services

- [Auth service](https://github.com/prxnesh/glucox/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [Prediction service](https://github.com/prxnesh/glucox/blob/main/backend/app/services/prediction_service.py): `backend/app/services/prediction_service.py`
- [Report service](https://github.com/prxnesh/glucox/blob/main/backend/app/services/report_service.py): `backend/app/services/report_service.py`
- [History service](https://github.com/prxnesh/glucox/blob/main/backend/app/services/history_service.py): `backend/app/services/history_service.py`
- [Chat service](https://github.com/prxnesh/glucox/blob/main/backend/app/services/chat_service.py): `backend/app/services/chat_service.py`
- [Insights and explanations](https://github.com/prxnesh/glucox/blob/main/backend/app/services/insight_service.py): `backend/app/services/insight_service.py`

### Analysis engines

- [ML training and inference](https://github.com/prxnesh/glucox/blob/main/backend/app/ml/training.py): `backend/app/ml/training.py`
- [OCR extraction](https://github.com/prxnesh/glucox/blob/main/backend/app/ocr/extractor.py): `backend/app/ocr/extractor.py`

### Persistence and context

- [Database access](https://github.com/prxnesh/glucox/blob/main/backend/app/utils/database.py): `backend/app/utils/database.py`
- [Prisma client](https://github.com/prxnesh/glucox/blob/main/backend/app/prisma_client/client.py): `backend/app/prisma_client/client.py`
- [Query builder](https://github.com/prxnesh/glucox/blob/main/backend/app/prisma_client/_builder.py): `backend/app/prisma_client/_builder.py`
- [Query engine](https://github.com/prxnesh/glucox/blob/main/backend/app/prisma_client/engine/_query.py): `backend/app/prisma_client/engine/_query.py`

### Other components

- **User**
- **Ollama model**
- **PostgreSQL**

## Connections

- User → Auth UI: uses (evidence: `README.md`)
- User → Risk assessment: submits vitals (evidence: `README.md`)
- User → Report upload: uploads report (evidence: `README.md`)
- User → Dashboard and history: views health (evidence: `README.md`)
- User → Health assistant: asks questions (evidence: `README.md`)
- User → Lifestyle profile: sets profile (evidence: `README.md`)
- Auth UI → Auth routes: sends credentials (evidence: `README.md`)
- Risk assessment → Prediction route: posts vitals (evidence: `README.md`)
- Report upload → Reports route: uploads file (evidence: `README.md`)
- Dashboard and history → Records route: requests dashboard (evidence: `README.md`)
- Health assistant → Chat route: sends chat (evidence: `README.md`)
- Lifestyle profile → Health assistant: provides profile facts (evidence: `README.md`)
- Auth routes → Auth service: delegates (evidence: `backend/app/api/routes/auth.py`)
- Prediction route → Prediction service: delegates (evidence: `backend/app/api/routes/predict.py`)
- Reports route → Report service: analyzes report (evidence: `README.md`)
- Records route → History service: aggregates records (evidence: `backend/app/api/routes/records.py`)
- Chat route → Chat service: delegates (evidence: `backend/app/api/routes/chat.py`)
- Prediction service → ML training and inference: runs inference (evidence: `README.md`)
- Prediction service → Insights and explanations: creates insights (evidence: `README.md`)
- Report service → OCR extraction: extracts biomarkers (evidence: `README.md`)
- Chat service → Ollama model: requests reply (evidence: `README.md`)
- Auth service → Database access: reads and writes users (evidence: `backend/app/services/auth_service.py`)
- Chat service → Database access: loads health context (evidence: `README.md`)
- Prediction service → Database access: stores health record (evidence: `README.md`)
- Report service → Database access: stores extraction (evidence: `README.md`)
- History service → Database access: reads dashboard data (evidence: `README.md`)
- Database access → Prisma client: uses client (evidence: `backend/app/utils/database.py`)
- Prisma client → Query builder: builds queries (evidence: `backend/app/prisma_client/client.py`)
- Prisma client → Query engine: dispatches queries (evidence: `backend/app/prisma_client/engine/_query.py`)
- Query engine → PostgreSQL: queries database (evidence: `README.md`)
