# chaseum/gymni-codered architecture

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

- Interactive diagram: https://gitdiagram.com/chaseum/gymni-codered
- Repository: https://github.com/chaseum/gymni-codered

## Overview

Gym&I is an iPhone-first fitness coach: the Pi captures video and produces movement observations, while the iPhone owns rep counting, workout state, and local history. The phone also requests cached spoken cues from a hosted ElevenLabs gateway; conversational coaching and user-confirmed memory are separate backend capabilities. The repository additionally contains a legacy laptop session server and an ML training workflow. Most links below reflect README ownership and workflow statements; implementation details for unsampled subsystems are not inferred.

Main entry points: [`ios/GymAndAIKit/Sources/GymAndAIKit/WorkoutSession.swift`](https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIKit/Sources/GymAndAIKit/WorkoutSession.swift) (Workout state), [`ios/GymAndAI/AppRootView.swift`](https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAI/AppRootView.swift) (Workout app), [`backend/gymai_backend/cloud_app.py`](https://github.com/chaseum/gymni-codered/blob/main/backend/gymai_backend/cloud_app.py) (Hosted API), [`backend/gymai_backend/gemini.py`](https://github.com/chaseum/gymni-codered/blob/main/backend/gymai_backend/gemini.py) (Gemini coach)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_phone["iPhone experience"]
  node_iosapp["Workout app<br/>[AppRootView.swift]"]
  node_onboarding["Onboarding"]
  node_workout["Workout state"]
  node_hub["Rep counting<br/>[HubSession.swift]"]
  node_journal[("Local history")]
  node_voiceclient["Voice client"]
  node_restview["Rest coaching<br/>[RestView.swift]"]
  node_watch["Watch workout"]
end

subgraph group_vision["Camera and movement"]
  node_camera["Pi camera<br/>[sources.py]"]
  node_preview["Camera preview<br/>[preview.py]"]
  node_movement["Movement analysis<br/>[pipeline.py]"]
  node_contracts["Observation protocol<br/>[protocol.md]"]
end

subgraph group_hosted["Hosted coaching"]
  node_cloud["Hosted API<br/>[cloud_app.py]"]
  node_dynamiccue["Dynamic cues<br/>[dynamic_cue.py]"]
  node_conversation["Gemini coach<br/>[gemini.py]"]
  node_memory[("Profile memory")]
  node_legacyapi["Legacy session API<br/>[app.py]"]
end

subgraph group_mltraining["ML training"]
  node_mlpipeline["Training workflow"]
  node_artifacts["Model artifacts<br/>[artifacts.py]"]
end

node_athlete(("Athlete"))

node_athlete -->|"uses"| node_iosapp
node_athlete -.->|"sets profile"| node_onboarding
node_iosapp -->|"owns workout"| node_workout
node_camera -->|"analyzes frames"| node_movement
node_movement -->|"emits observations"| node_contracts
node_camera -.->|"publishes frames"| node_preview
node_contracts -->|"ingests observations"| node_hub
node_workout -->|"commits reps"| node_hub
node_workout -->|"saves history"| node_journal
node_workout -->|"requests audio"| node_voiceclient
node_voiceclient -->|"fetches cues"| node_cloud
node_cloud -.->|"generates audio"| node_dynamiccue
node_restview -->|"controls rest"| node_workout
node_restview -->|"requests note"| node_conversation
node_cloud -->|"routes messages"| node_conversation
node_conversation -.->|"searches memories"| node_memory
node_iosapp -.->|"syncs workout"| node_watch
node_mlpipeline -->|"exports models"| node_artifacts
node_athlete -.->|"uses legacy tools"| node_legacyapi

click node_iosapp "https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAI/AppRootView.swift"
click node_onboarding "https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAI/Onboarding/OnboardingFlowView.swift"
click node_workout "https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIKit/Sources/GymAndAIKit/WorkoutSession.swift"
click node_hub "https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIKit/Sources/GymAndAIKit/HubSession.swift"
click node_journal "https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIKit/Sources/GymAndAIKit/WorkoutJournalWriter.swift"
click node_voiceclient "https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIKit/Sources/GymAndAIKit/HostedCoachClient.swift"
click node_restview "https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAI/Workout/RestView.swift"
click node_camera "https://github.com/chaseum/gymni-codered/blob/main/ml/src/fitness_ml/sources.py"
click node_preview "https://github.com/chaseum/gymni-codered/blob/main/ml/src/fitness_ml/preview.py"
click node_movement "https://github.com/chaseum/gymni-codered/blob/main/ml/src/fitness_ml/pipeline.py"
click node_contracts "https://github.com/chaseum/gymni-codered/blob/main/contracts/protocol.md"
click node_cloud "https://github.com/chaseum/gymni-codered/blob/main/backend/gymai_backend/cloud_app.py"
click node_dynamiccue "https://github.com/chaseum/gymni-codered/blob/main/backend/audio/dynamic_cue.py"
click node_conversation "https://github.com/chaseum/gymni-codered/blob/main/backend/gymai_backend/gemini.py"
click node_memory "https://github.com/chaseum/gymni-codered/blob/main/backend/gymai_backend/backboard_memory.py"
click node_legacyapi "https://github.com/chaseum/gymni-codered/blob/main/backend/gymai_backend/app.py"
click node_mlpipeline "https://github.com/chaseum/gymni-codered/tree/main/ml/src/fitness_ml/training"
click node_artifacts "https://github.com/chaseum/gymni-codered/blob/main/ml/src/fitness_ml/artifacts.py"
click node_watch "https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIWatch/WatchWorkoutManager.swift"

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_iosapp,node_onboarding,node_workout,node_hub,node_journal,node_voiceclient,node_restview,node_watch toneBlue
class node_camera,node_preview,node_movement,node_contracts toneAmber
class node_cloud,node_dynamiccue,node_conversation,node_memory,node_legacyapi toneMint
class node_mlpipeline,node_artifacts toneRose
class node_athlete toneIndigo
```

## Components

### iPhone experience

- [Workout app](https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAI/AppRootView.swift): `ios/GymAndAI/AppRootView.swift`
- [Onboarding](https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAI/Onboarding/OnboardingFlowView.swift): `ios/GymAndAI/Onboarding/OnboardingFlowView.swift`
- [Workout state](https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIKit/Sources/GymAndAIKit/WorkoutSession.swift): `ios/GymAndAIKit/Sources/GymAndAIKit/WorkoutSession.swift`
- [Rep counting](https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIKit/Sources/GymAndAIKit/HubSession.swift): `ios/GymAndAIKit/Sources/GymAndAIKit/HubSession.swift`
- [Local history](https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIKit/Sources/GymAndAIKit/WorkoutJournalWriter.swift): `ios/GymAndAIKit/Sources/GymAndAIKit/WorkoutJournalWriter.swift`
- [Voice client](https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIKit/Sources/GymAndAIKit/HostedCoachClient.swift): `ios/GymAndAIKit/Sources/GymAndAIKit/HostedCoachClient.swift`
- [Rest coaching](https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAI/Workout/RestView.swift): `ios/GymAndAI/Workout/RestView.swift`
- [Watch workout](https://github.com/chaseum/gymni-codered/blob/main/ios/GymAndAIWatch/WatchWorkoutManager.swift): `ios/GymAndAIWatch/WatchWorkoutManager.swift`

### Camera and movement

- [Pi camera](https://github.com/chaseum/gymni-codered/blob/main/ml/src/fitness_ml/sources.py): `ml/src/fitness_ml/sources.py`
- [Camera preview](https://github.com/chaseum/gymni-codered/blob/main/ml/src/fitness_ml/preview.py): `ml/src/fitness_ml/preview.py`
- [Movement analysis](https://github.com/chaseum/gymni-codered/blob/main/ml/src/fitness_ml/pipeline.py): `ml/src/fitness_ml/pipeline.py`
- [Observation protocol](https://github.com/chaseum/gymni-codered/blob/main/contracts/protocol.md): `contracts/protocol.md`

### Hosted coaching

- [Hosted API](https://github.com/chaseum/gymni-codered/blob/main/backend/gymai_backend/cloud_app.py): `backend/gymai_backend/cloud_app.py`
- [Dynamic cues](https://github.com/chaseum/gymni-codered/blob/main/backend/audio/dynamic_cue.py): `backend/audio/dynamic_cue.py`
- [Gemini coach](https://github.com/chaseum/gymni-codered/blob/main/backend/gymai_backend/gemini.py): `backend/gymai_backend/gemini.py`
- [Profile memory](https://github.com/chaseum/gymni-codered/blob/main/backend/gymai_backend/backboard_memory.py): `backend/gymai_backend/backboard_memory.py`
- [Legacy session API](https://github.com/chaseum/gymni-codered/blob/main/backend/gymai_backend/app.py): `backend/gymai_backend/app.py`

### ML training

- [Training workflow](https://github.com/chaseum/gymni-codered/tree/main/ml/src/fitness_ml/training): `ml/src/fitness_ml/training`
- [Model artifacts](https://github.com/chaseum/gymni-codered/blob/main/ml/src/fitness_ml/artifacts.py): `ml/src/fitness_ml/artifacts.py`

### Other components

- **Athlete**

## Connections

- Athlete → Workout app: uses (evidence: `README.md`)
- Athlete → Onboarding: sets profile
- Workout app → Workout state: owns workout (evidence: `README.md`)
- Pi camera → Movement analysis: analyzes frames (evidence: `ml/src/fitness_ml/pipeline.py`)
- Movement analysis → Observation protocol: emits observations (evidence: `README.md`)
- Pi camera → Camera preview: publishes frames
- Observation protocol → Rep counting: ingests observations (evidence: `README.md`)
- Workout state → Rep counting: commits reps (evidence: `ios/GymAndAIKit/Sources/GymAndAIKit/WorkoutSession.swift`)
- Workout state → Local history: saves history (evidence: `README.md`)
- Workout state → Voice client: requests audio (evidence: `ios/GymAndAIKit/Sources/GymAndAIKit/WorkoutSession.swift`)
- Voice client → Hosted API: fetches cues (evidence: `README.md`)
- Hosted API → Dynamic cues: generates audio (evidence: `backend/gymai_backend/cloud_app.py`)
- Rest coaching → Workout state: controls rest (evidence: `ios/GymAndAI/Workout/RestView.swift`)
- Rest coaching → Gemini coach: requests note (evidence: `ios/GymAndAI/Workout/RestView.swift`)
- Hosted API → Gemini coach: routes messages (evidence: `backend/gymai_backend/cloud_app.py`)
- Gemini coach → Profile memory: searches memories (evidence: `README.md`)
- Workout app → Watch workout: syncs workout
- Training workflow → Model artifacts: exports models (evidence: `ml/src/fitness_ml/training/cli.py`)
- Athlete → Legacy session API: uses legacy tools (evidence: `README.md`)
