# urattems/training-app architecture

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

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

## Overview

Training App is a local-first workout log: an athlete imports a coach-supplied program, records completed sessions, then exports results for the coach to prepare the next program. Separate capabilities cover history, progress, body measurements, full backup/restore, and optional Google Drive archiving. The graph combines documented user journeys with relationships visible in the sampled source and SOURCE INDEX; unsampled feature internals and some connections are therefore omitted.

Main entry points: [`src/app/App.tsx`](https://github.com/urattems/training-app/blob/main/src/app/App.tsx) (App routes), [`src/features/workout`](https://github.com/urattems/training-app/tree/main/src/features/workout) (Workout logging), [`src/features/settings`](https://github.com/urattems/training-app/tree/main/src/features/settings) (Settings), [`src/services`](https://github.com/urattems/training-app/tree/main/src/services) (Data services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and navigation"]
  node_routes["App routes<br/>[App.tsx]"]
  node_home["Home"]
  node_start["Start guide"]
  node_settings["Settings"]
end

subgraph group_training["Programs and training"]
  node_import["Program import"]
  node_programs["Program view"]
  node_workout["Workout logging"]
  node_exercise["Exercise logging"]
  node_workout_rules["Workout rules<br/>[workout.ts]"]
end

subgraph group_tracking["Progress and tracking"]
  node_history_ui["Workout history"]
  node_progress["Progress charts"]
  node_weight["Weight tracking"]
end

subgraph group_persistence["Data and exchange"]
  node_data_hooks["Reactive data<br/>[useData.ts]"]
  node_services["Data services"]
  node_domain["Domain calculations"]
  node_database[("Local database<br/>[database.ts]")]
  node_backup["Backup and restore<br/>[exportService.ts]"]
  node_coach_export["Coach export"]
end

subgraph group_archive["Optional Drive archive"]
  node_drive_ui["Drive settings<br/>[DrivePage.tsx]"]
  node_drive_sync["Drive sync<br/>[DriveSyncAgent.tsx]"]
  node_drive_service["Drive services<br/>[driveClient.ts]"]
end

node_athlete(("Athlete"))
node_coach(("External AI coach"))
node_drive_script["User Drive script"]

node_athlete -->|"opens guide"| node_start
node_start -->|"copies prompt"| node_coach
node_athlete -->|"pastes program"| node_import
node_routes -->|"routes to"| node_home
node_routes -->|"hosts flow"| node_import
node_routes -->|"routes to"| node_programs
node_routes -->|"routes to"| node_workout
node_routes -->|"routes to"| node_history_ui
node_routes -->|"routes to"| node_settings
node_import -->|"activates program"| node_programs
node_programs -->|"starts session"| node_workout
node_workout -->|"opens exercise"| node_exercise
node_workout -->|"applies rules"| node_workout_rules
node_workout -->|"records results"| node_history_ui
node_home -->|"offers next session"| node_workout
node_history_ui -->|"reviews trends"| node_progress
node_athlete -->|"records measurements"| node_weight
node_data_hooks -->|"reads through"| node_services
node_services -->|"reads and writes"| node_database
node_services -->|"uses calculations"| node_domain
node_settings -->|"exports or restores"| node_backup
node_backup -->|"reads data"| node_database
node_settings -->|"prepares export"| node_coach_export
node_coach_export -->|"delivers results"| node_coach
node_coach -->|"returns program"| node_athlete
node_drive_ui -.->|"configures archive"| node_drive_sync
node_drive_sync -.->|"uses client"| node_drive_service
node_drive_service -.->|"sends archive"| node_drive_script

click node_routes "https://github.com/urattems/training-app/blob/main/src/app/App.tsx"
click node_home "https://github.com/urattems/training-app/tree/main/src/features/home"
click node_start "https://github.com/urattems/training-app/tree/main/src/features/start"
click node_import "https://github.com/urattems/training-app/blob/main/src/features/import/ImportProgramFlow.tsx"
click node_programs "https://github.com/urattems/training-app/tree/main/src/features/program"
click node_workout "https://github.com/urattems/training-app/tree/main/src/features/workout"
click node_exercise "https://github.com/urattems/training-app/tree/main/src/features/exercise"
click node_workout_rules "https://github.com/urattems/training-app/blob/main/src/domain/workout.ts"
click node_history_ui "https://github.com/urattems/training-app/tree/main/src/features/history"
click node_progress "https://github.com/urattems/training-app/tree/main/src/features/progress"
click node_weight "https://github.com/urattems/training-app/tree/main/src/features/weight"
click node_data_hooks "https://github.com/urattems/training-app/blob/main/src/hooks/useData.ts"
click node_services "https://github.com/urattems/training-app/tree/main/src/services"
click node_domain "https://github.com/urattems/training-app/tree/main/src/domain"
click node_database "https://github.com/urattems/training-app/blob/main/src/db/database.ts"
click node_backup "https://github.com/urattems/training-app/blob/main/src/services/exportService.ts"
click node_coach_export "https://github.com/urattems/training-app/blob/main/src/services/coachExportService.ts"
click node_settings "https://github.com/urattems/training-app/tree/main/src/features/settings"
click node_drive_ui "https://github.com/urattems/training-app/blob/main/src/features/settings/DrivePage.tsx"
click node_drive_sync "https://github.com/urattems/training-app/blob/main/src/app/DriveSyncAgent.tsx"
click node_drive_service "https://github.com/urattems/training-app/blob/main/src/services/driveClient.ts"

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_routes,node_home,node_start,node_settings,node_drive_script toneBlue
class node_import,node_programs,node_workout,node_exercise,node_workout_rules toneAmber
class node_history_ui,node_progress,node_weight toneMint
class node_data_hooks,node_services,node_domain,node_database,node_backup,node_coach_export toneRose
class node_drive_ui,node_drive_sync,node_drive_service,node_athlete,node_coach toneIndigo
```

## Components

### App and navigation

- [App routes](https://github.com/urattems/training-app/blob/main/src/app/App.tsx): `src/app/App.tsx`
- [Home](https://github.com/urattems/training-app/tree/main/src/features/home): `src/features/home`
- [Start guide](https://github.com/urattems/training-app/tree/main/src/features/start): `src/features/start`
- [Settings](https://github.com/urattems/training-app/tree/main/src/features/settings): `src/features/settings`

### Programs and training

- [Program import](https://github.com/urattems/training-app/blob/main/src/features/import/ImportProgramFlow.tsx): `src/features/import/ImportProgramFlow.tsx`
- [Program view](https://github.com/urattems/training-app/tree/main/src/features/program): `src/features/program`
- [Workout logging](https://github.com/urattems/training-app/tree/main/src/features/workout): `src/features/workout`
- [Exercise logging](https://github.com/urattems/training-app/tree/main/src/features/exercise): `src/features/exercise`
- [Workout rules](https://github.com/urattems/training-app/blob/main/src/domain/workout.ts): `src/domain/workout.ts`

### Progress and tracking

- [Workout history](https://github.com/urattems/training-app/tree/main/src/features/history): `src/features/history`
- [Progress charts](https://github.com/urattems/training-app/tree/main/src/features/progress): `src/features/progress`
- [Weight tracking](https://github.com/urattems/training-app/tree/main/src/features/weight): `src/features/weight`

### Data and exchange

- [Reactive data](https://github.com/urattems/training-app/blob/main/src/hooks/useData.ts): `src/hooks/useData.ts`
- [Data services](https://github.com/urattems/training-app/tree/main/src/services): `src/services`
- [Domain calculations](https://github.com/urattems/training-app/tree/main/src/domain): `src/domain`
- [Local database](https://github.com/urattems/training-app/blob/main/src/db/database.ts): `src/db/database.ts`
- [Backup and restore](https://github.com/urattems/training-app/blob/main/src/services/exportService.ts): `src/services/exportService.ts`
- [Coach export](https://github.com/urattems/training-app/blob/main/src/services/coachExportService.ts): `src/services/coachExportService.ts`

### Optional Drive archive

- [Drive settings](https://github.com/urattems/training-app/blob/main/src/features/settings/DrivePage.tsx): `src/features/settings/DrivePage.tsx`
- [Drive sync](https://github.com/urattems/training-app/blob/main/src/app/DriveSyncAgent.tsx): `src/app/DriveSyncAgent.tsx`
- [Drive services](https://github.com/urattems/training-app/blob/main/src/services/driveClient.ts): `src/services/driveClient.ts`

### Other components

- **Athlete**
- **External AI coach**
- **User Drive script**

## Connections

- Athlete → Start guide: opens guide (evidence: `README.md`)
- Start guide → External AI coach: copies prompt (evidence: `README.md`)
- Athlete → Program import: pastes program (evidence: `README.md`)
- App routes → Home: routes to (evidence: `src/app/App.tsx`)
- App routes → Program import: hosts flow (evidence: `src/app/App.tsx`)
- App routes → Program view: routes to (evidence: `src/app/App.tsx`)
- App routes → Workout logging: routes to (evidence: `src/app/App.tsx`)
- App routes → Workout history: routes to (evidence: `src/app/App.tsx`)
- App routes → Settings: routes to (evidence: `src/app/App.tsx`)
- Program import → Program view: activates program (evidence: `README.md`)
- Program view → Workout logging: starts session (evidence: `src/features/program/ProgramSessionPage.tsx`)
- Workout logging → Exercise logging: opens exercise (evidence: `src/app/App.tsx`)
- Workout logging → Workout rules: applies rules
- Workout logging → Workout history: records results (evidence: `README.md`)
- Home → Workout logging: offers next session (evidence: `README.md`)
- Workout history → Progress charts: reviews trends (evidence: `README.md`)
- Athlete → Weight tracking: records measurements (evidence: `README.md`)
- Reactive data → Data services: reads through (evidence: `src/hooks/useData.ts`)
- Data services → Local database: reads and writes (evidence: `src/services/workoutService.ts`)
- Data services → Domain calculations: uses calculations (evidence: `src/services/workoutService.ts`)
- Settings → Backup and restore: exports or restores (evidence: `README.md`)
- Backup and restore → Local database: reads data (evidence: `src/services/exportService.ts`)
- Settings → Coach export: prepares export (evidence: `src/features/settings/CoachExportPage.tsx`)
- Coach export → External AI coach: delivers results (evidence: `README.md`)
- External AI coach → Athlete: returns program (evidence: `README.md`)
- Drive settings → Drive sync: configures archive
- Drive sync → Drive services: uses client
- Drive services → User Drive script: sends archive (evidence: `README.md`)
