# navysaiteja/apexfit- architecture

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

- Interactive diagram: https://gitdiagram.com/navysaiteja/apexfit-
- Repository: https://github.com/navysaiteja/apexfit-

## Overview

ApexFit is a fitness-tracking and coaching application. A user logs in, records workouts, nutrition and body progress, then views personalized analytics and AI-generated recommendations through the frontend and API. The graph retains the product’s main domain branches—coaching, meal planning and food scanning, subscriptions, and progress—alongside the shared persistence and retrieval layer. Edges are limited to routes and calls evidenced by the provided excerpts or SOURCE INDEX; unsampled controllers and frontend pages are represented without guessed connections.

Main entry points: [`apexfit/backend/src/routes`](https://github.com/navysaiteja/apexfit-/tree/main/apexfit/backend/src/routes) (API route groups), [`apexfit/backend/src/controllers/coach.controller.ts`](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/coach.controller.ts) (Coach endpoints), [`apexfit/backend/src/services/rag.service.ts`](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/rag.service.ts) (Fitness context retrieval), [`apexfit/backend/src/utils/strength.ts`](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/utils/strength.ts) (Strength metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User experience"]
  node_frontend["Web application<br/>[App.tsx]"]
  node_datahook["Fitness data hook<br/>[useApexData.ts]"]
  node_chatui["Coach chat hook<br/>[useCoachChat.ts]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and identity"]
  node_routes["API route groups"]
  node_auth["Authentication<br/>[authenticate.ts]"]
  node_validation["Request validation<br/>[validate.ts]"]
  node_auth_flow["Account access<br/>[auth.controller.ts]"]
  node_subscriptions["Subscriptions"]
end

subgraph group_fitness["Fitness tracking"]
  node_workouts["Workout logging"]
  node_progress["Progress analytics"]
  node_nutrition["Nutrition tracking"]
  node_strength["Strength metrics<br/>[strength.ts]"]
end

subgraph group_intelligence["AI coaching"]
  node_coach["Coach endpoints"]
  node_ai["AI generation"]
  node_briefing["Daily briefing"]
  node_recommendations["Workout recommendations"]
  node_mealplan["Meal planning"]
  node_plateau["Plateau analysis"]
  node_rag["Fitness context retrieval<br/>[rag.service.ts]"]
  node_vision["Food photo analysis<br/>[vision.service.ts]"]
end

subgraph group_platform["Persistence and integrations"]
  node_db[("Application database<br/>[prisma.ts]")]
  node_embeddings[("Vector embeddings<br/>[embeddings.ts]")]
  node_redis[("Redis cache<br/>[redis.ts]")]
  node_usda["USDA food data<br/>[usda.ts]"]
end

node_user(("Fitness user"))

node_user -->|"uses"| node_frontend
node_frontend -->|"loads data"| node_datahook
node_frontend -.->|"offers chat"| node_chatui
node_datahook -.->|"requests data"| node_api_client
node_chatui -.->|"sends messages"| node_api_client
node_api_client -.->|"calls API"| node_routes
node_routes -->|"authenticates"| node_auth
node_routes -->|"validates"| node_validation
node_routes -->|"dispatches"| node_auth_flow
node_routes -->|"dispatches"| node_workouts
node_routes -->|"dispatches"| node_progress
node_routes -->|"dispatches"| node_nutrition
node_routes -->|"dispatches"| node_coach
node_routes -->|"dispatches"| node_subscriptions
node_workouts -->|"logs sets"| node_strength
node_workouts -->|"refreshes profile"| node_rag
node_progress -->|"computes metrics"| node_strength
node_progress -->|"analyzes stalls"| node_plateau
node_nutrition -->|"analyzes photos"| node_vision
node_nutrition -->|"requests plans"| node_mealplan
node_nutrition -->|"retrieves context"| node_rag
node_coach -->|"generates responses"| node_ai
node_coach -->|"builds fitness context"| node_strength
node_coach -->|"gets briefing"| node_briefing
node_coach -.->|"requests workouts"| node_recommendations
node_coach -.->|"retrieves context"| node_rag
node_rag -->|"searches and stores"| node_embeddings
node_rag -->|"summarizes lifts"| node_strength
node_rag -->|"analyzes causes"| node_plateau
node_rag -->|"reads profile"| node_db
node_embeddings -->|"stores vectors"| node_db
node_strength -->|"reads and writes logs"| node_db
node_mealplan -.->|"uses food data"| node_usda
node_coach -->|"caches reports"| node_redis

click node_frontend "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/frontend/src/App.tsx"
click node_datahook "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/frontend/src/hooks/useApexData.ts"
click node_chatui "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/frontend/src/hooks/useCoachChat.ts"
click node_api_client "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/frontend/src/services/api.ts"
click node_routes "https://github.com/navysaiteja/apexfit-/tree/main/apexfit/backend/src/routes"
click node_auth "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/middleware/authenticate.ts"
click node_validation "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/middleware/validate.ts"
click node_auth_flow "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/auth.controller.ts"
click node_workouts "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/workout.controller.ts"
click node_progress "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/progress.controller.ts"
click node_nutrition "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/nutrition.controller.ts"
click node_coach "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/coach.controller.ts"
click node_ai "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/anthropic.service.ts"
click node_briefing "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/dailyBriefing.service.ts"
click node_recommendations "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/workoutRecommendation.service.ts"
click node_mealplan "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/mealPlan.service.ts"
click node_plateau "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/plateauAnalysis.service.ts"
click node_rag "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/rag.service.ts"
click node_strength "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/utils/strength.ts"
click node_db "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/config/prisma.ts"
click node_embeddings "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/config/embeddings.ts"
click node_redis "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/config/redis.ts"
click node_vision "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/vision.service.ts"
click node_subscriptions "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/subscription.controller.ts"
click node_usda "https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/config/usda.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_frontend,node_datahook,node_chatui,node_api_client,node_user toneBlue
class node_routes,node_auth,node_validation,node_auth_flow,node_subscriptions toneAmber
class node_workouts,node_progress,node_nutrition,node_strength toneMint
class node_coach,node_ai,node_briefing,node_recommendations,node_mealplan,node_plateau,node_rag,node_vision toneRose
class node_db,node_embeddings,node_redis,node_usda toneIndigo
```

## Components

### User experience

- [Web application](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/frontend/src/App.tsx): `apexfit/frontend/src/App.tsx`
- [Fitness data hook](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/frontend/src/hooks/useApexData.ts): `apexfit/frontend/src/hooks/useApexData.ts`
- [Coach chat hook](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/frontend/src/hooks/useCoachChat.ts): `apexfit/frontend/src/hooks/useCoachChat.ts`
- [API client](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/frontend/src/services/api.ts): `apexfit/frontend/src/services/api.ts`

### API and identity

- [API route groups](https://github.com/navysaiteja/apexfit-/tree/main/apexfit/backend/src/routes): `apexfit/backend/src/routes`
- [Authentication](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/middleware/authenticate.ts): `apexfit/backend/src/middleware/authenticate.ts`
- [Request validation](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/middleware/validate.ts): `apexfit/backend/src/middleware/validate.ts`
- [Account access](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/auth.controller.ts): `apexfit/backend/src/controllers/auth.controller.ts`
- [Subscriptions](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/subscription.controller.ts): `apexfit/backend/src/controllers/subscription.controller.ts`

### Fitness tracking

- [Workout logging](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/workout.controller.ts): `apexfit/backend/src/controllers/workout.controller.ts`
- [Progress analytics](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/progress.controller.ts): `apexfit/backend/src/controllers/progress.controller.ts`
- [Nutrition tracking](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/nutrition.controller.ts): `apexfit/backend/src/controllers/nutrition.controller.ts`
- [Strength metrics](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/utils/strength.ts): `apexfit/backend/src/utils/strength.ts`

### AI coaching

- [Coach endpoints](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/controllers/coach.controller.ts): `apexfit/backend/src/controllers/coach.controller.ts`
- [AI generation](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/anthropic.service.ts): `apexfit/backend/src/services/anthropic.service.ts`
- [Daily briefing](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/dailyBriefing.service.ts): `apexfit/backend/src/services/dailyBriefing.service.ts`
- [Workout recommendations](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/workoutRecommendation.service.ts): `apexfit/backend/src/services/workoutRecommendation.service.ts`
- [Meal planning](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/mealPlan.service.ts): `apexfit/backend/src/services/mealPlan.service.ts`
- [Plateau analysis](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/plateauAnalysis.service.ts): `apexfit/backend/src/services/plateauAnalysis.service.ts`
- [Fitness context retrieval](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/rag.service.ts): `apexfit/backend/src/services/rag.service.ts`
- [Food photo analysis](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/services/vision.service.ts): `apexfit/backend/src/services/vision.service.ts`

### Persistence and integrations

- [Application database](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/config/prisma.ts): `apexfit/backend/src/config/prisma.ts`
- [Vector embeddings](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/config/embeddings.ts): `apexfit/backend/src/config/embeddings.ts`
- [Redis cache](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/config/redis.ts): `apexfit/backend/src/config/redis.ts`
- [USDA food data](https://github.com/navysaiteja/apexfit-/blob/main/apexfit/backend/src/config/usda.ts): `apexfit/backend/src/config/usda.ts`

### Other components

- **Fitness user**

## Connections

- Fitness user → Web application: uses
- Web application → Fitness data hook: loads data (evidence: `apexfit/frontend/src/App.tsx`)
- Web application → Coach chat hook: offers chat
- Fitness data hook → API client: requests data
- Coach chat hook → API client: sends messages
- API client → API route groups: calls API
- API route groups → Authentication: authenticates (evidence: `apexfit/backend/src/routes/coach.routes.ts`)
- API route groups → Request validation: validates (evidence: `apexfit/backend/src/routes/coach.routes.ts`)
- API route groups → Account access: dispatches (evidence: `apexfit/backend/src/routes/auth.routes.ts`)
- API route groups → Workout logging: dispatches (evidence: `apexfit/backend/src/routes/workout.routes.ts`)
- API route groups → Progress analytics: dispatches (evidence: `apexfit/backend/src/routes/progress.routes.ts`)
- API route groups → Nutrition tracking: dispatches (evidence: `apexfit/backend/src/routes/nutrition.routes.ts`)
- API route groups → Coach endpoints: dispatches (evidence: `apexfit/backend/src/routes/coach.routes.ts`)
- API route groups → Subscriptions: dispatches (evidence: `apexfit/backend/src/routes/subscription.routes.ts`)
- Workout logging → Strength metrics: logs sets (evidence: `apexfit/backend/src/controllers/workout.controller.ts`)
- Workout logging → Fitness context retrieval: refreshes profile (evidence: `apexfit/backend/src/controllers/workout.controller.ts`)
- Progress analytics → Strength metrics: computes metrics (evidence: `apexfit/backend/src/controllers/progress.controller.ts`)
- Progress analytics → Plateau analysis: analyzes stalls (evidence: `apexfit/backend/src/controllers/progress.controller.ts`)
- Nutrition tracking → Food photo analysis: analyzes photos (evidence: `apexfit/backend/src/controllers/nutrition.controller.ts`)
- Nutrition tracking → Meal planning: requests plans (evidence: `apexfit/backend/src/controllers/nutrition.controller.ts`)
- Nutrition tracking → Fitness context retrieval: retrieves context (evidence: `apexfit/backend/src/controllers/nutrition.controller.ts`)
- Coach endpoints → AI generation: generates responses (evidence: `apexfit/backend/src/controllers/coach.controller.ts`)
- Coach endpoints → Strength metrics: builds fitness context (evidence: `apexfit/backend/src/controllers/coach.controller.ts`)
- Coach endpoints → Daily briefing: gets briefing (evidence: `apexfit/backend/src/controllers/coach.controller.ts`)
- Coach endpoints → Workout recommendations: requests workouts (evidence: `apexfit/backend/src/controllers/coach.controller.ts`)
- Coach endpoints → Fitness context retrieval: retrieves context (evidence: `apexfit/backend/src/controllers/coach.controller.ts`)
- Fitness context retrieval → Vector embeddings: searches and stores (evidence: `apexfit/backend/src/services/rag.service.ts`)
- Fitness context retrieval → Strength metrics: summarizes lifts (evidence: `apexfit/backend/src/services/rag.service.ts`)
- Fitness context retrieval → Plateau analysis: analyzes causes (evidence: `apexfit/backend/src/services/rag.service.ts`)
- Fitness context retrieval → Application database: reads profile (evidence: `apexfit/backend/src/services/rag.service.ts`)
- Vector embeddings → Application database: stores vectors (evidence: `apexfit/backend/src/config/embeddings.ts`)
- Strength metrics → Application database: reads and writes logs (evidence: `apexfit/backend/src/utils/strength.ts`)
- Meal planning → USDA food data: uses food data (evidence: `apexfit/backend/src/services/mealPlan.service.ts`)
- Coach endpoints → Redis cache: caches reports (evidence: `apexfit/backend/src/controllers/coach.controller.ts`)
