# callmejarod/jafit architecture

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

- Interactive diagram: https://gitdiagram.com/callmejarod/jafit
- Repository: https://github.com/callmejarod/jafit
- Video tour (about a minute): https://gitdiagram.com/callmejarod/jafit/video

## Overview

JaFit is a cross-platform fitness app with an Expo client and FastAPI backend. The principal supported flow is account registration/login and token-based identity: the API validates credentials, issues JWTs, and the client checks a stored token against the current-user endpoint. Authenticated API routes also support fitness profiles and calorie targets, meals and nutrition summaries, and workout records. The README lists AI coaching as planned; no implementation appears in the tree. Edges reflect shown calls, imports, or documented capabilities; client login-screen wiring and several unsampled route details are not inferred.

Main entry points: [`backend/app/routes/users.py`](https://github.com/callmejarod/jafit/blob/main/backend/app/routes/users.py) (User endpoints), [`backend/app/main.py`](https://github.com/callmejarod/jafit/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/database/mongodb.py`](https://github.com/callmejarod/jafit/blob/main/backend/app/database/mongodb.py) (MongoDB collections), [`backend/app/routes/profiles.py`](https://github.com/callmejarod/jafit/blob/main/backend/app/routes/profiles.py) (Fitness profiles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Mobile client"]
  node_login_screen["Login screen<br/>[login.tsx]"]
  node_dashboard_screen["Home screen<br/>[index.tsx]"]
  node_auth_context["Client auth state<br/>[AuthContext.tsx]"]
end

subgraph group_api["API routing"]
  node_api_app["FastAPI application<br/>[main.py]"]
end

subgraph group_identity["Identity and profiles"]
  node_users_route["User endpoints<br/>[users.py]"]
  node_auth_service["JWT authentication<br/>[auth.py]"]
  node_security_service["Password security<br/>[security.py]"]
  node_user_model["User and login models<br/>[user.py]"]
  node_login_model["Login request model<br/>[login.py]"]
end

subgraph group_tracking["Fitness tracking"]
  node_profile_route["Fitness profiles<br/>[profiles.py]"]
  node_profile_model["Fitness profile model<br/>[fitnessProfile.py]"]
  node_calorie_service["Calorie and macro estimates"]
  node_meals_route["Meal tracking and summary<br/>[meals.py]"]
  node_meal_model["Meal and food models<br/>[meal.py]"]
  node_workouts_route["Workout tracking<br/>[workouts.py]"]
  node_workout_model["Workout model<br/>[workout.py]"]
  node_dashboard_route["Fitness dashboard data<br/>[dashboard.py]"]
  node_ai_coach["AI fitness coach planned"]
end

subgraph group_storage["Persistence"]
  node_mongo[("MongoDB collections<br/>[mongodb.py]")]
end

node_user(("App user"))

node_user -.->|"starts sign-in"| node_login_screen
node_login_screen -.->|"signs in"| node_users_route
node_auth_context -->|"checks token"| node_users_route
node_api_app -->|"mounts router"| node_users_route
node_api_app -->|"mounts router"| node_workouts_route
node_api_app -->|"mounts router"| node_meals_route
node_api_app -->|"mounts router"| node_profile_route
node_api_app -->|"mounts router"| node_dashboard_route
node_users_route -->|"validates user"| node_user_model
node_users_route -->|"uses login model"| node_login_model
node_users_route -->|"hashes passwords"| node_security_service
node_users_route -->|"issues tokens"| node_auth_service
node_users_route -->|"reads and writes users"| node_mongo
node_profile_route -->|"validates profile"| node_profile_model
node_profile_route -->|"calculates targets"| node_calorie_service
node_profile_route -->|"reads and writes profiles"| node_mongo
node_meals_route -->|"validates meals"| node_meal_model
node_meals_route -->|"reads and writes meals"| node_mongo
node_workouts_route -->|"validates workouts"| node_workout_model
node_workouts_route -->|"reads and writes workouts"| node_mongo
node_dashboard_route -->|"reads fitness data"| node_mongo
node_dashboard_route -->|"calculates calories"| node_calorie_service

click node_login_screen "https://github.com/callmejarod/jafit/blob/main/frontend/app/login.tsx"
click node_dashboard_screen "https://github.com/callmejarod/jafit/blob/main/frontend/app/(tabs)/index.tsx"
click node_auth_context "https://github.com/callmejarod/jafit/blob/main/frontend/context/AuthContext.tsx"
click node_api_app "https://github.com/callmejarod/jafit/blob/main/backend/app/main.py"
click node_users_route "https://github.com/callmejarod/jafit/blob/main/backend/app/routes/users.py"
click node_auth_service "https://github.com/callmejarod/jafit/blob/main/backend/app/services/auth.py"
click node_security_service "https://github.com/callmejarod/jafit/blob/main/backend/app/services/security.py"
click node_user_model "https://github.com/callmejarod/jafit/blob/main/backend/app/models/user.py"
click node_login_model "https://github.com/callmejarod/jafit/blob/main/backend/app/models/login.py"
click node_profile_route "https://github.com/callmejarod/jafit/blob/main/backend/app/routes/profiles.py"
click node_profile_model "https://github.com/callmejarod/jafit/blob/main/backend/app/models/fitnessProfile.py"
click node_calorie_service "https://github.com/callmejarod/jafit/blob/main/backend/app/services/calorie_calculator.py"
click node_meals_route "https://github.com/callmejarod/jafit/blob/main/backend/app/routes/meals.py"
click node_meal_model "https://github.com/callmejarod/jafit/blob/main/backend/app/models/meal.py"
click node_workouts_route "https://github.com/callmejarod/jafit/blob/main/backend/app/routes/workouts.py"
click node_workout_model "https://github.com/callmejarod/jafit/blob/main/backend/app/models/workout.py"
click node_dashboard_route "https://github.com/callmejarod/jafit/blob/main/backend/app/routes/dashboard.py"
click node_mongo "https://github.com/callmejarod/jafit/blob/main/backend/app/database/mongodb.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_login_screen,node_dashboard_screen,node_auth_context,node_user toneBlue
class node_api_app toneAmber
class node_users_route,node_auth_service,node_security_service,node_user_model,node_login_model toneMint
class node_profile_route,node_profile_model,node_calorie_service,node_meals_route,node_meal_model,node_workouts_route,node_workout_model,node_dashboard_route,node_ai_coach toneRose
class node_mongo toneIndigo
```

## Components

### Mobile client

- [Login screen](https://github.com/callmejarod/jafit/blob/main/frontend/app/login.tsx): `frontend/app/login.tsx`
- [Home screen](https://github.com/callmejarod/jafit/blob/main/frontend/app/(tabs)/index.tsx): `frontend/app/(tabs)/index.tsx`
- [Client auth state](https://github.com/callmejarod/jafit/blob/main/frontend/context/AuthContext.tsx): `frontend/context/AuthContext.tsx`

### API routing

- [FastAPI application](https://github.com/callmejarod/jafit/blob/main/backend/app/main.py): `backend/app/main.py`

### Identity and profiles

- [User endpoints](https://github.com/callmejarod/jafit/blob/main/backend/app/routes/users.py): `backend/app/routes/users.py`
- [JWT authentication](https://github.com/callmejarod/jafit/blob/main/backend/app/services/auth.py): `backend/app/services/auth.py`
- [Password security](https://github.com/callmejarod/jafit/blob/main/backend/app/services/security.py): `backend/app/services/security.py`
- [User and login models](https://github.com/callmejarod/jafit/blob/main/backend/app/models/user.py): `backend/app/models/user.py`
- [Login request model](https://github.com/callmejarod/jafit/blob/main/backend/app/models/login.py): `backend/app/models/login.py`

### Fitness tracking

- [Fitness profiles](https://github.com/callmejarod/jafit/blob/main/backend/app/routes/profiles.py): `backend/app/routes/profiles.py`
- [Fitness profile model](https://github.com/callmejarod/jafit/blob/main/backend/app/models/fitnessProfile.py): `backend/app/models/fitnessProfile.py`
- [Calorie and macro estimates](https://github.com/callmejarod/jafit/blob/main/backend/app/services/calorie_calculator.py): `backend/app/services/calorie_calculator.py`
- [Meal tracking and summary](https://github.com/callmejarod/jafit/blob/main/backend/app/routes/meals.py): `backend/app/routes/meals.py`
- [Meal and food models](https://github.com/callmejarod/jafit/blob/main/backend/app/models/meal.py): `backend/app/models/meal.py`
- [Workout tracking](https://github.com/callmejarod/jafit/blob/main/backend/app/routes/workouts.py): `backend/app/routes/workouts.py`
- [Workout model](https://github.com/callmejarod/jafit/blob/main/backend/app/models/workout.py): `backend/app/models/workout.py`
- [Fitness dashboard data](https://github.com/callmejarod/jafit/blob/main/backend/app/routes/dashboard.py): `backend/app/routes/dashboard.py`
- **AI fitness coach planned**

### Persistence

- [MongoDB collections](https://github.com/callmejarod/jafit/blob/main/backend/app/database/mongodb.py): `backend/app/database/mongodb.py`

### Other components

- **App user**

## Connections

- App user → Login screen: starts sign-in
- Login screen → User endpoints: signs in
- Client auth state → User endpoints: checks token (evidence: `frontend/context/AuthContext.tsx`)
- FastAPI application → User endpoints: mounts router (evidence: `backend/app/main.py`)
- FastAPI application → Workout tracking: mounts router (evidence: `backend/app/main.py`)
- FastAPI application → Meal tracking and summary: mounts router (evidence: `backend/app/main.py`)
- FastAPI application → Fitness profiles: mounts router (evidence: `backend/app/main.py`)
- FastAPI application → Fitness dashboard data: mounts router (evidence: `backend/app/main.py`)
- User endpoints → User and login models: validates user (evidence: `backend/app/routes/users.py`)
- User endpoints → Login request model: uses login model (evidence: `backend/app/routes/users.py`)
- User endpoints → Password security: hashes passwords (evidence: `backend/app/routes/users.py`)
- User endpoints → JWT authentication: issues tokens (evidence: `backend/app/routes/users.py`)
- User endpoints → MongoDB collections: reads and writes users (evidence: `backend/app/routes/users.py`)
- Fitness profiles → Fitness profile model: validates profile (evidence: `backend/app/routes/profiles.py`)
- Fitness profiles → Calorie and macro estimates: calculates targets (evidence: `backend/app/routes/profiles.py`)
- Fitness profiles → MongoDB collections: reads and writes profiles (evidence: `backend/app/routes/profiles.py`)
- Meal tracking and summary → Meal and food models: validates meals (evidence: `backend/app/routes/meals.py`)
- Meal tracking and summary → MongoDB collections: reads and writes meals (evidence: `backend/app/routes/meals.py`)
- Workout tracking → Workout model: validates workouts (evidence: `backend/app/routes/workouts.py`)
- Workout tracking → MongoDB collections: reads and writes workouts (evidence: `backend/app/routes/workouts.py`)
- Fitness dashboard data → MongoDB collections: reads fitness data (evidence: `backend/app/routes/dashboard.py`)
- Fitness dashboard data → Calorie and macro estimates: calculates calories (evidence: `backend/app/routes/dashboard.py`)
