# augaish/calapp architecture

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

- Interactive diagram: https://gitdiagram.com/augaish/calapp
- Repository: https://github.com/augaish/calapp

## Overview

CalApp is a bilingual Arabic/English calorie and gym-coaching app. Its main workflow is onboarding and target calculation, followed by meal or equipment scanning, user review/editing, and logging; local-first profile, meal, and workout data persist on-device. The README documents demo-mode scans and an optional AI backend, while the sampled server entry point shows provider selection and WHOOP authorization. Several capabilities are represented from the README and source index; unsampled implementation details and their internal links are intentionally not inferred.

Main entry points: [`server/src/index.ts`](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/index.ts) (HTTP API and routing), [`src/lib/store.ts`](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/store.ts) (App state), [`src/app/(tabs)/index.tsx`](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/(tabs)/index.tsx) (Daily dashboard), [`src/app/scan.tsx`](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/scan.tsx) (Meal scan and review)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App experience"]
  node_onboarding["Onboarding<br/>[onboarding.tsx]"]
  node_dashboard["Daily dashboard<br/>[index.tsx]"]
  node_meal_scan["Meal scan and review<br/>[scan.tsx]"]
  node_food_features["Food and recipes<br/>[food.tsx]"]
  node_gym_scan["Gym equipment scan<br/>[photo-analyze.tsx]"]
  node_workout["Workout session<br/>[session.tsx]"]
  node_program["Programs and schedules<br/>[program.tsx]"]
  node_review["Progress review<br/>[review.tsx]"]
end

subgraph group_domain["Domain and state"]
  node_api_client["API client<br/>[api.ts]"]
  node_nutrition["Nutrition calculations<br/>[recipes.ts]"]
  node_tdee["TDEE targets<br/>[tdee.ts]"]
  node_exercise_catalog["Exercise catalog<br/>[exercises.ts]"]
  node_app_state["App state<br/>[store.ts]"]
  node_local_storage[("Device storage")]
end

subgraph group_backend["Backend services"]
  node_backend_entry["HTTP API and routing<br/>[index.ts]"]
  node_ai_analysis["AI analysis<br/>[parse.ts]"]
  node_billing["Access and quotas<br/>[billing.ts]"]
  node_wearable["WHOOP integration<br/>[whoop.ts]"]
  node_backend_db[("Backend data services<br/>[db.ts]")]
end

subgraph group_presentation["Shared presentation"]
  node_presentation["Shared UI components"]
  node_theme["Theme tokens<br/>[theme.ts]"]
  node_localization["Arabic and English<br/>[i18n.ts]"]
end

node_user(("User"))
node_ai_provider{{"Anthropic AI"}}

node_user -->|"sets up profile"| node_onboarding
node_onboarding -->|"computes targets"| node_tdee
node_user -->|"scans meal"| node_meal_scan
node_meal_scan -.->|"requests analysis"| node_api_client
node_api_client -->|"sends API request"| node_backend_entry
node_backend_entry -->|"routes analysis"| node_ai_analysis
node_ai_analysis -.->|"requests AI analysis"| node_ai_provider
node_meal_scan -.->|"edits and logs"| node_nutrition
node_user -->|"scans equipment"| node_gym_scan
node_gym_scan -.->|"requests analysis"| node_api_client
node_user -->|"views daily plan"| node_dashboard
node_dashboard -->|"reads daily data"| node_app_state
node_user -->|"manages food"| node_food_features
node_food_features -->|"uses recipe math"| node_nutrition
node_user -->|"logs training"| node_workout
node_workout -->|"updates workout data"| node_app_state
node_workout -->|"uses exercise data"| node_exercise_catalog
node_user -->|"manages program"| node_program
node_program -->|"uses saved state"| node_app_state
node_user -->|"reviews progress"| node_review
node_review -->|"reads logged activity"| node_app_state
node_app_state -->|"persists state"| node_local_storage
node_backend_entry -->|"checks access"| node_billing
node_backend_entry -->|"uses wearable data"| node_wearable
node_backend_entry -->|"uses data services"| node_backend_db
node_dashboard -->|"renders shared UI"| node_presentation
node_presentation -->|"uses theme tokens"| node_theme
node_presentation -->|"localizes icons and text"| node_localization

