# grishmitha-123/hospital architecture

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

- Interactive diagram: https://gitdiagram.com/grishmitha-123/hospital
- Repository: https://github.com/grishmitha-123/hospital

## Overview

MediCare AI is a hospital-operations decision-support platform: users view forecasts and patient-risk estimates, then explore what-if scenarios and resource-allocation recommendations. The React client calls a FastAPI backend, whose domain services produce forecasts and risk scores and whose simulation and optimization paths calculate and explain allocations. PostgreSQL stores operational and run records. The README documents dashboard, patient, forecast, simulation, and optimization capabilities; sampled-source evidence is strongest for startup wiring, client requests, and scenario execution, so some endpoint-to-service links rely on README documentation.

Main entry points: [`backend/app/api/scenarios.py`](https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/scenarios.py) (Scenario and optimization endpoints), [`backend/app/main.py`](https://github.com/grishmitha-123/hospital/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/api/dashboard.py`](https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/dashboard.py) (Dashboard and resources), [`backend/app/simulation/engine.py`](https://github.com/grishmitha-123/hospital/blob/main/backend/app/simulation/engine.py) (What-if simulation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_react["React application<br/>[main.jsx]"]
  node_client["API client<br/>[client.js]"]
end

subgraph group_api["API"]
  node_app["FastAPI application<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_dashboard["Dashboard and resources<br/>[dashboard.py]"]
  node_patients["Patient endpoints<br/>[patients.py]"]
  node_forecast_api["Forecast endpoints<br/>[forecast.py]"]
  node_scenario_api["Scenario and optimization endpoints<br/>[scenarios.py]"]
end

subgraph group_inference["Prediction"]
  node_risk["Deterioration risk scoring<br/>[risk_service.py]"]
  node_forecast["Demand forecasting"]
end

subgraph group_decision["Decision support"]
  node_state["Operational state and demand<br/>[state_service.py]"]
  node_simulation["What-if simulation<br/>[engine.py]"]
  node_solver["Resource allocation solver<br/>[solver.py]"]
  node_explanation["Recommendations and explanations<br/>[explanation.py]"]
end

subgraph group_storage["Persistence"]
  node_models["Operational and result models<br/>[models.py]"]
  node_session["Database session<br/>[session.py]"]
  node_postgres[("PostgreSQL")]
end

node_operator(("Hospital operator"))

node_operator -->|"uses"| node_react
node_react -->|"requests through"| node_client
node_client -->|"calls API"| node_app
node_app -->|"registers router"| node_auth
node_app -->|"registers router"| node_dashboard
node_app -->|"registers router"| node_patients
node_app -->|"registers router"| node_forecast_api
node_app -->|"registers router"| node_scenario_api
node_auth -->|"issues token for"| node_client
node_dashboard -->|"reports risk summary"| node_risk
node_dashboard -->|"reports demand forecast"| node_forecast
node_patients -->|"serves risk scores"| node_risk
node_forecast_api -->|"serves forecasts"| node_forecast
node_scenario_api -->|"loads state and demand"| node_state
node_scenario_api -->|"runs scenario"| node_simulation
node_scenario_api -->|"runs allocation"| node_solver
node_simulation -->|"solves allocation"| node_solver
node_simulation -->|"builds explanation"| node_explanation
node_scenario_api -->|"builds recommendations"| node_explanation
node_scenario_api -->|"stores run records"| node_models
node_scenario_api -->|"uses database session"| node_session
node_session -->|"connects to"| node_postgres
node_models -->|"persists records"| node_postgres

click node_react "https://github.com/grishmitha-123/hospital/blob/main/medicare-ai-frontend/src/main.jsx"
click node_client "https://github.com/grishmitha-123/hospital/blob/main/medicare-ai-frontend/src/api/client.js"
click node_app "https://github.com/grishmitha-123/hospital/blob/main/backend/app/main.py"
click node_auth "https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/auth.py"
click node_dashboard "https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/dashboard.py"
click node_patients "https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/patients.py"
click node_forecast_api "https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/forecast.py"
click node_scenario_api "https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/scenarios.py"
click node_risk "https://github.com/grishmitha-123/hospital/blob/main/backend/app/services/risk_service.py"
click node_forecast "https://github.com/grishmitha-123/hospital/blob/main/backend/app/services/forecast_service.py"
click node_state "https://github.com/grishmitha-123/hospital/blob/main/backend/app/services/state_service.py"
click node_simulation "https://github.com/grishmitha-123/hospital/blob/main/backend/app/simulation/engine.py"
click node_solver "https://github.com/grishmitha-123/hospital/blob/main/backend/app/optimization/solver.py"
click node_explanation "https://github.com/grishmitha-123/hospital/blob/main/backend/app/optimization/explanation.py"
click node_models "https://github.com/grishmitha-123/hospital/blob/main/backend/app/database/models.py"
click node_session "https://github.com/grishmitha-123/hospital/blob/main/backend/app/database/session.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_react,node_client toneBlue
class node_app,node_auth,node_dashboard,node_patients,node_forecast_api,node_scenario_api toneAmber
class node_risk,node_forecast toneMint
class node_state,node_simulation,node_solver,node_explanation toneRose
class node_models,node_session,node_postgres,node_operator toneIndigo
```

## Components

### Frontend

- [React application](https://github.com/grishmitha-123/hospital/blob/main/medicare-ai-frontend/src/main.jsx): `medicare-ai-frontend/src/main.jsx`
- [API client](https://github.com/grishmitha-123/hospital/blob/main/medicare-ai-frontend/src/api/client.js): `medicare-ai-frontend/src/api/client.js`

### API

- [FastAPI application](https://github.com/grishmitha-123/hospital/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Dashboard and resources](https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/dashboard.py): `backend/app/api/dashboard.py`
- [Patient endpoints](https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/patients.py): `backend/app/api/patients.py`
- [Forecast endpoints](https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/forecast.py): `backend/app/api/forecast.py`
- [Scenario and optimization endpoints](https://github.com/grishmitha-123/hospital/blob/main/backend/app/api/scenarios.py): `backend/app/api/scenarios.py`

### Prediction

- [Deterioration risk scoring](https://github.com/grishmitha-123/hospital/blob/main/backend/app/services/risk_service.py): `backend/app/services/risk_service.py`
- [Demand forecasting](https://github.com/grishmitha-123/hospital/blob/main/backend/app/services/forecast_service.py): `backend/app/services/forecast_service.py`

### Decision support

- [Operational state and demand](https://github.com/grishmitha-123/hospital/blob/main/backend/app/services/state_service.py): `backend/app/services/state_service.py`
- [What-if simulation](https://github.com/grishmitha-123/hospital/blob/main/backend/app/simulation/engine.py): `backend/app/simulation/engine.py`
- [Resource allocation solver](https://github.com/grishmitha-123/hospital/blob/main/backend/app/optimization/solver.py): `backend/app/optimization/solver.py`
- [Recommendations and explanations](https://github.com/grishmitha-123/hospital/blob/main/backend/app/optimization/explanation.py): `backend/app/optimization/explanation.py`

### Persistence

- [Operational and result models](https://github.com/grishmitha-123/hospital/blob/main/backend/app/database/models.py): `backend/app/database/models.py`
- [Database session](https://github.com/grishmitha-123/hospital/blob/main/backend/app/database/session.py): `backend/app/database/session.py`
- **PostgreSQL**

### Other components

- **Hospital operator**

## Connections

- Hospital operator → React application: uses (evidence: `README.md`)
- React application → API client: requests through (evidence: `medicare-ai-frontend/src/api/client.js`)
- API client → FastAPI application: calls API (evidence: `medicare-ai-frontend/src/api/client.js`)
- FastAPI application → Authentication: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Dashboard and resources: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Patient endpoints: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Forecast endpoints: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Scenario and optimization endpoints: registers router (evidence: `backend/app/main.py`)
- Authentication → API client: issues token for (evidence: `README.md`)
- Dashboard and resources → Deterioration risk scoring: reports risk summary (evidence: `README.md`)
- Dashboard and resources → Demand forecasting: reports demand forecast (evidence: `README.md`)
- Patient endpoints → Deterioration risk scoring: serves risk scores (evidence: `README.md`)
- Forecast endpoints → Demand forecasting: serves forecasts (evidence: `README.md`)
- Scenario and optimization endpoints → Operational state and demand: loads state and demand (evidence: `backend/app/api/scenarios.py`)
- Scenario and optimization endpoints → What-if simulation: runs scenario (evidence: `backend/app/api/scenarios.py`)
- Scenario and optimization endpoints → Resource allocation solver: runs allocation (evidence: `backend/app/api/scenarios.py`)
- What-if simulation → Resource allocation solver: solves allocation (evidence: `backend/app/simulation/engine.py`)
- What-if simulation → Recommendations and explanations: builds explanation (evidence: `backend/app/simulation/engine.py`)
- Scenario and optimization endpoints → Recommendations and explanations: builds recommendations (evidence: `backend/app/api/scenarios.py`)
- Scenario and optimization endpoints → Operational and result models: stores run records (evidence: `backend/app/api/scenarios.py`)
- Scenario and optimization endpoints → Database session: uses database session (evidence: `backend/app/api/scenarios.py`)
- Database session → PostgreSQL: connects to (evidence: `backend/app/database/session.py`)
- Operational and result models → PostgreSQL: persists records (evidence: `README.md`)
