# josepcal/tfm_rehab_followup_checkup architecture

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

- Interactive diagram: https://gitdiagram.com/josepcal/tfm_rehab_followup_checkup
- Repository: https://github.com/josepcal/tfm_rehab_followup_checkup

## Overview

FTM is a clinical rehabilitation follow-up platform: professionals manage patient diagnoses and exercise programs; patients consent and submit recordings; asynchronous analysis produces metrics for clinical reports and check-ups. The map combines the README’s documented workflow and architecture with source-index references and sampled excerpts. Several routers and the worker were not sampled, so their internal calls are not expanded beyond documented relationships.

Main entry points: [`web/src/App.tsx`](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/App.tsx) (Role-based SPA), [`api/app/recording/router.py`](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/recording/router.py) (Recording endpoints), [`api/app/worker.py`](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/worker.py) (Analysis worker), [`api/app/db.py`](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/db.py) (Clinical PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Role-based SPA<br/>[App.tsx]"]
  node_authclient["Web authentication<br/>[authClient.ts]"]
  node_clinicalworkspace["Clinical workspace"]
  node_patientportal["Patient portal<br/>[PatientPortal.tsx]"]
  node_featureapi["Feature API facade<br/>[api.ts]"]
  node_httpclient["HTTP client<br/>[http.ts]"]
end

subgraph group_clinical["Clinical workflows"]
  node_diagnostics["Diagnosis and programs"]
  node_catalog["Exercise catalog<br/>[router.py]"]
  node_consent["Consent management<br/>[consent_router.py]"]
  node_reports["Exercise reports<br/>[router.py]"]
  node_followups["Follow-up check-ups<br/>[router.py]"]
end

subgraph group_analysis["Recording analysis"]
  node_recordings["Recording endpoints<br/>[router.py]"]
  node_worker["Analysis worker<br/>[worker.py]"]
  node_metrics[("Metrics results<br/>[models.py]")]
end

subgraph group_platform["Identity and persistence"]
  node_database[("Clinical PostgreSQL<br/>[db.py]")]
  node_storage[("Recording storage<br/>[storage.py]")]
  node_keycloak["Keycloak"]
end

subgraph group_oversight["Privacy and oversight"]
  node_audit["Audit and data rights<br/>[router.py]"]
  node_ai["AI payload design<br/>[payload_service.py]"]
end

node_professional(("Clinician"))
node_patient(("Patient"))

node_professional -->|"uses"| node_app
node_patient -->|"uses"| node_app
node_app -->|"initializes"| node_authclient
node_app -->|"renders"| node_clinicalworkspace
node_app -->|"renders"| node_patientportal
node_clinicalworkspace -->|"uses"| node_featureapi
node_patientportal -.->|"uses"| node_featureapi
node_featureapi -.->|"uses"| node_httpclient
node_authclient -->|"authenticates"| node_keycloak
node_app -->|"requests"| node_diagnostics
node_patient -->|"grants consent"| node_consent
node_professional -->|"manages diagnosis"| node_diagnostics
node_diagnostics -->|"configures exercises"| node_catalog
node_patient -->|"submits recording"| node_recordings
node_recordings -->|"stores audio"| node_storage
node_recordings -->|"queues analysis"| node_worker
node_worker -->|"downloads audio"| node_storage
node_worker -->|"persists results"| node_metrics
node_professional -->|"creates reports"| node_reports
node_professional -->|"creates check-ups"| node_followups
node_reports -->|"links reports"| node_followups
node_diagnostics -->|"persists clinical data"| node_database
node_recordings -->|"registers recordings"| node_database
node_worker -->|"consumes jobs"| node_database
node_metrics -->|"stored in"| node_database
node_audit -->|"records and reads"| node_database
node_professional -->|"reviews events"| node_audit
node_patient -->|"requests data rights"| node_audit
node_recordings -->|"checks consent"| node_consent
node_worker -.->|"generates insights"| node_ai

click node_app "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/App.tsx"
click node_authclient "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/auth/authClient.ts"
click node_clinicalworkspace "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/features/diagnostics/DiagnosticWorkspace.tsx"
click node_patientportal "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/features/patient/PatientPortal.tsx"
click node_featureapi "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/features/diagnostics/api.ts"
click node_httpclient "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/api/http.ts"
click node_diagnostics "https://github.com/josepcal/tfm_rehab_followup_checkup/tree/main/api/app/clinical"
click node_catalog "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/catalog/router.py"
click node_consent "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/clinical/consent_router.py"
click node_recordings "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/recording/router.py"
click node_worker "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/worker.py"
click node_metrics "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/metrics/models.py"
click node_reports "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/reporting/router.py"
click node_followups "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/followup/router.py"
click node_database "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/db.py"
click node_storage "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/storage.py"
click node_audit "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/iam/router.py"
click node_ai "https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/ai/payload_service.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_app,node_authclient,node_clinicalworkspace,node_patientportal,node_featureapi,node_httpclient toneBlue
class node_diagnostics,node_catalog,node_consent,node_reports,node_followups toneAmber
class node_recordings,node_worker,node_metrics toneMint
class node_database,node_storage,node_keycloak toneRose
class node_audit,node_ai,node_professional,node_patient toneIndigo
```

## Components

### Web application

- [Role-based SPA](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [Web authentication](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/auth/authClient.ts): `web/src/auth/authClient.ts`
- [Clinical workspace](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/features/diagnostics/DiagnosticWorkspace.tsx): `web/src/features/diagnostics/DiagnosticWorkspace.tsx`
- [Patient portal](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/features/patient/PatientPortal.tsx): `web/src/features/patient/PatientPortal.tsx`
- [Feature API facade](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/features/diagnostics/api.ts): `web/src/features/diagnostics/api.ts`
- [HTTP client](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/web/src/api/http.ts): `web/src/api/http.ts`

### Clinical workflows

- [Diagnosis and programs](https://github.com/josepcal/tfm_rehab_followup_checkup/tree/main/api/app/clinical): `api/app/clinical`
- [Exercise catalog](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/catalog/router.py): `api/app/catalog/router.py`
- [Consent management](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/clinical/consent_router.py): `api/app/clinical/consent_router.py`
- [Exercise reports](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/reporting/router.py): `api/app/reporting/router.py`
- [Follow-up check-ups](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/followup/router.py): `api/app/followup/router.py`

### Recording analysis

- [Recording endpoints](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/recording/router.py): `api/app/recording/router.py`
- [Analysis worker](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/worker.py): `api/app/worker.py`
- [Metrics results](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/metrics/models.py): `api/app/metrics/models.py`

### Identity and persistence

- [Clinical PostgreSQL](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/db.py): `api/app/db.py`
- [Recording storage](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/storage.py): `api/app/storage.py`
- **Keycloak**

### Privacy and oversight

- [Audit and data rights](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/iam/router.py): `api/app/iam/router.py`
- [AI payload design](https://github.com/josepcal/tfm_rehab_followup_checkup/blob/main/api/app/ai/payload_service.py): `api/app/ai/payload_service.py`

### Other components

- **Clinician**
- **Patient**

## Connections

- Clinician → Role-based SPA: uses (evidence: `README.md`)
- Patient → Role-based SPA: uses (evidence: `README.md`)
- Role-based SPA → Web authentication: initializes (evidence: `web/src/App.tsx`)
- Role-based SPA → Clinical workspace: renders (evidence: `web/src/App.tsx`)
- Role-based SPA → Patient portal: renders (evidence: `web/src/App.tsx`)
- Clinical workspace → Feature API facade: uses (evidence: `web/src/features/diagnostics/DiagnosticWorkspace.tsx`)
- Patient portal → Feature API facade: uses
- Feature API facade → HTTP client: uses
- Web authentication → Keycloak: authenticates (evidence: `README.md`)
- Role-based SPA → Diagnosis and programs: requests (evidence: `web/src/App.tsx`)
- Patient → Consent management: grants consent (evidence: `README.md`)
- Clinician → Diagnosis and programs: manages diagnosis (evidence: `README.md`)
- Diagnosis and programs → Exercise catalog: configures exercises (evidence: `README.md`)
- Patient → Recording endpoints: submits recording (evidence: `README.md`)
- Recording endpoints → Recording storage: stores audio (evidence: `README.md`)
- Recording endpoints → Analysis worker: queues analysis (evidence: `README.md`)
- Analysis worker → Recording storage: downloads audio (evidence: `README.md`)
- Analysis worker → Metrics results: persists results (evidence: `README.md`)
- Clinician → Exercise reports: creates reports (evidence: `README.md`)
- Clinician → Follow-up check-ups: creates check-ups (evidence: `README.md`)
- Exercise reports → Follow-up check-ups: links reports (evidence: `api/app/followup/router.py`)
- Diagnosis and programs → Clinical PostgreSQL: persists clinical data (evidence: `README.md`)
- Recording endpoints → Clinical PostgreSQL: registers recordings (evidence: `README.md`)
- Analysis worker → Clinical PostgreSQL: consumes jobs (evidence: `README.md`)
- Metrics results → Clinical PostgreSQL: stored in (evidence: `api/app/metrics/models.py`)
- Audit and data rights → Clinical PostgreSQL: records and reads (evidence: `api/app/iam/router.py`)
- Clinician → Audit and data rights: reviews events (evidence: `README.md`)
- Patient → Audit and data rights: requests data rights (evidence: `api/app/iam/router.py`)
- Recording endpoints → Consent management: checks consent (evidence: `api/app/recording/router.py`)
- Analysis worker → AI payload design: generates insights