click node_onboarding "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/onboarding.tsx"
click node_dashboard "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/(tabs)/index.tsx"
click node_meal_scan "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/scan.tsx"
click node_food_features "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/(tabs)/food.tsx"
click node_gym_scan "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/photo-analyze.tsx"
click node_workout "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/session.tsx"
click node_program "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/program.tsx"
click node_review "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/review.tsx"
click node_api_client "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/api.ts"
click node_nutrition "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/recipes.ts"
click node_tdee "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/tdee.ts"
click node_exercise_catalog "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/exercises.ts"
click node_app_state "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/store.ts"
click node_backend_entry "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/index.ts"
click node_ai_analysis "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/parse.ts"
click node_billing "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/billing.ts"
click node_wearable "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/whoop.ts"
click node_backend_db "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/db.ts"
click node_presentation "https://github.com/augaish/calapp/tree/claude/ai-meal-gym-tracker-lxtx25/src/components"
click node_theme "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/constants/theme.ts"
click node_localization "https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/i18n.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_onboarding,node_dashboard,node_meal_scan,node_food_features,node_gym_scan,node_workout,node_program,node_review,node_user toneBlue
class node_api_client,node_nutrition,node_tdee,node_exercise_catalog,node_app_state,node_local_storage toneAmber
class node_backend_entry,node_ai_analysis,node_billing,node_wearable,node_backend_db toneMint
class node_presentation,node_theme,node_localization toneRose
class node_ai_provider toneIndigo
```

## Components

### App experience

- [Onboarding](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/onboarding.tsx): `src/app/onboarding.tsx`
- [Daily dashboard](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/(tabs)/index.tsx): `src/app/(tabs)/index.tsx`
- [Meal scan and review](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/scan.tsx): `src/app/scan.tsx`
- [Food and recipes](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/(tabs)/food.tsx): `src/app/(tabs)/food.tsx`
- [Gym equipment scan](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/photo-analyze.tsx): `src/app/photo-analyze.tsx`
- [Workout session](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/session.tsx): `src/app/session.tsx`
- [Programs and schedules](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/program.tsx): `src/app/program.tsx`
- [Progress review](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/app/review.tsx): `src/app/review.tsx`

### Domain and state

- [API client](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/api.ts): `src/lib/api.ts`
- [Nutrition calculations](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/recipes.ts): `src/lib/recipes.ts`
- [TDEE targets](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/tdee.ts): `src/lib/tdee.ts`
- [Exercise catalog](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/exercises.ts): `src/lib/exercises.ts`
- [App state](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/store.ts): `src/lib/store.ts`
- **Device storage**

### Backend services

- [HTTP API and routing](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/index.ts): `server/src/index.ts`
- [AI analysis](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/parse.ts): `server/src/parse.ts`
- [Access and quotas](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/billing.ts): `server/src/billing.ts`
- [WHOOP integration](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/whoop.ts): `server/src/whoop.ts`
- [Backend data services](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/server/src/db.ts): `server/src/db.ts`

### Shared presentation

- [Shared UI components](https://github.com/augaish/calapp/tree/claude/ai-meal-gym-tracker-lxtx25/src/components): `src/components`
- [Theme tokens](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/constants/theme.ts): `src/constants/theme.ts`
- [Arabic and English](https://github.com/augaish/calapp/blob/claude/ai-meal-gym-tracker-lxtx25/src/lib/i18n.ts): `src/lib/i18n.ts`

### Other components

- **User**
- **Anthropic AI**

## Connections

- User → Onboarding: sets up profile (evidence: `README.md`)
- Onboarding → TDEE targets: computes targets (evidence: `README.md`)
- User → Meal scan and review: scans meal (evidence: `README.md`)
- Meal scan and review → API client: requests analysis (evidence: `README.md`)
- API client → HTTP API and routing: sends API request (evidence: `README.md`)
- HTTP API and routing → AI analysis: routes analysis (evidence: `server/src/index.ts`)
- AI analysis → Anthropic AI: requests AI analysis (evidence: `README.md`)
- Meal scan and review → Nutrition calculations: edits and logs (evidence: `README.md`)
- User → Gym equipment scan: scans equipment (evidence: `README.md`)
- Gym equipment scan → API client: requests analysis (evidence: `README.md`)
- User → Daily dashboard: views daily plan (evidence: `README.md`)
- Daily dashboard → App state: reads daily data (evidence: `src/app/(tabs)/index.tsx`)
- User → Food and recipes: manages food (evidence: `README.md`)
- Food and recipes → Nutrition calculations: uses recipe math (evidence: `src/lib/recipes.ts`)
- User → Workout session: logs training (evidence: `README.md`)
- Workout session → App state: updates workout data (evidence: `src/app/session.tsx`)
- Workout session → Exercise catalog: uses exercise data (evidence: `src/app/session.tsx`)
- User → Programs and schedules: manages program (evidence: `src/app/program.tsx`)
- Programs and schedules → App state: uses saved state (evidence: `src/app/program.tsx`)
- User → Progress review: reviews progress (evidence: `src/app/review.tsx`)
- Progress review → App state: reads logged activity (evidence: `src/app/review.tsx`)
- App state → Device storage: persists state (evidence: `src/lib/store.ts`)
- HTTP API and routing → Access and quotas: checks access (evidence: `server/src/index.ts`)
- HTTP API and routing → WHOOP integration: uses wearable data (evidence: `server/src/index.ts`)
- HTTP API and routing → Backend data services: uses data services (evidence: `server/src/index.ts`)
- Daily dashboard → Shared UI components: renders shared UI (evidence: `src/app/(tabs)/index.tsx`)
- Shared UI components → Theme tokens: uses theme tokens (evidence: `src/components/system.tsx`)
- Shared UI components → Arabic and English: localizes icons and text (evidence: `src/components/icon.tsx`)
