# cvjayanth005-sketch/tracker architecture

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

- Interactive diagram: https://gitdiagram.com/cvjayanth005-sketch/tracker
- Repository: https://github.com/cvjayanth005-sketch/tracker

## Overview

Fat Loss Ledger is a local-first fitness and fat-loss PWA. The user signs in, records food, weight, sleep, runs, and workouts, then navigates Today, Progress, Activity, Food, and Plan views. React reads the Dexie working store through dashboard/repository hooks; pure domain rules derive recommendations, trends, compliance, and adaptive training. Changes synchronize as a document with the FastAPI backend, while optional AI services narrate already-decided results. The graph reflects sampled source and README capabilities; some screen wiring was not sampled.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_bootstrap["App Bootstrap<br/>[main.tsx]"]
  node_shell["App Shell<br/>[App.tsx]"]
  node_auth["Auth Session<br/>[session.ts]"]
  node_google_signin["Google Login<br/>[googleSignIn.ts]"]
  node_dashboard["Dashboard Read Model<br/>[useDashboard.ts]"]
  node_today["Today Screen<br/>[Today.tsx]"]
  node_food["Food Screen<br/>[Food.tsx]"]
  node_activity["Activity Screen<br/>[Activity.tsx]"]
  node_workout["Workout Screen<br/>[WorkoutScreen.tsx]"]
  node_plan["Plan Screen<br/>[Plan.tsx]"]
  node_coach["Coach Commentary<br/>[coachChat.ts]"]
end

subgraph group_decision["Decision Engine"]
  node_rules["Rules Engine<br/>[rules.ts]"]
  node_trends["Trend Analytics<br/>[trend.ts]"]
  node_adaptive["Adaptive Training"]
  node_adaptive_hook["Adaptive Session"]
end

subgraph group_storage["Local Data"]
  node_dexie[("IndexedDB Store<br/>[database.ts]")]
  node_repo["Data Repository<br/>[repo.ts]"]
  node_sync["Sync Client<br/>[client.ts]"]
end

subgraph group_server["Sync Backend"]
  node_api["FastAPI Service<br/>[main.py]"]
  node_backend_services["Backend Services<br/>[services.py]"]
  node_sqlite[("SQLite Store<br/>[database.py]")]
end

node_user(("User"))
node_google["Google Sign-In"]
node_groq["AI Provider"]

node_user -->|"uses"| node_shell
node_bootstrap -->|"renders"| node_shell
node_bootstrap -->|"seeds"| node_dexie
node_shell -->|"reads auth"| node_auth
node_shell -->|"starts login"| node_google_signin
node_google_signin -->|"authenticates"| node_google
node_google_signin -->|"posts credential"| node_api
node_shell -->|"starts sync"| node_sync
node_shell -->|"routes"| node_today
node_shell -->|"routes"| node_food
node_shell -->|"routes"| node_activity
node_shell -->|"routes"| node_workout
node_shell -->|"routes"| node_plan
node_today -->|"derives view"| node_dashboard
node_food -->|"derives view"| node_dashboard
node_activity -->|"derives view"| node_dashboard
node_workout -->|"derives view"| node_dashboard
node_plan -->|"derives view"| node_dashboard
node_dashboard -->|"reads records"| node_repo
node_dashboard -->|"calculates decisions"| node_rules
node_dashboard -->|"calculates trends"| node_trends
node_activity -->|"loads session"| node_adaptive_hook
node_adaptive_hook -->|"builds session"| node_adaptive
node_adaptive_hook -->|"starts workout"| node_repo
node_repo -->|"reads writes"| node_dexie
node_sync -->|"merges state"| node_dexie
node_sync -->|"syncs document"| node_api
node_api -->|"dispatches work"| node_backend_services
node_backend_services -->|"reads writes"| node_sqlite
node_coach -.->|"requests prose"| node_api
node_backend_services -.->|"narrates summary"| node_groq

