# amitdas4321/opengym architecture

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

- Interactive diagram: https://gitdiagram.com/amitdas4321/opengym
- Repository: https://github.com/amitdas4321/opengym

## Overview

openGym is a self-hosted workout and body-weight tracker: users sign in, plan routines, log guided workouts, and review progress, with state synchronized through a REST API to a selectable database. The frontend also supports imports/exports, passkeys, reminders, localization, and installable offline use. The graph follows the documented app-to-server-to-storage structure and includes the major training and analytics capabilities. Some view implementations were not sampled, so their internal calls are not inferred.

Main entry points: [`src/App.jsx`](https://github.com/amitdas4321/opengym/blob/main/src/App.jsx) (App shell), [`src/views/Stats.jsx`](https://github.com/amitdas4321/opengym/blob/main/src/views/Stats.jsx) (Stats and charts), [`src/views/Settings.jsx`](https://github.com/amitdas4321/opengym/blob/main/src/views/Settings.jsx) (Settings and export), [`src/store/useStore.js`](https://github.com/amitdas4321/opengym/blob/main/src/store/useStore.js) (Workout state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and State"]
  node_app["App shell<br/>[App.jsx]"]
  node_state["Workout state<br/>[useStore.js]"]
  node_ui_state["UI state<br/>[useUI.js]"]
  node_sheets["Action sheets<br/>[sheets.jsx]"]
end

subgraph group_training["Training and Planning"]
  node_home["Home and weight<br/>[Home.jsx]"]
  node_planner["Weekly planner<br/>[Plan.jsx]"]
  node_routine["Routine editor<br/>[RoutineEdit.jsx]"]
  node_workout["Guided workout<br/>[Workout.jsx]"]
  node_exercise_catalog["Exercise catalogue<br/>[exercises.js]"]
end

subgraph group_insights["Progress and Insights"]
  node_history["Workout history<br/>[history.js]"]
  node_history_view["History view<br/>[History.jsx]"]
  node_stats["Stats and charts<br/>[Stats.jsx]"]
  node_muscle_map["Muscle map<br/>[BodyMap.jsx]"]
  node_chart["Trend charts<br/>[LineChart.jsx]"]
  node_imports["History import<br/>[import-csv.js]"]
end

subgraph group_platform["Account and Platform"]
  node_settings["Settings and export<br/>[Settings.jsx]"]
  node_login["Passkey login<br/>[Login.jsx]"]
  node_localization["Localization<br/>[i18n.js]"]
  node_mobile["Mobile and PWA<br/>[mobile.js]"]
  node_push["Push reminders<br/>[push.js]"]
end

subgraph group_backend["Server and Storage"]
  node_api["REST client<br/>[api.js]"]
  node_server["Unified server<br/>[server.js]"]
  node_db_service["Database service<br/>[index.js]"]
  node_firebase[("Firebase provider<br/>[firebase.js]")]
  node_mysql[("MySQL provider<br/>[mysql.js]")]
  node_mongodb[("MongoDB provider<br/>[mongodb.js]")]
end

node_user(("Gym user"))
node_external_db[("Configured database")]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_planner
node_app -->|"routes to"| node_routine
node_app -->|"routes to"| node_workout
node_app -->|"routes to"| node_stats
node_app -->|"routes to"| node_history_view
node_app -->|"routes to"| node_settings
node_app -->|"routes to"| node_login
node_app -->|"reads"| node_state
node_state -->|"syncs state"| node_api
node_api -->|"HTTP requests"| node_server
node_server -->|"uses"| node_db_service
node_db_service -->|"dispatches"| node_firebase
node_db_service -->|"dispatches"| node_mysql
node_db_service -->|"dispatches"| node_mongodb
node_firebase -.->|"reads and writes"| node_external_db
node_mysql -.->|"reads and writes"| node_external_db
node_mongodb -.->|"reads and writes"| node_external_db
node_planner -->|"assigns routines"| node_routine
node_routine -->|"selects exercises"| node_exercise_catalog
node_workout -->|"records sets"| node_history
node_workout -.->|"updates workout data"| node_state
node_history_view -.->|"summarizes"| node_history
node_stats -->|"analyzes"| node_history
node_stats -->|"renders trends"| node_chart
node_stats -->|"renders muscle map"| node_muscle_map
node_settings -->|"imports history"| node_imports
node_settings -->|"uses account API"| node_api
node_state -->|"loads and saves"| node_mobile
node_settings -->|"configures reminders"| node_push
node_ui_state -->|"schedules timer alert"| node_api
node_ui_state -->|"reads preferences"| node_state
node_app -->|"mounts"| node_sheets
node_routine -.->|"opens editors"| node_sheets
node_user -.->|"configures account"| node_settings
node_user -->|"plans week"| node_planner
node_user -->|"trains and logs"| node_workout
node_user -->|"reviews progress"| node_stats

click node_app "https://github.com/amitdas4321/opengym/blob/main/src/App.jsx"
click node_state "https://github.com/amitdas4321/opengym/blob/main/src/store/useStore.js"
click node_ui_state "https://github.com/amitdas4321/opengym/blob/main/src/store/useUI.js"
click node_sheets "https://github.com/amitdas4321/opengym/blob/main/src/sheets.jsx"
click node_api "https://github.com/amitdas4321/opengym/blob/main/src/lib/api.js"
click node_home "https://github.com/amitdas4321/opengym/blob/main/src/views/Home.jsx"
click node_planner "https://github.com/amitdas4321/opengym/blob/main/src/views/Plan.jsx"
click node_routine "https://github.com/amitdas4321/opengym/blob/main/src/views/RoutineEdit.jsx"
click node_workout "https://github.com/amitdas4321/opengym/blob/main/src/views/Workout.jsx"
click node_exercise_catalog "https://github.com/amitdas4321/opengym/blob/main/src/lib/exercises.js"
click node_history "https://github.com/amitdas4321/opengym/blob/main/src/lib/history.js"
click node_history_view "https://github.com/amitdas4321/opengym/blob/main/src/views/History.jsx"
click node_stats "https://github.com/amitdas4321/opengym/blob/main/src/views/Stats.jsx"
click node_muscle_map "https://github.com/amitdas4321/opengym/blob/main/src/components/BodyMap.jsx"
click node_chart "https://github.com/amitdas4321/opengym/blob/main/src/components/LineChart.jsx"
click node_imports "https://github.com/amitdas4321/opengym/blob/main/src/lib/import-csv.js"
click node_settings "https://github.com/amitdas4321/opengym/blob/main/src/views/Settings.jsx"
click node_login "https://github.com/amitdas4321/opengym/blob/main/src/views/Login.jsx"
click node_localization "https://github.com/amitdas4321/opengym/blob/main/src/lib/i18n.js"
click node_mobile "https://github.com/amitdas4321/opengym/blob/main/src/lib/mobile.js"
click node_push "https://github.com/amitdas4321/opengym/blob/main/src/lib/push.js"
click node_server "https://github.com/amitdas4321/opengym/blob/main/server.js"
click node_db_service "https://github.com/amitdas4321/opengym/blob/main/database/index.js"
click node_firebase "https://github.com/amitdas4321/opengym/blob/main/database/providers/firebase.js"
click node_mysql "https://github.com/amitdas4321/opengym/blob/main/database/providers/mysql.js"
click node_mongodb "https://github.com/amitdas4321/opengym/blob/main/database/providers/mongodb.js"

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_state,node_ui_state,node_sheets,node_user toneBlue
class node_home,node_planner,node_routine,node_workout,node_exercise_catalog,node_external_db toneAmber
class node_history,node_history_view,node_stats,node_muscle_map,node_chart,node_imports toneMint
class node_settings,node_login,node_localization,node_mobile,node_push toneRose
class node_api,node_server,node_db_service,node_firebase,node_mysql,node_mongodb toneIndigo
```

## Components

### App and State

- [App shell](https://github.com/amitdas4321/opengym/blob/main/src/App.jsx): `src/App.jsx`
- [Workout state](https://github.com/amitdas4321/opengym/blob/main/src/store/useStore.js): `src/store/useStore.js`
- [UI state](https://github.com/amitdas4321/opengym/blob/main/src/store/useUI.js): `src/store/useUI.js`
- [Action sheets](https://github.com/amitdas4321/opengym/blob/main/src/sheets.jsx): `src/sheets.jsx`

### Training and Planning

- [Home and weight](https://github.com/amitdas4321/opengym/blob/main/src/views/Home.jsx): `src/views/Home.jsx`
- [Weekly planner](https://github.com/amitdas4321/opengym/blob/main/src/views/Plan.jsx): `src/views/Plan.jsx`
- [Routine editor](https://github.com/amitdas4321/opengym/blob/main/src/views/RoutineEdit.jsx): `src/views/RoutineEdit.jsx`
- [Guided workout](https://github.com/amitdas4321/opengym/blob/main/src/views/Workout.jsx): `src/views/Workout.jsx`
- [Exercise catalogue](https://github.com/amitdas4321/opengym/blob/main/src/lib/exercises.js): `src/lib/exercises.js`

### Progress and Insights

- [Workout history](https://github.com/amitdas4321/opengym/blob/main/src/lib/history.js): `src/lib/history.js`
- [History view](https://github.com/amitdas4321/opengym/blob/main/src/views/History.jsx): `src/views/History.jsx`
- [Stats and charts](https://github.com/amitdas4321/opengym/blob/main/src/views/Stats.jsx): `src/views/Stats.jsx`
- [Muscle map](https://github.com/amitdas4321/opengym/blob/main/src/components/BodyMap.jsx): `src/components/BodyMap.jsx`
- [Trend charts](https://github.com/amitdas4321/opengym/blob/main/src/components/LineChart.jsx): `src/components/LineChart.jsx`
- [History import](https://github.com/amitdas4321/opengym/blob/main/src/lib/import-csv.js): `src/lib/import-csv.js`

### Account and Platform

- [Settings and export](https://github.com/amitdas4321/opengym/blob/main/src/views/Settings.jsx): `src/views/Settings.jsx`
- [Passkey login](https://github.com/amitdas4321/opengym/blob/main/src/views/Login.jsx): `src/views/Login.jsx`
- [Localization](https://github.com/amitdas4321/opengym/blob/main/src/lib/i18n.js): `src/lib/i18n.js`
- [Mobile and PWA](https://github.com/amitdas4321/opengym/blob/main/src/lib/mobile.js): `src/lib/mobile.js`
- [Push reminders](https://github.com/amitdas4321/opengym/blob/main/src/lib/push.js): `src/lib/push.js`

### Server and Storage

- [REST client](https://github.com/amitdas4321/opengym/blob/main/src/lib/api.js): `src/lib/api.js`
- [Unified server](https://github.com/amitdas4321/opengym/blob/main/server.js): `server.js`
- [Database service](https://github.com/amitdas4321/opengym/blob/main/database/index.js): `database/index.js`
- [Firebase provider](https://github.com/amitdas4321/opengym/blob/main/database/providers/firebase.js): `database/providers/firebase.js`
- [MySQL provider](https://github.com/amitdas4321/opengym/blob/main/database/providers/mysql.js): `database/providers/mysql.js`
- [MongoDB provider](https://github.com/amitdas4321/opengym/blob/main/database/providers/mongodb.js): `database/providers/mongodb.js`

### Other components

- **Gym user**
- **Configured database**

## Connections

- Gym user → App shell: uses
- App shell → Home and weight: routes to (evidence: `src/App.jsx`)
- App shell → Weekly planner: routes to (evidence: `src/App.jsx`)
- App shell → Routine editor: routes to (evidence: `src/App.jsx`)
- App shell → Guided workout: routes to (evidence: `src/App.jsx`)
- App shell → Stats and charts: routes to (evidence: `src/App.jsx`)
- App shell → History view: routes to (evidence: `src/App.jsx`)
- App shell → Settings and export: routes to (evidence: `src/App.jsx`)
- App shell → Passkey login: routes to (evidence: `src/App.jsx`)
- App shell → Workout state: reads (evidence: `src/App.jsx`)
- Workout state → REST client: syncs state (evidence: `src/store/useStore.js`)
- REST client → Unified server: HTTP requests
- Unified server → Database service: uses (evidence: `server.js`)
- Database service → Firebase provider: dispatches (evidence: `database/index.js`)
- Database service → MySQL provider: dispatches (evidence: `database/index.js`)
- Database service → MongoDB provider: dispatches (evidence: `database/index.js`)
- Firebase provider → Configured database: reads and writes
- MySQL provider → Configured database: reads and writes
- MongoDB provider → Configured database: reads and writes
- Weekly planner → Routine editor: assigns routines
- Routine editor → Exercise catalogue: selects exercises
- Guided workout → Workout history: records sets (evidence: `src/views/Workout.jsx`)
- Guided workout → Workout state: updates workout data (evidence: `src/views/Workout.jsx`)
- History view → Workout history: summarizes
- Stats and charts → Workout history: analyzes (evidence: `src/views/Stats.jsx`)
- Stats and charts → Trend charts: renders trends (evidence: `src/views/Stats.jsx`)
- Stats and charts → Muscle map: renders muscle map (evidence: `src/views/Stats.jsx`)
- Settings and export → History import: imports history
- Settings and export → REST client: uses account API (evidence: `src/views/Settings.jsx`)
- Workout state → Mobile and PWA: loads and saves (evidence: `src/store/useStore.js`)
- Settings and export → Push reminders: configures reminders (evidence: `src/views/Settings.jsx`)
- UI state → REST client: schedules timer alert (evidence: `src/store/useUI.js`)
- UI state → Workout state: reads preferences (evidence: `src/store/useUI.js`)
- App shell → Action sheets: mounts (evidence: `src/App.jsx`)
- Routine editor → Action sheets: opens editors
- Gym user → Settings and export: configures account
- Gym user → Weekly planner: plans week
- Gym user → Guided workout: trains and logs
- Gym user → Stats and charts: reviews progress
