# niranjan20069019-pixel/oncolens_ai architecture

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

- Interactive diagram: https://gitdiagram.com/niranjan20069019-pixel/oncolens_ai
- Repository: https://github.com/niranjan20069019-pixel/oncolens_ai

## Overview

OncoLens AI supports clinical oncology imaging workflows: users authenticate, submit scans, receive model classifications and Grad-CAM explanations, and access saved history and reports. The documented Streamlit dashboard and API are represented alongside the React frontend present in the tree; their runtime linkage is not established by the sampled excerpts. The prediction pipeline exposes validation, preprocessing, inference, explainability, and persistence stages. Edges are limited to calls shown in excerpts, SOURCE INDEX references, or README statements; unsampled feature links are omitted where evidence is insufficient.

Main entry points: [`app/api`](https://github.com/niranjan20069019-pixel/oncolens_ai/tree/main/app/api) (API routes), [`app/services/prediction_service.py`](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/services/prediction_service.py) (Prediction pipeline), [`app/frontend/api_client.py`](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/frontend/api_client.py) (Dashboard API client), [`app/main.py`](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User interfaces"]
  node_streamlit["Clinical dashboard"]
  node_react["Web frontend"]
  node_api_client["Dashboard API client<br/>[api_client.py]"]
end

subgraph group_api["API and access"]
  node_app["FastAPI application<br/>[main.py]"]
  node_routes["API routes"]
  node_auth["Authentication<br/>[auth.py]"]
  node_access["JWT access control"]
  node_schemas["Request and result schemas<br/>[schemas.py]"]
  node_predict_route["Prediction endpoint<br/>[predict.py]"]
  node_history_route["History endpoint<br/>[history.py]"]
  node_ws_route["Progress WebSocket<br/>[websocket.py]"]
  node_health["Health checks<br/>[health.py]"]
  node_settings["Configuration<br/>[config.py]"]
end

subgraph group_analysis["Imaging analysis"]
  node_preprocess["Image preprocessing<br/>[preprocessor.py]"]
  node_dicom["DICOM loading<br/>[dicom_loader.py]"]
  node_inference["Tumor classifier<br/>[inference.py]"]
  node_gradcam["Grad-CAM explainability<br/>[gradcam.py]"]
end

subgraph group_services["Clinical services"]
  node_pipeline["Prediction pipeline"]
  node_analytics["Clinical analytics<br/>[analytics.py]"]
  node_reports["PDF reports<br/>[report_service.py]"]
  node_progress["Progress hub<br/>[progress_hub.py]"]
end

subgraph group_persistence["Persistence"]
  node_store[("Clinical records<br/>[models.py]")]
  node_crud["Record operations<br/>[crud.py]"]
  node_session["Database sessions<br/>[session.py]"]
end

node_clinician(("Clinician / patient"))

node_clinician -.->|"uses"| node_streamlit
node_clinician -.->|"uses"| node_react
node_streamlit -.->|"calls"| node_api_client
node_api_client -.->|"HTTP requests"| node_app
node_app -->|"registers"| node_routes
node_routes -->|"registers"| node_auth
node_routes -->|"registers"| node_predict_route
node_routes -->|"registers"| node_history_route
node_routes -->|"registers"| node_ws_route
node_routes -->|"registers"| node_health
node_auth -->|"authenticates"| node_access
node_access -->|"looks up users"| node_crud
node_crud -->|"reads and writes"| node_store
node_app -->|"initializes"| node_session
node_session -->|"creates schema"| node_store
node_predict_route -->|"runs"| node_pipeline
node_predict_route -->|"checks access"| node_access
node_pipeline -.->|"preprocesses via"| node_preprocess
node_preprocess -->|"loads via"| node_dicom
node_pipeline -->|"runs"| node_inference
node_inference -->|"preprocesses with"| node_preprocess
node_inference -->|"generates map"| node_gradcam
node_pipeline -->|"builds payload"| node_analytics
node_pipeline -->|"saves scan"| node_crud
node_pipeline -->|"emits stages"| node_progress
node_ws_route -->|"streams updates"| node_progress
node_history_route -->|"queries history"| node_crud
node_api_client -->|"subscribes"| node_ws_route
node_api_client -.->|"fetches history"| node_history_route
node_api_client -.->|"downloads PDF"| node_reports
node_health -->|"checks model"| node_inference
node_app -->|"configures"| node_settings
node_inference -->|"loads settings"| node_settings
node_react -.->|"API integration"| node_app

click node_streamlit "https://github.com/niranjan20069019-pixel/oncolens_ai/tree/main/app/frontend"
click node_react "https://github.com/niranjan20069019-pixel/oncolens_ai/tree/main/frontend/src"
click node_api_client "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/frontend/api_client.py"
click node_app "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/main.py"
click node_routes "https://github.com/niranjan20069019-pixel/oncolens_ai/tree/main/app/api"
click node_auth "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/api/v1/auth.py"
click node_access "https://github.com/niranjan20069019-pixel/oncolens_ai/tree/main/app/auth"
click node_schemas "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/models/schemas.py"
click node_predict_route "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/api/v1/predict.py"
click node_history_route "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/api/v1/history.py"
click node_ws_route "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/api/v1/websocket.py"
click node_health "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/api/v1/health.py"
click node_pipeline "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/services/prediction_service.py"
click node_preprocess "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/ml/preprocessor.py"
click node_dicom "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/ml/dicom_loader.py"
click node_inference "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/ml/inference.py"
click node_gradcam "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/ml/gradcam.py"
click node_analytics "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/services/analytics.py"
click node_reports "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/services/report_service.py"
click node_progress "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/services/progress_hub.py"
click node_store "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/database/models.py"
click node_crud "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/database/crud.py"
click node_session "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/database/session.py"
click node_settings "https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/utils/config.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_streamlit,node_react,node_api_client toneBlue
class node_app,node_routes,node_auth,node_access,node_schemas,node_predict_route,node_history_route,node_ws_route,node_health,node_settings toneAmber
class node_preprocess,node_dicom,node_inference,node_gradcam toneMint
class node_pipeline,node_analytics,node_reports,node_progress toneRose
class node_store,node_crud,node_session,node_clinician toneIndigo
```

## Components

### User interfaces

- [Clinical dashboard](https://github.com/niranjan20069019-pixel/oncolens_ai/tree/main/app/frontend): `app/frontend`
- [Web frontend](https://github.com/niranjan20069019-pixel/oncolens_ai/tree/main/frontend/src): `frontend/src`
- [Dashboard API client](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/frontend/api_client.py): `app/frontend/api_client.py`

### API and access

- [FastAPI application](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/main.py): `app/main.py`
- [API routes](https://github.com/niranjan20069019-pixel/oncolens_ai/tree/main/app/api): `app/api`
- [Authentication](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/api/v1/auth.py): `app/api/v1/auth.py`
- [JWT access control](https://github.com/niranjan20069019-pixel/oncolens_ai/tree/main/app/auth): `app/auth`
- [Request and result schemas](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/models/schemas.py): `app/models/schemas.py`
- [Prediction endpoint](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/api/v1/predict.py): `app/api/v1/predict.py`
- [History endpoint](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/api/v1/history.py): `app/api/v1/history.py`
- [Progress WebSocket](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/api/v1/websocket.py): `app/api/v1/websocket.py`
- [Health checks](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/api/v1/health.py): `app/api/v1/health.py`
- [Configuration](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/utils/config.py): `app/utils/config.py`

### Imaging analysis

- [Image preprocessing](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/ml/preprocessor.py): `app/ml/preprocessor.py`
- [DICOM loading](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/ml/dicom_loader.py): `app/ml/dicom_loader.py`
- [Tumor classifier](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/ml/inference.py): `app/ml/inference.py`
- [Grad-CAM explainability](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/ml/gradcam.py): `app/ml/gradcam.py`

### Clinical services

- [Prediction pipeline](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/services/prediction_service.py): `app/services/prediction_service.py`
- [Clinical analytics](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/services/analytics.py): `app/services/analytics.py`
- [PDF reports](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/services/report_service.py): `app/services/report_service.py`
- [Progress hub](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/services/progress_hub.py): `app/services/progress_hub.py`

### Persistence

- [Clinical records](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/database/models.py): `app/database/models.py`
- [Record operations](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/database/crud.py): `app/database/crud.py`
- [Database sessions](https://github.com/niranjan20069019-pixel/oncolens_ai/blob/main/app/database/session.py): `app/database/session.py`

### Other components

- **Clinician / patient**

## Connections

- Clinician / patient → Clinical dashboard: uses (evidence: `README.md`)
- Clinician / patient → Web frontend: uses
- Clinical dashboard → Dashboard API client: calls (evidence: `app/frontend/pages/doctor_workspace.py`)
- Dashboard API client → FastAPI application: HTTP requests (evidence: `app/frontend/api_client.py`)
- FastAPI application → API routes: registers (evidence: `app/main.py`)
- API routes → Authentication: registers (evidence: `app/api/router.py`)
- API routes → Prediction endpoint: registers (evidence: `app/api/router.py`)
- API routes → History endpoint: registers (evidence: `app/api/router.py`)
- API routes → Progress WebSocket: registers (evidence: `app/api/router.py`)
- API routes → Health checks: registers (evidence: `app/api/router.py`)
- Authentication → JWT access control: authenticates (evidence: `app/api/v1/auth.py`)
- JWT access control → Record operations: looks up users (evidence: `app/auth/dependencies.py`)
- Record operations → Clinical records: reads and writes (evidence: `app/database/crud.py`)
- FastAPI application → Database sessions: initializes (evidence: `app/main.py`)
- Database sessions → Clinical records: creates schema (evidence: `app/database/session.py`)
- Prediction endpoint → Prediction pipeline: runs (evidence: `app/api/v1/predict.py`)
- Prediction endpoint → JWT access control: checks access (evidence: `app/api/v1/predict.py`)
- Prediction pipeline → Image preprocessing: preprocesses via
- Image preprocessing → DICOM loading: loads via (evidence: `app/ml/preprocessor.py`)
- Prediction pipeline → Tumor classifier: runs (evidence: `app/services/prediction_service.py`)
- Tumor classifier → Image preprocessing: preprocesses with (evidence: `app/ml/inference.py`)
- Tumor classifier → Grad-CAM explainability: generates map (evidence: `app/ml/inference.py`)
- Prediction pipeline → Clinical analytics: builds payload (evidence: `app/services/prediction_service.py`)
- Prediction pipeline → Record operations: saves scan (evidence: `app/services/prediction_service.py`)
- Prediction pipeline → Progress hub: emits stages (evidence: `app/services/prediction_service.py`)
- Progress WebSocket → Progress hub: streams updates (evidence: `app/api/v1/websocket.py`)
- History endpoint → Record operations: queries history (evidence: `app/api/v1/history.py`)
- Dashboard API client → Progress WebSocket: subscribes (evidence: `app/frontend/api_client.py`)
- Dashboard API client → History endpoint: fetches history
- Dashboard API client → PDF reports: downloads PDF
- Health checks → Tumor classifier: checks model (evidence: `app/api/v1/health.py`)
- FastAPI application → Configuration: configures (evidence: `app/main.py`)
- Tumor classifier → Configuration: loads settings (evidence: `app/ml/inference.py`)
- Web frontend → FastAPI application: API integration
