# sanjaytheli/gymbrochat architecture

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

- Interactive diagram: https://gitdiagram.com/sanjaytheli/gymbrochat
- Repository: https://github.com/sanjaytheli/gymbrochat

## Overview

GymBro AI is a fitness-coaching chat app with workout chat sessions and lightweight progress tracking. The main workflow is a user message submitted from the React app to a FastAPI endpoint, which builds a prompt and streams Cohere-generated text. The frontend also maintains session, streak, PR, and macro state in browser storage. The excerpts establish the frontend/backend request and backend model/prompt calls; frontend response handling is only partially shown, so the return stream is documented from the backend side.

Main entry points: [`backend/app.py`](https://github.com/sanjaytheli/gymbrochat/blob/main/backend/app.py) (Chat endpoint), [`frontend/FEgymbro/src/App.jsx`](https://github.com/sanjaytheli/gymbrochat/blob/main/frontend/FEgymbro/src/App.jsx) (GymBro app), [`frontend/FEgymbro/src/main.jsx`](https://github.com/sanjaytheli/gymbrochat/blob/main/frontend/FEgymbro/src/main.jsx) (React entry), [`backend/schemas/models.py`](https://github.com/sanjaytheli/gymbrochat/blob/main/backend/schemas/models.py) (Chat request schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_app_entry["React entry<br/>[main.jsx]"]
  node_gym_app["GymBro app<br/>[App.jsx]"]
  node_chat_sessions["Chat sessions<br/>[App.jsx]"]
  node_progress_tracking["Progress tracking<br/>[App.jsx]"]
end

subgraph group_backend["Backend"]
  node_chat_api["Chat endpoint<br/>[app.py]"]
  node_chat_request["Chat request schema<br/>[models.py]"]
  node_coach_prompt["Coach system prompt<br/>[cohere_prompts.py]"]
end

subgraph group_ai["AI provider"]
  node_cohere{{"Cohere API"}}
end

node_user(("Fitness user"))
node_browser_storage[("Browser storage")]

node_user -->|"uses"| node_gym_app
node_app_entry -->|"renders"| node_gym_app
node_gym_app -->|"posts message"| node_chat_api
node_gym_app -->|"persists state"| node_browser_storage
node_chat_api -->|"validates payload"| node_chat_request
node_chat_api -->|"uses prompt"| node_coach_prompt
node_chat_api -->|"requests stream"| node_cohere
node_chat_api -->|"streams response"| node_gym_app

click node_app_entry "https://github.com/sanjaytheli/gymbrochat/blob/main/frontend/FEgymbro/src/main.jsx"
click node_gym_app "https://github.com/sanjaytheli/gymbrochat/blob/main/frontend/FEgymbro/src/App.jsx"
click node_chat_sessions "https://github.com/sanjaytheli/gymbrochat/blob/main/frontend/FEgymbro/src/App.jsx"
click node_progress_tracking "https://github.com/sanjaytheli/gymbrochat/blob/main/frontend/FEgymbro/src/App.jsx"
click node_chat_api "https://github.com/sanjaytheli/gymbrochat/blob/main/backend/app.py"
click node_chat_request "https://github.com/sanjaytheli/gymbrochat/blob/main/backend/schemas/models.py"
click node_coach_prompt "https://github.com/sanjaytheli/gymbrochat/blob/main/backend/llm_adapters/cohere_prompts.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_entry,node_gym_app,node_chat_sessions,node_progress_tracking,node_user toneBlue
class node_chat_api,node_chat_request,node_coach_prompt,node_browser_storage toneAmber
class node_cohere toneMint
```

## Components

### Frontend

- [React entry](https://github.com/sanjaytheli/gymbrochat/blob/main/frontend/FEgymbro/src/main.jsx): `frontend/FEgymbro/src/main.jsx`
- [GymBro app](https://github.com/sanjaytheli/gymbrochat/blob/main/frontend/FEgymbro/src/App.jsx): `frontend/FEgymbro/src/App.jsx`
- [Chat sessions](https://github.com/sanjaytheli/gymbrochat/blob/main/frontend/FEgymbro/src/App.jsx): `frontend/FEgymbro/src/App.jsx`
- [Progress tracking](https://github.com/sanjaytheli/gymbrochat/blob/main/frontend/FEgymbro/src/App.jsx): `frontend/FEgymbro/src/App.jsx`

### Backend

- [Chat endpoint](https://github.com/sanjaytheli/gymbrochat/blob/main/backend/app.py): `backend/app.py`
- [Chat request schema](https://github.com/sanjaytheli/gymbrochat/blob/main/backend/schemas/models.py): `backend/schemas/models.py`
- [Coach system prompt](https://github.com/sanjaytheli/gymbrochat/blob/main/backend/llm_adapters/cohere_prompts.py): `backend/llm_adapters/cohere_prompts.py`

### AI provider

- **Cohere API**

### Other components

- **Fitness user**
- **Browser storage**

## Connections

- Fitness user → GymBro app: uses (evidence: `frontend/FEgymbro/src/App.jsx`)
- React entry → GymBro app: renders (evidence: `frontend/FEgymbro/src/main.jsx`)
- GymBro app → Chat endpoint: posts message (evidence: `frontend/FEgymbro/src/App.jsx`)
- GymBro app → Browser storage: persists state (evidence: `frontend/FEgymbro/src/App.jsx`)
- Chat endpoint → Chat request schema: validates payload (evidence: `backend/app.py`)
- Chat endpoint → Coach system prompt: uses prompt (evidence: `backend/app.py`)
- Chat endpoint → Cohere API: requests stream (evidence: `backend/app.py`)
- Chat endpoint → GymBro app: streams response (evidence: `backend/app.py`)
