# candela-app/candela architecture

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

- Interactive diagram: https://gitdiagram.com/candela-app/candela
- Repository: https://github.com/candela-app/candela

## Overview

Candela is a multi-platform cognitive and vision-therapy product: patients play configurable therapy games, while clinicians review progress and administrators manage organizations and users. The repository also provides account and DocID linking workflows, persisted session analytics, announcements, and a gaze-tracking service. The README documents the shared backend and shared package across apps; source excerpts show selected API-to-service and service-to-storage calls. Many screens and game implementations are indexed but unsampled, so their internal wiring is not asserted.

Main entry points: [`apps/candela-app/src/app`](https://github.com/candela-app/candela/tree/develop/apps/candela-app/src/app) (Web experience), [`apps/candela-mobile/app`](https://github.com/candela-app/candela/tree/develop/apps/candela-mobile/app) (Mobile experience), [`packages/shared/src/game-session.ts`](https://github.com/candela-app/candela/blob/develop/packages/shared/src/game-session.ts) (Session processing), [`apps/candela-mobile/src/games`](https://github.com/candela-app/candela/tree/develop/apps/candela-mobile/src/games) (Mobile therapy games)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Patient and clinician apps"]
  node_web["Web experience"]
  node_mobile["Mobile experience"]
  node_doctor["Doctor workflows"]
  node_admin["Organization admin"]
end

subgraph group_therapy["Therapy and analytics"]
  node_webgames["Web therapy games"]
  node_mobilegames["Mobile therapy games"]
  node_registry["Game catalog<br/>[game-registry.ts]"]
  node_gameplay["Game logic<br/>[game-logic.ts]"]
  node_sessionmetrics["Session metrics<br/>[session-metrics.ts]"]
  node_sessionmodel["Session processing<br/>[game-session.ts]"]
end

subgraph group_backend["Shared backend"]
  node_gameapi["Session API"]
  node_gameservice["Session service"]
  node_database[("Relational database")]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_docid["DocID linking<br/>[docid.service.ts]"]
  node_adminapi["Organization API"]
  node_announcements["Announcements"]
end

subgraph group_vision["Gaze tracking"]
  node_cvservice["Gaze tracking service<br/>[main.py]"]
  node_gazetracker["Gaze tracker<br/>[gaze_tracker.py]"]
end

node_patient(("Patient or clinician"))

node_patient -->|"uses"| node_web
node_patient -->|"uses"| node_mobile
node_web -.->|"offers games"| node_webgames
node_mobile -.->|"offers games"| node_mobilegames
node_webgames -.->|"uses catalog"| node_registry
node_mobilegames -->|"uses catalog"| node_registry
node_mobilegames -.->|"uses logic"| node_gameplay
node_sessionmodel -->|"validates modules"| node_registry
node_sessionmodel -->|"computes metrics"| node_sessionmetrics
node_web -->|"shares code"| node_sessionmodel
node_mobile -->|"shares code"| node_sessionmodel
node_web -->|"calls backend"| node_gameapi
node_mobile -->|"calls backend"| node_gameapi
node_gameapi -->|"dispatches"| node_gameservice
node_gameservice -->|"reads and writes"| node_database
node_doctor -.->|"reviews progress"| node_web
node_admin -->|"manages organizations"| node_adminapi
node_adminapi -.->|"serves admin UI"| node_web
node_web -.->|"uses DocID"| node_docid
node_mobile -.->|"uses DocID"| node_docid
node_web -.->|"authenticates"| node_auth
node_mobile -.->|"authenticates"| node_auth
node_web -.->|"uses announcements"| node_announcements
node_cvservice -->|"processes frames"| node_gazetracker

click node_web "https://github.com/candela-app/candela/tree/develop/apps/candela-app/src/app"
click node_mobile "https://github.com/candela-app/candela/tree/develop/apps/candela-mobile/app"
click node_webgames "https://github.com/candela-app/candela/tree/develop/apps/candela-app/src/components"
click node_mobilegames "https://github.com/candela-app/candela/tree/develop/apps/candela-mobile/src/games"
click node_registry "https://github.com/candela-app/candela/blob/develop/packages/shared/src/game-registry.ts"
click node_gameplay "https://github.com/candela-app/candela/blob/develop/packages/shared/src/game-logic.ts"
click node_sessionmetrics "https://github.com/candela-app/candela/blob/develop/packages/shared/src/session-metrics.ts"
click node_sessionmodel "https://github.com/candela-app/candela/blob/develop/packages/shared/src/game-session.ts"
click node_gameapi "https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/game-sessions/game-sessions.controller.ts"
click node_gameservice "https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/game-sessions/game-sessions.service.ts"
click node_database "https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/entities/game-session.entity.ts"
click node_auth "https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/auth/auth.service.ts"
click node_docid "https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/docid/docid.service.ts"
click node_doctor "https://github.com/candela-app/candela/tree/develop/apps/candela-app/src/app/doctor"
click node_admin "https://github.com/candela-app/candela/tree/develop/apps/candela-app/src/app/super-admin"
click node_adminapi "https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/super-admin/super-admin.controller.ts"
click node_announcements "https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/announcements/announcements.controller.ts"
click node_cvservice "https://github.com/candela-app/candela/blob/develop/apps/candela-cv/main.py"
click node_gazetracker "https://github.com/candela-app/candela/blob/develop/apps/candela-cv/gaze_tracker.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_web,node_mobile,node_doctor,node_admin toneBlue
class node_webgames,node_mobilegames,node_registry,node_gameplay,node_sessionmetrics,node_sessionmodel toneAmber
class node_gameapi,node_gameservice,node_database,node_auth,node_docid,node_adminapi,node_announcements toneMint
class node_cvservice,node_gazetracker toneRose
class node_patient toneIndigo
```

## Components

### Patient and clinician apps

- [Web experience](https://github.com/candela-app/candela/tree/develop/apps/candela-app/src/app): `apps/candela-app/src/app`
- [Mobile experience](https://github.com/candela-app/candela/tree/develop/apps/candela-mobile/app): `apps/candela-mobile/app`
- [Doctor workflows](https://github.com/candela-app/candela/tree/develop/apps/candela-app/src/app/doctor): `apps/candela-app/src/app/doctor`
- [Organization admin](https://github.com/candela-app/candela/tree/develop/apps/candela-app/src/app/super-admin): `apps/candela-app/src/app/super-admin`

### Therapy and analytics

- [Web therapy games](https://github.com/candela-app/candela/tree/develop/apps/candela-app/src/components): `apps/candela-app/src/components`
- [Mobile therapy games](https://github.com/candela-app/candela/tree/develop/apps/candela-mobile/src/games): `apps/candela-mobile/src/games`
- [Game catalog](https://github.com/candela-app/candela/blob/develop/packages/shared/src/game-registry.ts): `packages/shared/src/game-registry.ts`
- [Game logic](https://github.com/candela-app/candela/blob/develop/packages/shared/src/game-logic.ts): `packages/shared/src/game-logic.ts`
- [Session metrics](https://github.com/candela-app/candela/blob/develop/packages/shared/src/session-metrics.ts): `packages/shared/src/session-metrics.ts`
- [Session processing](https://github.com/candela-app/candela/blob/develop/packages/shared/src/game-session.ts): `packages/shared/src/game-session.ts`

### Shared backend

- [Session API](https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/game-sessions/game-sessions.controller.ts): `apps/candela-backend/src/game-sessions/game-sessions.controller.ts`
- [Session service](https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/game-sessions/game-sessions.service.ts): `apps/candela-backend/src/game-sessions/game-sessions.service.ts`
- [Relational database](https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/entities/game-session.entity.ts): `apps/candela-backend/src/entities/game-session.entity.ts`
- [Authentication](https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/auth/auth.service.ts): `apps/candela-backend/src/auth/auth.service.ts`
- [DocID linking](https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/docid/docid.service.ts): `apps/candela-backend/src/docid/docid.service.ts`
- [Organization API](https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/super-admin/super-admin.controller.ts): `apps/candela-backend/src/super-admin/super-admin.controller.ts`
- [Announcements](https://github.com/candela-app/candela/blob/develop/apps/candela-backend/src/announcements/announcements.controller.ts): `apps/candela-backend/src/announcements/announcements.controller.ts`

### Gaze tracking

- [Gaze tracking service](https://github.com/candela-app/candela/blob/develop/apps/candela-cv/main.py): `apps/candela-cv/main.py`
- [Gaze tracker](https://github.com/candela-app/candela/blob/develop/apps/candela-cv/gaze_tracker.py): `apps/candela-cv/gaze_tracker.py`

### Other components

- **Patient or clinician**

## Connections

- Patient or clinician → Web experience: uses (evidence: `README.md`)
- Patient or clinician → Mobile experience: uses (evidence: `README.md`)
- Web experience → Web therapy games: offers games
- Mobile experience → Mobile therapy games: offers games
- Web therapy games → Game catalog: uses catalog
- Mobile therapy games → Game catalog: uses catalog (evidence: `apps/candela-mobile/src/games/NumberSearchGame.tsx`)
- Mobile therapy games → Game logic: uses logic
- Session processing → Game catalog: validates modules (evidence: `packages/shared/src/game-session.ts`)
- Session processing → Session metrics: computes metrics (evidence: `packages/shared/src/game-session.ts`)
- Web experience → Session processing: shares code (evidence: `README.md`)
- Mobile experience → Session processing: shares code (evidence: `README.md`)
- Web experience → Session API: calls backend (evidence: `README.md`)
- Mobile experience → Session API: calls backend (evidence: `README.md`)
- Session API → Session service: dispatches
- Session service → Relational database: reads and writes (evidence: `apps/candela-backend/src/game-sessions/game-sessions.service.ts`)
- Doctor workflows → Web experience: reviews progress
- Organization admin → Organization API: manages organizations (evidence: `apps/candela-backend/src/super-admin/super-admin.controller.ts`)
- Organization API → Web experience: serves admin UI
- Web experience → DocID linking: uses DocID
- Mobile experience → DocID linking: uses DocID
- Web experience → Authentication: authenticates
- Mobile experience → Authentication: authenticates
- Web experience → Announcements: uses announcements
- Gaze tracking service → Gaze tracker: processes frames (evidence: `apps/candela-cv/main.py`)
