# abhiramogirala/zenithcity architecture

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

- Interactive diagram: https://gitdiagram.com/abhiramogirala/zenithcity
- Repository: https://github.com/abhiramogirala/zenithcity

## Overview

ZenithCity is a fitness gamification app: users onboard, record and verify workouts, earn points, and use those rewards to grow a persistent city and compete on leaderboards or in territory battles. The React frontend routes users through those experiences, keeps domain state in Redux, and communicates with an Express API and Socket.IO; Supabase stores domain data, while Redis supports selected backend features. The tree documents watch synchronization, workout planning, nutrition, and AI live features, though their detailed implementations were not sampled. Edges reflect explicit imports, calls, or routes; unsampled domain links are omitted.

Main entry points: [`zenithcity/backend/src/index.ts`](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/index.ts) (API and sockets), [`zenithcity/frontend/src/App.tsx`](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/App.tsx) (App routing), [`zenithcity/frontend/src/store/slices/authSlice.ts`](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/store/slices/authSlice.ts) (Auth state), [`zenithcity/frontend/src/hooks/useSocket.ts`](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/hooks/useSocket.ts) (Live updates hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Frontend experience"]
  node_app["App routing<br/>[App.tsx]"]
  node_auth_ui["Sign-in<br/>[AuthPage.tsx]"]
  node_onboard_ui["Onboarding<br/>[OnboardingPage.tsx]"]
  node_dashboard_ui["Dashboard<br/>[DashboardPage.tsx]"]
  node_workout_ui["Workout tracking<br/>[WorkoutPage.tsx]"]
  node_plan_ui["Workout plans"]
  node_nutrition_ui["Nutrition<br/>[NutritionPage.tsx]"]
  node_city_ui["City builder<br/>[CityPage.tsx]"]
  node_city_view["3D city view<br/>[City3D.tsx]"]
  node_profile_ui["Player profile<br/>[ProfilePage.tsx]"]
  node_leaderboard_ui["Leaderboards"]
  node_battles_ui["Territory battles<br/>[BattlesPage.tsx]"]
  node_pose_ui["Pose detection<br/>[PoseDetector.tsx]"]
  node_frontend_store["Redux state<br/>[index.ts]"]
  node_auth_state["Auth state<br/>[authSlice.ts]"]
  node_city_state["City state<br/>[citySlice.ts]"]
  node_socket_hook["Live updates hook<br/>[useSocket.ts]"]
  node_socket_client["Socket client<br/>[socket.ts]"]
  node_api_client["HTTP API client<br/>[api.ts]"]
end

subgraph group_backend["Backend API"]
  node_api_entry["API and sockets<br/>[index.ts]"]
  node_auth_routes["Account and onboarding<br/>[auth.ts]"]
end

subgraph group_domain["Fitness game systems"]
  node_workout_routes["Workout sessions<br/>[workouts.ts]"]
  node_plan_routes["Plan generation<br/>[workoutPlan.ts]"]
  node_watch_routes["Watch sync<br/>[watchSync.ts]"]
  node_city_routes["City growth<br/>[cities.ts]"]
  node_points_routes["Points ledger<br/>[points.ts]"]
  node_points_logic["Points rules<br/>[points.ts]"]
  node_dashboard_routes["Dashboard data<br/>[dashboard.ts]"]
  node_leaderboard_routes["Rankings<br/>[leaderboards.ts]"]
  node_battle_routes["Battle management<br/>[battles.ts]"]
  node_feedback_routes["Feedback<br/>[feedback.ts]"]
  node_decline_job["City decline job<br/>[cityDecline.ts]"]
  node_gemini_socket["Gemini live socket<br/>[geminiLive.ts]"]
end

subgraph group_infrastructure["Persistence and realtime"]
end

node_user(("Player"))

node_user -->|"uses"| node_app
node_app -->|"routes"| node_auth_ui
node_app -->|"routes"| node_dashboard_ui
node_app -->|"routes"| node_workout_ui
node_app -->|"routes"| node_city_ui
node_app -->|"routes"| node_battles_ui
node_app -->|"starts"| node_socket_hook
node_auth_ui -->|"dispatches"| node_auth_state
node_app -->|"fetches profile"| node_auth_state
node_frontend_store -->|"registers"| node_auth_state
node_frontend_store -->|"registers"| node_city_state
node_socket_hook -->|"connects"| node_socket_client
node_socket_hook -->|"updates"| node_city_state
node_auth_state -->|"requests"| node_api_client
node_city_ui -->|"renders"| node_city_view
node_app -.->|"HTTP requests"| node_api_entry
node_socket_client -.->|"Socket.IO"| node_api_entry
node_api_entry -->|"mounts"| node_auth_routes
node_api_entry -->|"mounts"| node_workout_routes
node_api_entry -->|"mounts"| node_plan_routes
node_api_entry -->|"mounts"| node_watch_routes
node_api_entry -->|"mounts"| node_city_routes
node_api_entry -->|"mounts"| node_points_routes
node_api_entry -->|"mounts"| node_dashboard_routes
node_api_entry -->|"mounts"| node_leaderboard_routes
node_api_entry -->|"mounts"| node_battle_routes
node_api_entry -->|"mounts"| node_feedback_routes
node_api_entry -->|"sets up"| node_gemini_socket
node_api_entry -->|"schedules"| node_decline_job
node_workout_routes -->|"calculates"| node_points_logic
node_city_routes -->|"uses rules"| node_points_logic
node_decline_job -->|"uses limits"| node_points_logic
node_auth_routes -.->|"HTTP response"| node_auth_state

click node_app "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/App.tsx"
click node_auth_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/AuthPage.tsx"
click node_onboard_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/OnboardingPage.tsx"
click node_dashboard_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/DashboardPage.tsx"
click node_workout_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/WorkoutPage.tsx"
click node_plan_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/WorkoutPlanPage.tsx"
click node_nutrition_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/NutritionPage.tsx"
click node_city_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/CityPage.tsx"
click node_city_view "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/components/City3D.tsx"
click node_profile_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/ProfilePage.tsx"
click node_leaderboard_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/LeaderboardPage.tsx"
click node_battles_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/BattlesPage.tsx"
click node_pose_ui "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/components/PoseDetector.tsx"
click node_frontend_store "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/store/index.ts"
click node_auth_state "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/store/slices/authSlice.ts"
click node_city_state "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/store/slices/citySlice.ts"
click node_socket_hook "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/hooks/useSocket.ts"
click node_socket_client "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/services/socket.ts"
click node_api_client "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/services/api.ts"
click node_api_entry "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/index.ts"
click node_auth_routes "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/auth.ts"
click node_workout_routes "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/workouts.ts"
click node_plan_routes "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/workoutPlan.ts"
click node_watch_routes "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/watchSync.ts"
click node_city_routes "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/cities.ts"
click node_points_routes "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/points.ts"
click node_points_logic "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/utils/points.ts"
click node_dashboard_routes "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/dashboard.ts"
click node_leaderboard_routes "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/leaderboards.ts"
click node_battle_routes "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/battles.ts"
click node_feedback_routes "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/feedback.ts"
click node_decline_job "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/jobs/cityDecline.ts"
click node_gemini_socket "https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/socket/geminiLive.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_app,node_auth_ui,node_onboard_ui,node_dashboard_ui,node_workout_ui,node_plan_ui,node_nutrition_ui,node_city_ui,node_city_view,node_profile_ui,node_leaderboard_ui,node_battles_ui,node_pose_ui,node_frontend_store,node_auth_state,node_city_state,node_socket_hook,node_socket_client,node_api_client toneBlue
class node_api_entry,node_auth_routes toneAmber
class node_workout_routes,node_plan_routes,node_watch_routes,node_city_routes,node_points_routes,node_points_logic,node_dashboard_routes,node_leaderboard_routes,node_battle_routes,node_feedback_routes,node_decline_job,node_gemini_socket toneMint
class node_user toneIndigo
```

## Components

### Frontend experience

- [App routing](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/App.tsx): `zenithcity/frontend/src/App.tsx`
- [Sign-in](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/AuthPage.tsx): `zenithcity/frontend/src/pages/AuthPage.tsx`
- [Onboarding](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/OnboardingPage.tsx): `zenithcity/frontend/src/pages/OnboardingPage.tsx`
- [Dashboard](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/DashboardPage.tsx): `zenithcity/frontend/src/pages/DashboardPage.tsx`
- [Workout tracking](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/WorkoutPage.tsx): `zenithcity/frontend/src/pages/WorkoutPage.tsx`
- [Workout plans](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/WorkoutPlanPage.tsx): `zenithcity/frontend/src/pages/WorkoutPlanPage.tsx`
- [Nutrition](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/NutritionPage.tsx): `zenithcity/frontend/src/pages/NutritionPage.tsx`
- [City builder](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/CityPage.tsx): `zenithcity/frontend/src/pages/CityPage.tsx`
- [3D city view](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/components/City3D.tsx): `zenithcity/frontend/src/components/City3D.tsx`
- [Player profile](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/ProfilePage.tsx): `zenithcity/frontend/src/pages/ProfilePage.tsx`
- [Leaderboards](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/LeaderboardPage.tsx): `zenithcity/frontend/src/pages/LeaderboardPage.tsx`
- [Territory battles](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/pages/BattlesPage.tsx): `zenithcity/frontend/src/pages/BattlesPage.tsx`
- [Pose detection](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/components/PoseDetector.tsx): `zenithcity/frontend/src/components/PoseDetector.tsx`
- [Redux state](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/store/index.ts): `zenithcity/frontend/src/store/index.ts`
- [Auth state](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/store/slices/authSlice.ts): `zenithcity/frontend/src/store/slices/authSlice.ts`
- [City state](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/store/slices/citySlice.ts): `zenithcity/frontend/src/store/slices/citySlice.ts`
- [Live updates hook](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/hooks/useSocket.ts): `zenithcity/frontend/src/hooks/useSocket.ts`
- [Socket client](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/services/socket.ts): `zenithcity/frontend/src/services/socket.ts`
- [HTTP API client](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/frontend/src/services/api.ts): `zenithcity/frontend/src/services/api.ts`

### Backend API

- [API and sockets](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/index.ts): `zenithcity/backend/src/index.ts`
- [Account and onboarding](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/auth.ts): `zenithcity/backend/src/routes/auth.ts`

### Fitness game systems

- [Workout sessions](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/workouts.ts): `zenithcity/backend/src/routes/workouts.ts`
- [Plan generation](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/workoutPlan.ts): `zenithcity/backend/src/routes/workoutPlan.ts`
- [Watch sync](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/watchSync.ts): `zenithcity/backend/src/routes/watchSync.ts`
- [City growth](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/cities.ts): `zenithcity/backend/src/routes/cities.ts`
- [Points ledger](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/points.ts): `zenithcity/backend/src/routes/points.ts`
- [Points rules](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/utils/points.ts): `zenithcity/backend/src/utils/points.ts`
- [Dashboard data](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/dashboard.ts): `zenithcity/backend/src/routes/dashboard.ts`
- [Rankings](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/leaderboards.ts): `zenithcity/backend/src/routes/leaderboards.ts`
- [Battle management](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/battles.ts): `zenithcity/backend/src/routes/battles.ts`
- [Feedback](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/routes/feedback.ts): `zenithcity/backend/src/routes/feedback.ts`
- [City decline job](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/jobs/cityDecline.ts): `zenithcity/backend/src/jobs/cityDecline.ts`
- [Gemini live socket](https://github.com/abhiramogirala/zenithcity/blob/main/zenithcity/backend/src/socket/geminiLive.ts): `zenithcity/backend/src/socket/geminiLive.ts`

### Other components

- **Player**

## Connections

- Player → App routing: uses (evidence: `zenithcity/frontend/src/App.tsx`)
- App routing → Sign-in: routes (evidence: `zenithcity/frontend/src/App.tsx`)
- App routing → Dashboard: routes (evidence: `zenithcity/frontend/src/App.tsx`)
- App routing → Workout tracking: routes (evidence: `zenithcity/frontend/src/App.tsx`)
- App routing → City builder: routes (evidence: `zenithcity/frontend/src/App.tsx`)
- App routing → Territory battles: routes (evidence: `zenithcity/frontend/src/App.tsx`)
- App routing → Live updates hook: starts (evidence: `zenithcity/frontend/src/App.tsx`)
- Sign-in → Auth state: dispatches (evidence: `zenithcity/frontend/src/pages/AuthPage.tsx`)
- App routing → Auth state: fetches profile (evidence: `zenithcity/frontend/src/App.tsx`)
- Redux state → Auth state: registers (evidence: `zenithcity/frontend/src/store/index.ts`)
- Redux state → City state: registers (evidence: `zenithcity/frontend/src/store/index.ts`)
- Live updates hook → Socket client: connects (evidence: `zenithcity/frontend/src/hooks/useSocket.ts`)
- Live updates hook → City state: updates (evidence: `zenithcity/frontend/src/hooks/useSocket.ts`)
- Auth state → HTTP API client: requests (evidence: `zenithcity/frontend/src/store/slices/authSlice.ts`)
- City builder → 3D city view: renders (evidence: `zenithcity/frontend/src/pages/CityPage.tsx`)
- App routing → API and sockets: HTTP requests
- Socket client → API and sockets: Socket.IO
- API and sockets → Account and onboarding: mounts (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → Workout sessions: mounts (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → Plan generation: mounts (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → Watch sync: mounts (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → City growth: mounts (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → Points ledger: mounts (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → Dashboard data: mounts (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → Rankings: mounts (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → Battle management: mounts (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → Feedback: mounts (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → Gemini live socket: sets up (evidence: `zenithcity/backend/src/index.ts`)
- API and sockets → City decline job: schedules (evidence: `zenithcity/backend/src/index.ts`)
- Workout sessions → Points rules: calculates (evidence: `zenithcity/backend/src/routes/workouts.ts`)
- City growth → Points rules: uses rules (evidence: `zenithcity/backend/src/routes/cities.ts`)
- City decline job → Points rules: uses limits (evidence: `zenithcity/backend/src/jobs/cityDecline.ts`)
- Account and onboarding → Auth state: HTTP response
