# reddysridharkb/brain-tumor-detection architecture

> Architecture diagram of the GitHub repository reddysridharkb/brain-tumor-detection, 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/reddysridharkb/brain-tumor-detection
- Repository: https://github.com/reddysridharkb/brain-tumor-detection

## Overview

NeuroAI is a clinical MRI tumor-analysis application: staff or patients sign in, manage patient records, upload scans, review AI-assisted findings and progression, and produce clinical reports. The backend separates API routes, scan/AI processing, patient services, and persistence; the Next.js frontend provides login, dashboard, patient, scan-analysis, and report experiences. The landing page also advertises tumor segmentation and longitudinal comparison. Several routes and integrations are listed but unsampled, so their connections are shown only as unverified where useful.

Main entry points: [`backend/app/main.py`](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/services/scan_service.py`](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/services/scan_service.py) (Scan workflow), [`backend/app/routes/auth.py`](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/auth.py) (Authentication routes), [`backend/app/models/models.py`](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/models/models.py) (Clinical models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Clinical web app"]
  node_home["Product landing<br/>[page.tsx]"]
  node_login["Sign-in<br/>[page.tsx]"]
  node_authstate["Session state<br/>[useAuthStore.ts]"]
  node_dashboard["Clinical dashboard<br/>[page.tsx]"]
  node_dashboardstate["Dashboard data"]
  node_patientlist["Patient directory<br/>[page.tsx]"]
  node_patientdetail["Patient workspace<br/>[page.tsx]"]
  node_patientstate["Patient state<br/>[usePatientStore.ts]"]
  node_upload["Scan upload<br/>[page.tsx]"]
  node_scananalysis["Scan review<br/>[page.tsx]"]
  node_scanstate["Scan state<br/>[useScanStore.ts]"]
  node_eegui["EEG scanner UI<br/>[EEGScanner.tsx]"]
  node_reportsui["Reports interface<br/>[page.tsx]"]
  node_apiclient["HTTP client<br/>[api.ts]"]
end

subgraph group_api["Backend API"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_authroutes["Authentication routes<br/>[auth.py]"]
  node_patientroutes["Patient routes<br/>[patients.py]"]
  node_scanroutes["Scan routes<br/>[scans.py]"]
  node_eegroute["EEG routes<br/>[eeg.py]"]
  node_analyticsroutes["Analytics routes<br/>[analytics.py]"]
  node_reportroutes["Report routes<br/>[reports.py]"]
end

subgraph group_analysis["Scan analysis"]
  node_scanservice["Scan workflow<br/>[scan_service.py]"]
  node_opencv["Image analysis<br/>[opencv_service.py]"]
  node_imageprocessing["Image processing"]
  node_openai["Tumor highlighting<br/>[openai_service.py]"]
  node_gemini["AI interpretation<br/>[gemini_service.py]"]
  node_charts["Analytics charts<br/>[chart_generator.py]"]
end

subgraph group_data["Clinical data"]
  node_patientservice["Patient operations<br/>[patient_service.py]"]
  node_pdf["PDF generation<br/>[pdf_generator.py]"]
  node_models[("Clinical models<br/>[models.py]")]
  node_schemas["API schemas<br/>[schemas.py]"]
  node_database[("Database sessions<br/>[database.py]")]
  node_settings["Configuration<br/>[settings.py]"]
end

node_clinician(("Clinician / patient"))

node_clinician -->|"opens"| node_home
node_clinician -.->|"signs in"| node_login
node_login -.->|"uses session"| node_authstate
node_authstate -->|"posts login"| node_apiclient
node_apiclient -.->|"HTTP requests"| node_authroutes
node_dashboard -->|"loads metrics"| node_dashboardstate
node_dashboard -.->|"requests analytics"| node_analyticsroutes
node_patientlist -.->|"manages patients"| node_patientstate
node_patientstate -->|"sends requests"| node_apiclient
node_patientroutes -.->|"delegates operations"| node_patientservice
node_patientservice -->|"queries and updates"| node_models
node_patientservice -->|"accepts patient data"| node_schemas
node_patientdetail -->|"renders scanner"| node_eegui
node_upload -.->|"submits scans"| node_scanroutes
node_scananalysis -.->|"uses scan data"| node_scanstate
node_scanroutes -.->|"dispatches scan work"| node_scanservice
node_scanservice -->|"generates highlight"| node_openai
node_scanservice -->|"requests interpretation"| node_gemini
node_scanservice -->|"persists scan"| node_models
node_scanservice -.->|"uses image analysis"| node_opencv
node_scanservice -.->|"uses processing"| node_imageprocessing
node_reportroutes -.->|"generates reports"| node_pdf
node_pdf -->|"reads scan data"| node_models
node_pdf -->|"references AI analysis"| node_gemini
node_analyticsroutes -.->|"uses chart output"| node_charts
node_authroutes -->|"gets database session"| node_database
node_authroutes -->|"queries user records"| node_models
node_database -->|"configures connection"| node_settings
node_backend -.->|"registers routes"| node_authroutes
node_backend -.->|"registers routes"| node_patientroutes
node_backend -.->|"registers routes"| node_scanroutes
node_backend -.->|"registers routes"| node_eegroute
node_backend -.->|"registers routes"| node_analyticsroutes
node_backend -.->|"registers routes"| node_reportroutes
node_reportsui -.->|"requests reports"| node_reportroutes

click node_home "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/page.tsx"
click node_login "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/login/page.tsx"
click node_authstate "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/store/useAuthStore.ts"
click node_dashboard "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/dashboard/page.tsx"
click node_dashboardstate "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/store/useDashboardStore.ts"
click node_patientlist "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/patients/page.tsx"
click node_patientdetail "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/patients/%5Bid%5D/page.tsx"
click node_patientstate "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/store/usePatientStore.ts"
click node_upload "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/upload/page.tsx"
click node_scananalysis "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/analysis/%5BscanId%5D/page.tsx"
click node_scanstate "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/store/useScanStore.ts"
click node_eegui "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/components/EEGScanner.tsx"
click node_reportsui "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/reports/page.tsx"
click node_apiclient "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/lib/api.ts"
click node_backend "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/main.py"
click node_authroutes "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/auth.py"
click node_patientroutes "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/patients.py"
click node_scanroutes "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/scans.py"
click node_eegroute "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/eeg.py"
click node_analyticsroutes "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/analytics.py"
click node_reportroutes "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/reports.py"
click node_scanservice "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/services/scan_service.py"
click node_opencv "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/ai/opencv_service.py"
click node_imageprocessing "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/ai/image_processing.py"
click node_openai "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/ai/openai_service.py"
click node_gemini "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/ai/gemini_service.py"
click node_charts "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/analytics/chart_generator.py"
click node_patientservice "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/services/patient_service.py"
click node_pdf "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/reports/pdf_generator.py"
click node_models "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/models/models.py"
click node_schemas "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/schemas/schemas.py"
click node_database "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/database/database.py"
click node_settings "https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/config/settings.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_home,node_login,node_authstate,node_dashboard,node_dashboardstate,node_patientlist,node_patientdetail,node_patientstate,node_upload,node_scananalysis,node_scanstate,node_eegui,node_reportsui,node_apiclient toneBlue
class node_backend,node_authroutes,node_patientroutes,node_scanroutes,node_eegroute,node_analyticsroutes,node_reportroutes toneAmber
class node_scanservice,node_opencv,node_imageprocessing,node_openai,node_gemini,node_charts toneMint
class node_patientservice,node_pdf,node_models,node_schemas,node_database,node_settings toneRose
class node_clinician toneIndigo
```

## Components

### Clinical web app

- [Product landing](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Sign-in](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/login/page.tsx): `frontend/src/app/login/page.tsx`
- [Session state](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/store/useAuthStore.ts): `frontend/src/store/useAuthStore.ts`
- [Clinical dashboard](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/dashboard/page.tsx): `frontend/src/app/dashboard/page.tsx`
- [Dashboard data](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/store/useDashboardStore.ts): `frontend/src/store/useDashboardStore.ts`
- [Patient directory](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/patients/page.tsx): `frontend/src/app/patients/page.tsx`
- [Patient workspace](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/patients/%5Bid%5D/page.tsx): `frontend/src/app/patients/[id]/page.tsx`
- [Patient state](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/store/usePatientStore.ts): `frontend/src/store/usePatientStore.ts`
- [Scan upload](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/upload/page.tsx): `frontend/src/app/upload/page.tsx`
- [Scan review](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/analysis/%5BscanId%5D/page.tsx): `frontend/src/app/analysis/[scanId]/page.tsx`
- [Scan state](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/store/useScanStore.ts): `frontend/src/store/useScanStore.ts`
- [EEG scanner UI](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/components/EEGScanner.tsx): `frontend/src/components/EEGScanner.tsx`
- [Reports interface](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/app/reports/page.tsx): `frontend/src/app/reports/page.tsx`
- [HTTP client](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Backend API

- [FastAPI application](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/auth.py): `backend/app/routes/auth.py`
- [Patient routes](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/patients.py): `backend/app/routes/patients.py`
- [Scan routes](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/scans.py): `backend/app/routes/scans.py`
- [EEG routes](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/eeg.py): `backend/app/routes/eeg.py`
- [Analytics routes](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/analytics.py): `backend/app/routes/analytics.py`
- [Report routes](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/routes/reports.py): `backend/app/routes/reports.py`

### Scan analysis

- [Scan workflow](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/services/scan_service.py): `backend/app/services/scan_service.py`
- [Image analysis](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/ai/opencv_service.py): `backend/app/ai/opencv_service.py`
- [Image processing](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/ai/image_processing.py): `backend/app/ai/image_processing.py`
- [Tumor highlighting](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/ai/openai_service.py): `backend/app/ai/openai_service.py`
- [AI interpretation](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/ai/gemini_service.py): `backend/app/ai/gemini_service.py`
- [Analytics charts](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/analytics/chart_generator.py): `backend/app/analytics/chart_generator.py`

### Clinical data

- [Patient operations](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/services/patient_service.py): `backend/app/services/patient_service.py`
- [PDF generation](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/reports/pdf_generator.py): `backend/app/reports/pdf_generator.py`
- [Clinical models](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/models/models.py): `backend/app/models/models.py`
- [API schemas](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/schemas/schemas.py): `backend/app/schemas/schemas.py`
- [Database sessions](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/database/database.py): `backend/app/database/database.py`
- [Configuration](https://github.com/reddysridharkb/brain-tumor-detection/blob/main/backend/app/config/settings.py): `backend/app/config/settings.py`

### Other components

- **Clinician / patient**

## Connections

- Clinician / patient → Product landing: opens (evidence: `frontend/src/app/page.tsx`)
- Clinician / patient → Sign-in: signs in
- Sign-in → Session state: uses session
- Session state → HTTP client: posts login (evidence: `frontend/src/store/useAuthStore.ts`)
- HTTP client → Authentication routes: HTTP requests
- Clinical dashboard → Dashboard data: loads metrics (evidence: `frontend/src/app/dashboard/page.tsx`)
- Clinical dashboard → Analytics routes: requests analytics
- Patient directory → Patient state: manages patients
- Patient state → HTTP client: sends requests (evidence: `frontend/src/store/usePatientStore.ts`)
- Patient routes → Patient operations: delegates operations
- Patient operations → Clinical models: queries and updates (evidence: `backend/app/services/patient_service.py`)
- Patient operations → API schemas: accepts patient data (evidence: `backend/app/services/patient_service.py`)
- Patient workspace → EEG scanner UI: renders scanner (evidence: `frontend/src/app/patients/[id]/page.tsx`)
- Scan upload → Scan routes: submits scans
- Scan review → Scan state: uses scan data
- Scan routes → Scan workflow: dispatches scan work
- Scan workflow → Tumor highlighting: generates highlight (evidence: `backend/app/services/scan_service.py`)
- Scan workflow → AI interpretation: requests interpretation (evidence: `backend/app/services/scan_service.py`)
- Scan workflow → Clinical models: persists scan (evidence: `backend/app/services/scan_service.py`)
- Scan workflow → Image analysis: uses image analysis
- Scan workflow → Image processing: uses processing
- Report routes → PDF generation: generates reports
- PDF generation → Clinical models: reads scan data (evidence: `backend/app/reports/pdf_generator.py`)
- PDF generation → AI interpretation: references AI analysis (evidence: `backend/app/reports/pdf_generator.py`)
- Analytics routes → Analytics charts: uses chart output
- Authentication routes → Database sessions: gets database session (evidence: `backend/app/routes/auth.py`)
- Authentication routes → Clinical models: queries user records (evidence: `backend/app/routes/auth.py`)
- Database sessions → Configuration: configures connection (evidence: `backend/app/database/database.py`)
- FastAPI application → Authentication routes: registers routes
- FastAPI application → Patient routes: registers routes
- FastAPI application → Scan routes: registers routes
- FastAPI application → EEG routes: registers routes
- FastAPI application → Analytics routes: registers routes
- FastAPI application → Report routes: registers routes
- Reports interface → Report routes: requests reports