click node_bootstrap "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/main.tsx"
click node_shell "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/App.tsx"
click node_auth "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/auth/session.ts"
click node_google_signin "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/auth/googleSignIn.ts"
click node_dashboard "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/hooks/useDashboard.ts"
click node_today "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/screens/Today.tsx"
click node_food "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/screens/Food.tsx"
click node_activity "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/screens/Activity.tsx"
click node_workout "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/screens/WorkoutScreen.tsx"
click node_plan "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/screens/Plan.tsx"
click node_coach "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/ai/coachChat.ts"
click node_rules "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/domain/rules.ts"
click node_trends "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/domain/trend.ts"
click node_adaptive "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/domain/adaptiveTraining.ts"
click node_adaptive_hook "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/hooks/useAdaptiveSession.ts"
click node_dexie "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/db/database.ts"
click node_repo "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/db/repo.ts"
click node_sync "https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/sync/client.ts"
click node_api "https://github.com/cvjayanth005-sketch/tracker/blob/main/backend/app/main.py"
click node_backend_services "https://github.com/cvjayanth005-sketch/tracker/blob/main/backend/app/services.py"
click node_sqlite "https://github.com/cvjayanth005-sketch/tracker/blob/main/backend/app/database.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_bootstrap,node_shell,node_auth,node_google_signin,node_dashboard,node_today,node_food,node_activity,node_workout,node_plan,node_coach,node_user toneBlue
class node_rules,node_trends,node_adaptive,node_adaptive_hook toneAmber
class node_dexie,node_repo,node_sync toneMint
class node_api,node_backend_services,node_sqlite toneRose
class node_google,node_groq toneIndigo
```

## Components

### User Experience

- [App Bootstrap](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [App Shell](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Auth Session](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/auth/session.ts): `frontend/src/auth/session.ts`
- [Google Login](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/auth/googleSignIn.ts): `frontend/src/auth/googleSignIn.ts`
- [Dashboard Read Model](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/hooks/useDashboard.ts): `frontend/src/hooks/useDashboard.ts`
- [Today Screen](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/screens/Today.tsx): `frontend/src/screens/Today.tsx`
- [Food Screen](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/screens/Food.tsx): `frontend/src/screens/Food.tsx`
- [Activity Screen](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/screens/Activity.tsx): `frontend/src/screens/Activity.tsx`
- [Workout Screen](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/screens/WorkoutScreen.tsx): `frontend/src/screens/WorkoutScreen.tsx`
- [Plan Screen](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/screens/Plan.tsx): `frontend/src/screens/Plan.tsx`
- [Coach Commentary](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/ai/coachChat.ts): `frontend/src/ai/coachChat.ts`

### Decision Engine

- [Rules Engine](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/domain/rules.ts): `frontend/src/domain/rules.ts`
- [Trend Analytics](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/domain/trend.ts): `frontend/src/domain/trend.ts`
- [Adaptive Training](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/domain/adaptiveTraining.ts): `frontend/src/domain/adaptiveTraining.ts`
- [Adaptive Session](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/hooks/useAdaptiveSession.ts): `frontend/src/hooks/useAdaptiveSession.ts`

### Local Data

- [IndexedDB Store](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/db/database.ts): `frontend/src/db/database.ts`
- [Data Repository](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/db/repo.ts): `frontend/src/db/repo.ts`
- [Sync Client](https://github.com/cvjayanth005-sketch/tracker/blob/main/frontend/src/sync/client.ts): `frontend/src/sync/client.ts`

### Sync Backend

- [FastAPI Service](https://github.com/cvjayanth005-sketch/tracker/blob/main/backend/app/main.py): `backend/app/main.py`
- [Backend Services](https://github.com/cvjayanth005-sketch/tracker/blob/main/backend/app/services.py): `backend/app/services.py`
- [SQLite Store](https://github.com/cvjayanth005-sketch/tracker/blob/main/backend/app/database.py): `backend/app/database.py`

### Other components

- **User**
- **Google Sign-In**
- **AI Provider**

## Connections

- User → App Shell: uses
- App Bootstrap → App Shell: renders
- App Bootstrap → IndexedDB Store: seeds
- App Shell → Auth Session: reads auth
- App Shell → Google Login: starts login
- Google Login → Google Sign-In: authenticates
- Google Login → FastAPI Service: posts credential
- App Shell → Sync Client: starts sync
- App Shell → Today Screen: routes
- App Shell → Food Screen: routes
- App Shell → Activity Screen: routes
- App Shell → Workout Screen: routes
- App Shell → Plan Screen: routes
- Today Screen → Dashboard Read Model: derives view
- Food Screen → Dashboard Read Model: derives view
- Activity Screen → Dashboard Read Model: derives view
- Workout Screen → Dashboard Read Model: derives view
- Plan Screen → Dashboard Read Model: derives view
- Dashboard Read Model → Data Repository: reads records
- Dashboard Read Model → Rules Engine: calculates decisions
- Dashboard Read Model → Trend Analytics: calculates trends
- Activity Screen → Adaptive Session: loads session
- Adaptive Session → Adaptive Training: builds session
- Adaptive Session → Data Repository: starts workout
- Data Repository → IndexedDB Store: reads writes
- Sync Client → IndexedDB Store: merges state
- Sync Client → FastAPI Service: syncs document
- FastAPI Service → Backend Services: dispatches work
- Backend Services → SQLite Store: reads writes
- Coach Commentary → FastAPI Service: requests prose
- Backend Services → AI Provider: narrates summary
