# itsbk13/cts_project architecture

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

- Interactive diagram: https://gitdiagram.com/itsbk13/cts_project
- Repository: https://github.com/itsbk13/cts_project

## Overview

Patient Journey Intelligence is a hospital-facing patient access and drop-off analytics product. Hospital staff use its web interface to inspect patient journeys, cohorts, funnels, leakage, risk, survival, and SHAP explanations; backend processing builds journey features and serves analytics and risk results, with assistant capabilities for recommendations and contextual questions. The excerpts show registration calling the auth service and backend connections to preprocessing, validation, onboarding, and Databricks. Frontend-to-backend analytics wiring and several storage paths are not shown, so those links are omitted.

Main entry points: [`backend/main.py`](https://github.com/itsbk13/cts_project/blob/main/backend/main.py) (FastAPI application), [`backend/onboard_hospital.py`](https://github.com/itsbk13/cts_project/blob/main/backend/onboard_hospital.py) (Hospital onboarding), [`frontend/src/app/register/page.tsx`](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/register/page.tsx) (Account registration), [`backend/schemas.py`](https://github.com/itsbk13/cts_project/blob/main/backend/schemas.py) (Request schemas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
end

subgraph group_journey["Journey analytics"]
  node_overview["Journey overview<br/>[page.tsx]"]
  node_cohorts["Cohort analysis<br/>[page.tsx]"]
  node_funnel["Journey funnel<br/>[page.tsx]"]
  node_journey_event["Event journeys<br/>[page.tsx]"]
  node_leakage["Leakage analysis<br/>[page.tsx]"]
end

subgraph group_risk["Risk and assistance"]
  node_patients["Patient records<br/>[page.tsx]"]
  node_patient_detail["Patient detail<br/>[page.tsx]"]
  node_patient_register["Patient intake<br/>[page.tsx]"]
  node_risk_page["Risk analysis<br/>[page.tsx]"]
  node_shap["SHAP explanations<br/>[page.tsx]"]
  node_survival["Survival analysis<br/>[page.tsx]"]
  node_ai["AI assistant<br/>[page.tsx]"]
end

subgraph group_backend["Backend services"]
  node_api["FastAPI application<br/>[main.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
  node_validation["Input validation<br/>[validation.py]"]
  node_preprocessing["Journey preprocessing<br/>[preprocessing.py]"]
  node_onboarding["Hospital onboarding"]
  node_recommendation["Risk recommendations"]
  node_chatbot["Contextual chat<br/>[chatbot.py]"]
  node_database[("SQL database setup<br/>[database.py]")]
end

subgraph group_identity["Identity and onboarding"]
  node_register["Account registration<br/>[page.tsx]"]
  node_login["Sign in<br/>[page.tsx]"]
  node_authapi["Auth API client<br/>[authApi.ts]"]
end

node_staff(("Hospital staff"))
node_databricks[("Databricks")]

node_staff -->|"registers"| node_register
node_register -->|"calls"| node_authapi
node_staff -->|"signs in"| node_login
node_api -->|"imports"| node_schemas
node_api -->|"imports"| node_validation
node_api -->|"imports"| node_preprocessing
node_api -->|"imports"| node_recommendation
node_api -->|"imports"| node_chatbot
node_api -->|"calls"| node_onboarding
node_api -->|"requests predictions"| node_databricks
node_onboarding -->|"creates schema"| node_databricks

click node_register "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/register/page.tsx"
click node_login "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/login/page.tsx"
click node_authapi "https://github.com/itsbk13/cts_project/blob/main/frontend/src/services/authApi.ts"
click node_overview "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/page.tsx"
click node_cohorts "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/cohorts/page.tsx"
click node_funnel "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/funnel/page.tsx"
click node_journey_event "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/journey/event/page.tsx"
click node_leakage "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/leakage/page.tsx"
click node_patients "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/patients/page.tsx"
click node_patient_detail "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/patients/%5BpatientId%5D/page.tsx"
click node_patient_register "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/patients/register/page.tsx"
click node_risk_page "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/risk/page.tsx"
click node_shap "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/shap/page.tsx"
click node_survival "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/survival/page.tsx"
click node_ai "https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/ai/page.tsx"
click node_api "https://github.com/itsbk13/cts_project/blob/main/backend/main.py"
click node_schemas "https://github.com/itsbk13/cts_project/blob/main/backend/schemas.py"
click node_validation "https://github.com/itsbk13/cts_project/blob/main/backend/validation.py"
click node_preprocessing "https://github.com/itsbk13/cts_project/blob/main/backend/src/preprocessing.py"
click node_onboarding "https://github.com/itsbk13/cts_project/blob/main/backend/onboard_hospital.py"
click node_recommendation "https://github.com/itsbk13/cts_project/blob/main/backend/llm_recommendation.py"
click node_chatbot "https://github.com/itsbk13/cts_project/blob/main/backend/chatbot.py"
click node_database "https://github.com/itsbk13/cts_project/blob/main/backend/database.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_overview,node_cohorts,node_funnel,node_journey_event,node_leakage,node_databricks toneAmber
class node_patients,node_patient_detail,node_patient_register,node_risk_page,node_shap,node_survival,node_ai toneMint
class node_api,node_schemas,node_validation,node_preprocessing,node_onboarding,node_recommendation,node_chatbot,node_database toneRose
class node_register,node_login,node_authapi,node_staff toneIndigo
```

## Components

### Journey analytics

- [Journey overview](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Cohort analysis](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/cohorts/page.tsx): `frontend/src/app/cohorts/page.tsx`
- [Journey funnel](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/funnel/page.tsx): `frontend/src/app/funnel/page.tsx`
- [Event journeys](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/journey/event/page.tsx): `frontend/src/app/journey/event/page.tsx`
- [Leakage analysis](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/leakage/page.tsx): `frontend/src/app/leakage/page.tsx`

### Risk and assistance

- [Patient records](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/patients/page.tsx): `frontend/src/app/patients/page.tsx`
- [Patient detail](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/patients/%5BpatientId%5D/page.tsx): `frontend/src/app/patients/[patientId]/page.tsx`
- [Patient intake](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/patients/register/page.tsx): `frontend/src/app/patients/register/page.tsx`
- [Risk analysis](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/risk/page.tsx): `frontend/src/app/risk/page.tsx`
- [SHAP explanations](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/shap/page.tsx): `frontend/src/app/shap/page.tsx`
- [Survival analysis](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/survival/page.tsx): `frontend/src/app/survival/page.tsx`
- [AI assistant](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/ai/page.tsx): `frontend/src/app/ai/page.tsx`

### Backend services

- [FastAPI application](https://github.com/itsbk13/cts_project/blob/main/backend/main.py): `backend/main.py`
- [Request schemas](https://github.com/itsbk13/cts_project/blob/main/backend/schemas.py): `backend/schemas.py`
- [Input validation](https://github.com/itsbk13/cts_project/blob/main/backend/validation.py): `backend/validation.py`
- [Journey preprocessing](https://github.com/itsbk13/cts_project/blob/main/backend/src/preprocessing.py): `backend/src/preprocessing.py`
- [Hospital onboarding](https://github.com/itsbk13/cts_project/blob/main/backend/onboard_hospital.py): `backend/onboard_hospital.py`
- [Risk recommendations](https://github.com/itsbk13/cts_project/blob/main/backend/llm_recommendation.py): `backend/llm_recommendation.py`
- [Contextual chat](https://github.com/itsbk13/cts_project/blob/main/backend/chatbot.py): `backend/chatbot.py`
- [SQL database setup](https://github.com/itsbk13/cts_project/blob/main/backend/database.py): `backend/database.py`

### Identity and onboarding

- [Account registration](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/register/page.tsx): `frontend/src/app/register/page.tsx`
- [Sign in](https://github.com/itsbk13/cts_project/blob/main/frontend/src/app/login/page.tsx): `frontend/src/app/login/page.tsx`
- [Auth API client](https://github.com/itsbk13/cts_project/blob/main/frontend/src/services/authApi.ts): `frontend/src/services/authApi.ts`

### Other components

- **Hospital staff**
- **Databricks**

## Connections

- Hospital staff → Account registration: registers (evidence: `frontend/src/app/register/page.tsx`)
- Account registration → Auth API client: calls (evidence: `frontend/src/app/register/page.tsx`)
- Hospital staff → Sign in: signs in (evidence: `frontend/src/app/login/page.tsx`)
- FastAPI application → Request schemas: imports (evidence: `backend/main.py`)
- FastAPI application → Input validation: imports (evidence: `backend/main.py`)
- FastAPI application → Journey preprocessing: imports (evidence: `backend/main.py`)
- FastAPI application → Risk recommendations: imports (evidence: `backend/main.py`)
- FastAPI application → Contextual chat: imports (evidence: `backend/main.py`)
- FastAPI application → Hospital onboarding: calls (evidence: `backend/main.py`)
- FastAPI application → Databricks: requests predictions (evidence: `backend/main.py`)
- Hospital onboarding → Databricks: creates schema (evidence: `backend/onboard_hospital.py`)
