# ka4733231-cloud/food architecture

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

- Interactive diagram: https://gitdiagram.com/ka4733231-cloud/food
- Repository: https://github.com/ka4733231-cloud/food

## Overview

NutriBite is a food and nutrition platform spanning a web frontend, Expo mobile app, and FastAPI service. Its main user journey is scanning food, estimating nutrition, and logging meals; recipe discovery, planning, grocery management, assistant chat, and subscriptions are additional capabilities. The backend persists domain data in a relational database and can consult USDA FoodData Central. Some web and backend route implementations were not excerpted, so uncertain links are omitted or marked unverified.

Main entry points: [`backend/app/main.py`](https://github.com/ka4733231-cloud/food/blob/main/backend/app/main.py) (FastAPI endpoints), [`apps/mobile/src/store/useNutriBiteStore.ts`](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/src/store/useNutriBiteStore.ts) (Mobile app state), [`apps/mobile/src/api/client.ts`](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/src/api/client.ts) (REST API client), [`frontend/js/app.js`](https://github.com/ka4733231-cloud/food/blob/main/frontend/js/app.js) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User Applications"]
  node_mobile["Mobile navigation<br/>[_layout.tsx]"]
  node_scan["Food scanning<br/>[scan.tsx]"]
  node_recipes["Recipe discovery<br/>[recipes.tsx]"]
  node_recipe_detail["Recipe details<br/>[&#91;id&#93;.tsx]"]
  node_planner["Meal planner<br/>[planner.tsx]"]
  node_dashboard["Nutrition dashboard<br/>[index.tsx]"]
  node_profile["Profile and plans<br/>[pricing.tsx]"]
  node_mobile_state["Mobile app state"]
  node_api_client["REST API client<br/>[client.ts]"]
  node_web_app["Web application<br/>[app.js]"]
  node_web_router["Web pages and routes<br/>[router.js]"]
  node_web_state["Web state<br/>[state.js]"]
end

subgraph group_api["API and Intelligence"]
  node_backend["FastAPI endpoints<br/>[main.py]"]
  node_vision["Food recognition<br/>[vision_service.py]"]
end

subgraph group_domain["Food and Planning"]
  node_nutrition["Nutrition analysis"]
  node_assistant["Nutrition assistant"]
  node_recipes_data["Recipe and meal data<br/>[seed_data.py]"]
end

subgraph group_persistence["Persistence"]
  node_schema["Domain models<br/>[models.py]"]
  node_database[("Relational database<br/>[database.py]")]
end

node_user(("Food app user"))
node_usda["USDA FoodData Central"]

node_user -->|"uses"| node_mobile
node_user -->|"uses"| node_web_app
node_scan -->|"submits scans"| node_api_client
node_api_client -->|"calls scan API"| node_backend
node_backend -->|"runs recognition"| node_vision
node_backend -->|"gets nutrition"| node_nutrition
node_backend -->|"processes chat"| node_assistant
node_backend -->|"queries domain"| node_schema
node_backend -->|"opens sessions"| node_database
node_nutrition -->|"queries foods"| node_schema
node_nutrition -->|"searches foods"| node_usda
node_recipes_data -->|"seeds records"| node_database
node_recipes -->|"reads state"| node_mobile_state
node_recipe_detail -->|"reads state"| node_mobile_state
node_planner -->|"updates plan"| node_mobile_state
node_dashboard -->|"reads diary"| node_mobile_state
node_profile -->|"reads subscription"| node_mobile_state
node_api_client -.->|"requests nutrition"| node_backend
node_api_client -->|"sends assistant chat"| node_backend
node_web_app -.->|"routes pages"| node_web_router
node_web_app -.->|"uses state"| node_web_state
node_backend -.->|"uses seeded assets"| node_recipes_data

click node_mobile "https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/(tabs)/_layout.tsx"
click node_scan "https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/(tabs)/scan.tsx"
click node_recipes "https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/(tabs)/recipes.tsx"
click node_recipe_detail "https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/recipe/%5Bid%5D.tsx"
click node_planner "https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/(tabs)/planner.tsx"
click node_dashboard "https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/(tabs)/index.tsx"
click node_profile "https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/pricing.tsx"
click node_mobile_state "https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/src/store/useNutriBiteStore.ts"
click node_api_client "https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/src/api/client.ts"
click node_web_app "https://github.com/ka4733231-cloud/food/blob/main/frontend/js/app.js"
click node_web_router "https://github.com/ka4733231-cloud/food/blob/main/frontend/js/router.js"
click node_web_state "https://github.com/ka4733231-cloud/food/blob/main/frontend/js/state.js"
click node_backend "https://github.com/ka4733231-cloud/food/blob/main/backend/app/main.py"
click node_vision "https://github.com/ka4733231-cloud/food/blob/main/backend/app/services/vision_service.py"
click node_nutrition "https://github.com/ka4733231-cloud/food/blob/main/backend/app/services/nutrition_service.py"
click node_assistant "https://github.com/ka4733231-cloud/food/blob/main/backend/app/services/assistant_service.py"
click node_recipes_data "https://github.com/ka4733231-cloud/food/blob/main/backend/app/seed_data.py"
click node_schema "https://github.com/ka4733231-cloud/food/blob/main/backend/app/models.py"
click node_database "https://github.com/ka4733231-cloud/food/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_mobile,node_scan,node_recipes,node_recipe_detail,node_planner,node_dashboard,node_profile,node_mobile_state,node_api_client,node_web_app,node_web_router,node_web_state,node_user toneBlue
class node_backend,node_vision toneAmber
class node_nutrition,node_assistant,node_recipes_data toneMint
class node_schema,node_database toneRose
class node_usda toneIndigo
```

## Components

### User Applications

- [Mobile navigation](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/(tabs)/_layout.tsx): `apps/mobile/app/(tabs)/_layout.tsx`
- [Food scanning](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/(tabs)/scan.tsx): `apps/mobile/app/(tabs)/scan.tsx`
- [Recipe discovery](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/(tabs)/recipes.tsx): `apps/mobile/app/(tabs)/recipes.tsx`
- [Recipe details](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/recipe/%5Bid%5D.tsx): `apps/mobile/app/recipe/[id].tsx`
- [Meal planner](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/(tabs)/planner.tsx): `apps/mobile/app/(tabs)/planner.tsx`
- [Nutrition dashboard](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/(tabs)/index.tsx): `apps/mobile/app/(tabs)/index.tsx`
- [Profile and plans](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/app/pricing.tsx): `apps/mobile/app/pricing.tsx`
- [Mobile app state](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/src/store/useNutriBiteStore.ts): `apps/mobile/src/store/useNutriBiteStore.ts`
- [REST API client](https://github.com/ka4733231-cloud/food/blob/main/apps/mobile/src/api/client.ts): `apps/mobile/src/api/client.ts`
- [Web application](https://github.com/ka4733231-cloud/food/blob/main/frontend/js/app.js): `frontend/js/app.js`
- [Web pages and routes](https://github.com/ka4733231-cloud/food/blob/main/frontend/js/router.js): `frontend/js/router.js`
- [Web state](https://github.com/ka4733231-cloud/food/blob/main/frontend/js/state.js): `frontend/js/state.js`

### API and Intelligence

- [FastAPI endpoints](https://github.com/ka4733231-cloud/food/blob/main/backend/app/main.py): `backend/app/main.py`
- [Food recognition](https://github.com/ka4733231-cloud/food/blob/main/backend/app/services/vision_service.py): `backend/app/services/vision_service.py`

### Food and Planning

- [Nutrition analysis](https://github.com/ka4733231-cloud/food/blob/main/backend/app/services/nutrition_service.py): `backend/app/services/nutrition_service.py`
- [Nutrition assistant](https://github.com/ka4733231-cloud/food/blob/main/backend/app/services/assistant_service.py): `backend/app/services/assistant_service.py`
- [Recipe and meal data](https://github.com/ka4733231-cloud/food/blob/main/backend/app/seed_data.py): `backend/app/seed_data.py`

### Persistence

- [Domain models](https://github.com/ka4733231-cloud/food/blob/main/backend/app/models.py): `backend/app/models.py`
- [Relational database](https://github.com/ka4733231-cloud/food/blob/main/backend/app/database.py): `backend/app/database.py`

### Other components

- **Food app user**
- **USDA FoodData Central**

## Connections

- Food app user → Mobile navigation: uses (evidence: `README.md`)
- Food app user → Web application: uses (evidence: `README.md`)
- Food scanning → REST API client: submits scans (evidence: `apps/mobile/app/(tabs)/scan.tsx`)
- REST API client → FastAPI endpoints: calls scan API (evidence: `apps/mobile/src/api/client.ts`)
- FastAPI endpoints → Food recognition: runs recognition (evidence: `backend/app/main.py`)
- FastAPI endpoints → Nutrition analysis: gets nutrition (evidence: `backend/app/main.py`)
- FastAPI endpoints → Nutrition assistant: processes chat (evidence: `backend/app/main.py`)
- FastAPI endpoints → Domain models: queries domain (evidence: `backend/app/main.py`)
- FastAPI endpoints → Relational database: opens sessions (evidence: `backend/app/main.py`)
- Nutrition analysis → Domain models: queries foods (evidence: `backend/app/services/nutrition_service.py`)
- Nutrition analysis → USDA FoodData Central: searches foods (evidence: `backend/app/services/nutrition_service.py`)
- Recipe and meal data → Relational database: seeds records (evidence: `backend/app/seed_data.py`)
- Recipe discovery → Mobile app state: reads state (evidence: `apps/mobile/app/(tabs)/recipes.tsx`)
- Recipe details → Mobile app state: reads state (evidence: `apps/mobile/app/recipe/[id].tsx`)
- Meal planner → Mobile app state: updates plan (evidence: `apps/mobile/app/(tabs)/planner.tsx`)
- Nutrition dashboard → Mobile app state: reads diary (evidence: `apps/mobile/app/(tabs)/index.tsx`)
- Profile and plans → Mobile app state: reads subscription (evidence: `apps/mobile/app/pricing.tsx`)
- REST API client → FastAPI endpoints: requests nutrition
- REST API client → FastAPI endpoints: sends assistant chat (evidence: `apps/mobile/src/api/client.ts`)
- Web application → Web pages and routes: routes pages
- Web application → Web state: uses state
- FastAPI endpoints → Recipe and meal data: uses seeded assets (evidence: `backend/app/main.py`)
