# mark-costin/thesis-draft-1 architecture

> Architecture diagram of the GitHub repository mark-costin/thesis-draft-1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mark-costin/thesis-draft-1
- Repository: https://github.com/mark-costin/thesis-draft-1

## Overview

This is a clinical platform with a Streamlit interface and Flask API. Its main user journey is role-based login, then patient intake and risk assessment or clinician review and consultation; administrators manage accounts. The API gateway mounts authentication, doctor, admin, prediction, and health endpoints, with ORM-backed persistence and shared security controls. The README describes longitudinal CDSS and clinical reporting, but the sampled excerpts do not establish their full runtime wiring; those capabilities are represented without asserting unsupported calls. The graph focuses on product runtime, not sample or test files.

Main entry points: [`backend/rest.py`](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/rest.py) (REST gateway), [`backend/routes/auth0.py`](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/auth0.py) (Authentication), [`frontend/views/docpage.py`](https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/docpage.py) (Clinician workspace), [`backend/routes/admin.py`](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/admin.py) (Admin endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Clinical workspaces"]
  node_streamlit["Workspace router<br/>[main.py]"]
  node_login["Login and signup<br/>[login.py]"]
  node_patient_view["Patient portal<br/>[patientpage.py]"]
  node_doctor_view["Clinician workspace<br/>[docpage.py]"]
  node_admin_view["Admin portal<br/>[adminpage.py]"]
  node_styles["Workspace styling<br/>[styles.py]"]
  node_api_client["API client<br/>[api_client.py]"]
end

subgraph group_api["API gateway"]
  node_gateway["REST gateway<br/>[rest.py]"]
  node_auth["Authentication<br/>[auth0.py]"]
  node_doctor_routes["Doctor endpoints<br/>[doctor.py]"]
  node_admin_routes["Admin endpoints<br/>[admin.py]"]
  node_prediction_routes["Risk inference endpoints<br/>[predictions.py]"]
  node_health_routes["Health diagnostics<br/>[health.py]"]
end

subgraph group_security["Identity and safeguards"]
  node_rbac["Role authorization<br/>[rbac.py]"]
  node_idempotency["Replay protection<br/>[idempotency.py]"]
  node_sanitizer["Response sanitization<br/>[sanitizer.py]"]
  node_security_headers["Security headers<br/>[security.py]"]
end

subgraph group_clinical["Clinical services"]
  node_cdss["CDSS engine<br/>[cdss_engine.py]"]
  node_clinic["Clinical records<br/>[clinic_orm.py]"]
  node_baseline["Baseline records<br/>[baseline_orm.py]"]
  node_clinical_vector["Clinical vectors<br/>[clinical_vector.py]"]
end

subgraph group_persistence["Data layer"]
  node_db[("SQLAlchemy connection<br/>[dbconnect.py]")]
  node_users[("User accounts<br/>[usr_orm.py]")]
  node_patients[("Patient profiles<br/>[pat_orm.py]")]
  node_doctors[("Doctor profiles<br/>[doc_orm.py]")]
  node_admins[("Admin profiles<br/>[adm_orm.py]")]
end

node_user(("Platform user"))

node_user -->|"uses"| node_streamlit
node_streamlit -->|"routes to"| node_login
node_streamlit -->|"routes to"| node_patient_view
node_streamlit -->|"routes to"| node_doctor_view
node_streamlit -->|"routes to"| node_admin_view
node_patient_view -->|"uses"| node_styles
node_doctor_view -->|"uses"| node_styles
node_user -->|"submits credentials"| node_login
node_login -.->|"requests authentication"| node_api_client
node_patient_view -.->|"requests assessment"| node_api_client
node_doctor_view -.->|"requests clinical data"| node_api_client
node_admin_view -.->|"requests administration"| node_api_client
node_api_client -.->|"calls API"| node_gateway
node_gateway -->|"registers"| node_auth
node_gateway -->|"registers"| node_doctor_routes
node_gateway -->|"registers"| node_admin_routes
node_gateway -->|"registers"| node_prediction_routes
node_gateway -->|"registers"| node_health_routes
node_gateway -->|"initializes"| node_security_headers
node_auth -->|"queries and updates"| node_users
node_auth -->|"creates and reads"| node_patients
node_auth -->|"reads profiles"| node_doctors
node_auth -->|"reads profiles"| node_admins
node_auth -->|"protects logout"| node_rbac
node_auth -->|"sanitizes output"| node_sanitizer
node_doctor_routes -->|"protects routes"| node_rbac
node_doctor_routes -->|"guards consultation"| node_idempotency
node_doctor_routes -->|"reads records"| node_patients
node_doctor_routes -->|"sanitizes output"| node_sanitizer
node_admin_routes -->|"protects routes"| node_rbac
node_admin_routes -->|"guards provisioning"| node_idempotency
node_admin_routes -->|"queries accounts"| node_users
node_admin_routes -->|"provisions clinicians"| node_doctors
node_admin_routes -->|"sanitizes output"| node_sanitizer
node_prediction_routes -->|"protects inference"| node_rbac
node_prediction_routes -->|"sanitizes output"| node_sanitizer
node_health_routes -->|"checks connectivity"| node_db
node_health_routes -->|"tests replay guard"| node_idempotency
node_db -->|"backs ORM models"| node_users
node_db -->|"backs ORM models"| node_patients
node_db -->|"backs ORM models"| node_doctors
node_db -->|"backs ORM models"| node_admins
node_db -->|"provides raw connection"| node_idempotency
node_doctor_view -.->|"supports CDSS workflow"| node_cdss
node_doctor_view -.->|"supports clinical records"| node_clinic
node_doctor_view -.->|"supports longitudinal baseline"| node_baseline
node_cdss -.->|"uses vectors"| node_clinical_vector

click node_streamlit "https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/main.py"
click node_login "https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/login.py"
click node_patient_view "https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/patientpage.py"
click node_doctor_view "https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/docpage.py"
click node_admin_view "https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/adminpage.py"
click node_styles "https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/styles.py"
click node_api_client "https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/api_client.py"
click node_gateway "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/rest.py"
click node_auth "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/auth0.py"
click node_doctor_routes "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/doctor.py"
click node_admin_routes "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/admin.py"
click node_prediction_routes "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/predictions.py"
click node_health_routes "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/health.py"
click node_rbac "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/middleware/rbac.py"
click node_idempotency "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/middleware/idempotency.py"
click node_sanitizer "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/middleware/sanitizer.py"
click node_security_headers "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/middleware/security.py"
click node_cdss "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/cdss_engine.py"
click node_clinic "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/clinic_orm.py"
click node_baseline "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/baseline_orm.py"
click node_clinical_vector "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/clinical_vector.py"
click node_db "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/dbconnect.py"
click node_users "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/usr_orm.py"
click node_patients "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/pat_orm.py"
click node_doctors "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/doc_orm.py"
click node_admins "https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/adm_orm.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_login,node_patient_view,node_doctor_view,node_admin_view,node_styles,node_api_client,node_user toneBlue
class node_gateway,node_auth,node_doctor_routes,node_admin_routes,node_prediction_routes,node_health_routes toneAmber
class node_rbac,node_idempotency,node_sanitizer,node_security_headers toneMint
class node_cdss,node_clinic,node_baseline,node_clinical_vector toneRose
class node_db,node_users,node_patients,node_doctors,node_admins toneIndigo
```

## Components

### Clinical workspaces

- [Workspace router](https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/main.py): `frontend/main.py`
- [Login and signup](https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/login.py): `frontend/views/login.py`
- [Patient portal](https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/patientpage.py): `frontend/views/patientpage.py`
- [Clinician workspace](https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/docpage.py): `frontend/views/docpage.py`
- [Admin portal](https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/adminpage.py): `frontend/views/adminpage.py`
- [Workspace styling](https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/views/styles.py): `frontend/views/styles.py`
- [API client](https://github.com/mark-costin/thesis-draft-1/blob/main/frontend/api_client.py): `frontend/api_client.py`

### API gateway

- [REST gateway](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/rest.py): `backend/rest.py`
- [Authentication](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/auth0.py): `backend/routes/auth0.py`
- [Doctor endpoints](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/doctor.py): `backend/routes/doctor.py`
- [Admin endpoints](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/admin.py): `backend/routes/admin.py`
- [Risk inference endpoints](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/predictions.py): `backend/routes/predictions.py`
- [Health diagnostics](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/routes/health.py): `backend/routes/health.py`

### Identity and safeguards

- [Role authorization](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/middleware/rbac.py): `backend/middleware/rbac.py`
- [Replay protection](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/middleware/idempotency.py): `backend/middleware/idempotency.py`
- [Response sanitization](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/middleware/sanitizer.py): `backend/middleware/sanitizer.py`
- [Security headers](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/middleware/security.py): `backend/middleware/security.py`

### Clinical services

- [CDSS engine](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/cdss_engine.py): `backend/model_orm/cdss_engine.py`
- [Clinical records](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/clinic_orm.py): `backend/model_orm/clinic_orm.py`
- [Baseline records](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/baseline_orm.py): `backend/model_orm/baseline_orm.py`
- [Clinical vectors](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/clinical_vector.py): `backend/model_orm/clinical_vector.py`

### Data layer

- [SQLAlchemy connection](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/dbconnect.py): `backend/dbconnect.py`
- [User accounts](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/usr_orm.py): `backend/model_orm/usr_orm.py`
- [Patient profiles](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/pat_orm.py): `backend/model_orm/pat_orm.py`
- [Doctor profiles](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/doc_orm.py): `backend/model_orm/doc_orm.py`
- [Admin profiles](https://github.com/mark-costin/thesis-draft-1/blob/main/backend/model_orm/adm_orm.py): `backend/model_orm/adm_orm.py`

### Other components

- **Platform user**

## Connections

- Platform user → Workspace router: uses (evidence: `README.md`)
- Workspace router → Login and signup: routes to (evidence: `README.md`)
- Workspace router → Patient portal: routes to (evidence: `README.md`)
- Workspace router → Clinician workspace: routes to (evidence: `README.md`)
- Workspace router → Admin portal: routes to (evidence: `README.md`)
- Patient portal → Workspace styling: uses (evidence: `README.md`)
- Clinician workspace → Workspace styling: uses (evidence: `frontend/views/docpage.py`)
- Platform user → Login and signup: submits credentials (evidence: `README.md`)
- Login and signup → API client: requests authentication
- Patient portal → API client: requests assessment
- Clinician workspace → API client: requests clinical data
- Admin portal → API client: requests administration
- API client → REST gateway: calls API
- REST gateway → Authentication: registers (evidence: `backend/rest.py`)
- REST gateway → Doctor endpoints: registers (evidence: `backend/rest.py`)
- REST gateway → Admin endpoints: registers (evidence: `backend/rest.py`)
- REST gateway → Risk inference endpoints: registers (evidence: `backend/rest.py`)
- REST gateway → Health diagnostics: registers (evidence: `backend/rest.py`)
- REST gateway → Security headers: initializes (evidence: `backend/rest.py`)
- Authentication → User accounts: queries and updates (evidence: `backend/routes/auth0.py`)
- Authentication → Patient profiles: creates and reads (evidence: `backend/routes/auth0.py`)
- Authentication → Doctor profiles: reads profiles (evidence: `backend/routes/auth0.py`)
- Authentication → Admin profiles: reads profiles (evidence: `backend/routes/auth0.py`)
- Authentication → Role authorization: protects logout (evidence: `backend/routes/auth0.py`)
- Authentication → Response sanitization: sanitizes output (evidence: `backend/routes/auth0.py`)
- Doctor endpoints → Role authorization: protects routes (evidence: `backend/routes/doctor.py`)
- Doctor endpoints → Replay protection: guards consultation (evidence: `backend/routes/doctor.py`)
- Doctor endpoints → Patient profiles: reads records (evidence: `backend/routes/doctor.py`)
- Doctor endpoints → Response sanitization: sanitizes output (evidence: `backend/routes/doctor.py`)
- Admin endpoints → Role authorization: protects routes (evidence: `backend/routes/admin.py`)
- Admin endpoints → Replay protection: guards provisioning (evidence: `backend/routes/admin.py`)
- Admin endpoints → User accounts: queries accounts (evidence: `backend/routes/admin.py`)
- Admin endpoints → Doctor profiles: provisions clinicians (evidence: `backend/routes/admin.py`)
- Admin endpoints → Response sanitization: sanitizes output (evidence: `backend/routes/admin.py`)
- Risk inference endpoints → Role authorization: protects inference (evidence: `backend/routes/predictions.py`)
- Risk inference endpoints → Response sanitization: sanitizes output (evidence: `backend/routes/predictions.py`)
- Health diagnostics → SQLAlchemy connection: checks connectivity (evidence: `backend/routes/health.py`)
- Health diagnostics → Replay protection: tests replay guard (evidence: `backend/routes/health.py`)
- SQLAlchemy connection → User accounts: backs ORM models (evidence: `backend/model_orm/usr_orm.py`)
- SQLAlchemy connection → Patient profiles: backs ORM models (evidence: `backend/model_orm/pat_orm.py`)
- SQLAlchemy connection → Doctor profiles: backs ORM models (evidence: `backend/model_orm/doc_orm.py`)
- SQLAlchemy connection → Admin profiles: backs ORM models (evidence: `backend/model_orm/adm_orm.py`)
- SQLAlchemy connection → Replay protection: provides raw connection (evidence: `backend/middleware/idempotency.py`)
- Clinician workspace → CDSS engine: supports CDSS workflow (evidence: `README.md`)
- Clinician workspace → Clinical records: supports clinical records (evidence: `README.md`)
- Clinician workspace → Baseline records: supports longitudinal baseline (evidence: `README.md`)
- CDSS engine → Clinical vectors: uses vectors
