# lohith400/nutrition_traker architecture

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

- Interactive diagram: https://gitdiagram.com/lohith400/nutrition_traker
- Repository: https://github.com/lohith400/nutrition_traker

## Overview

NutriSync is an Indian-food nutrition coach: users set up a profile, log meals or water, review nutrition and activity, and can ask an optional AI coach for suggestions or actions. The dashboard calls a FastAPI service; deterministic nutrition logic and food matching support the coach and logging, while profile and history persist in SQLite or Turso. The README documents reminders, grocery planning, restaurant search, and fitness integration. Some frontend-to-API and unsampled feature relationships are documented rather than verified in source excerpts.

Main entry points: [`backend/orchestrator.py`](https://github.com/lohith400/nutrition_traker/blob/main/backend/orchestrator.py) (Coach orchestrator), [`backend/app.py`](https://github.com/lohith400/nutrition_traker/blob/main/backend/app.py) (HTTP API), [`backend/reminders.py`](https://github.com/lohith400/nutrition_traker/blob/main/backend/reminders.py) (Reminders), [`backend/math_engine.py`](https://github.com/lohith400/nutrition_traker/blob/main/backend/math_engine.py) (Nutrition calculations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_dashboard_pages["Dashboard pages"]
  node_chat["Coach chat<br/>[page.tsx]"]
  node_voice["Voice chat<br/>[useVoiceChat.ts]"]
  node_shell["Navigation shell<br/>[Shell.tsx]"]
  node_access["Access gate<br/>[AccessGate.tsx]"]
end

subgraph group_api["API"]
  node_api_service["HTTP API<br/>[app.py]"]
  node_coach["Coach orchestrator<br/>[orchestrator.py]"]
end

subgraph group_nutrition["Nutrition"]
  node_nutrition_math["Nutrition calculations<br/>[math_engine.py]"]
  node_food_match["Food resolver<br/>[rag_resolver.py]"]
  node_food_quality["Food quality rules<br/>[food_quality.py]"]
  node_meal_planner["Meal planner<br/>[menu_planner.py]"]
end

subgraph group_state["Persistence"]
  node_memory["Profile and meal memory<br/>[memory_agent.py]"]
  node_database[("SQLite or Turso<br/>[database.py]")]
  node_db_builder["Food database builder<br/>[db_setup.py]"]
end

subgraph group_integrations["Integrations"]
  node_grocery["Grocery planning<br/>[grocery.py]"]
  node_reminders["Reminders<br/>[reminders.py]"]
  node_fitness["Google Fit sync<br/>[google_fit.py]"]
  node_places["Restaurant search<br/>[places_finder.py]"]
  node_llm["LLM provider config<br/>[llm_config.py]"]
end

node_user(("User"))
node_fitness_provider(("Google Fit"))
node_llm_provider(("LLM provider"))
node_notification_services(("Notification services"))

node_user -->|"uses"| node_dashboard_pages
node_dashboard_pages -.->|"calls API"| node_api_service
node_chat -->|"uses"| node_voice
node_dashboard_pages -.->|"renders"| node_shell
node_dashboard_pages -->|"gates access"| node_access
node_api_service -->|"routes profile"| node_memory
node_api_service -->|"routes reminders"| node_reminders
node_api_service -->|"imports"| node_coach
node_api_service -->|"imports"| node_nutrition_math
node_api_service -->|"imports"| node_meal_planner
node_api_service -->|"imports"| node_food_match
node_api_service -->|"imports"| node_fitness
node_coach -->|"requests completion"| node_llm
node_coach -->|"uses calculations"| node_nutrition_math
node_coach -->|"uses profile data"| node_memory
node_coach -->|"uses suggestions"| node_meal_planner
node_coach -->|"resolves foods"| node_food_match
node_coach -->|"checks groceries"| node_grocery
node_coach -->|"searches restaurants"| node_places
node_coach -->|"handles reminders"| node_reminders
node_coach -->|"reads fitness"| node_fitness
node_llm -.->|"configures access"| node_llm_provider
node_fitness -->|"fetches activity"| node_fitness_provider
node_reminders -.->|"sends notices"| node_notification_services
node_reminders -->|"resolves foods"| node_food_match
node_reminders -->|"calculates macros"| node_nutrition_math
node_reminders -->|"logs meals"| node_memory
node_memory -->|"reads and writes"| node_database
node_nutrition_math -->|"reads food and logs"| node_database
node_nutrition_math -->|"uses diet rules"| node_food_quality
node_food_match -->|"reads food rows"| node_database
node_food_match -->|"filters diet"| node_food_quality
node_meal_planner -->|"reads food data"| node_database
node_meal_planner -->|"uses quality rules"| node_food_quality
node_db_builder -->|"uses adapter"| node_database
node_db_builder -->|"grades food rows"| node_food_quality

click node_dashboard_pages "https://github.com/lohith400/nutrition_traker/tree/main/frontend/app"
click node_chat "https://github.com/lohith400/nutrition_traker/blob/main/frontend/app/chat/page.tsx"
click node_voice "https://github.com/lohith400/nutrition_traker/blob/main/frontend/app/hooks/useVoiceChat.ts"
click node_shell "https://github.com/lohith400/nutrition_traker/blob/main/frontend/app/components/Shell.tsx"
click node_access "https://github.com/lohith400/nutrition_traker/blob/main/frontend/app/components/AccessGate.tsx"
click node_api_service "https://github.com/lohith400/nutrition_traker/blob/main/backend/app.py"
click node_coach "https://github.com/lohith400/nutrition_traker/blob/main/backend/orchestrator.py"
click node_nutrition_math "https://github.com/lohith400/nutrition_traker/blob/main/backend/math_engine.py"
click node_food_match "https://github.com/lohith400/nutrition_traker/blob/main/backend/rag_resolver.py"
click node_food_quality "https://github.com/lohith400/nutrition_traker/blob/main/backend/food_quality.py"
click node_meal_planner "https://github.com/lohith400/nutrition_traker/blob/main/backend/menu_planner.py"
click node_memory "https://github.com/lohith400/nutrition_traker/blob/main/backend/memory_agent.py"
click node_database "https://github.com/lohith400/nutrition_traker/blob/main/backend/database.py"
click node_db_builder "https://github.com/lohith400/nutrition_traker/blob/main/backend/db_setup.py"
click node_grocery "https://github.com/lohith400/nutrition_traker/blob/main/backend/grocery.py"
click node_reminders "https://github.com/lohith400/nutrition_traker/blob/main/backend/reminders.py"
click node_fitness "https://github.com/lohith400/nutrition_traker/blob/main/backend/google_fit.py"
click node_places "https://github.com/lohith400/nutrition_traker/blob/main/backend/places_finder.py"
click node_llm "https://github.com/lohith400/nutrition_traker/blob/main/backend/llm_config.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_dashboard_pages,node_chat,node_voice,node_shell,node_access,node_user toneBlue
class node_api_service,node_coach toneAmber
class node_nutrition_math,node_food_match,node_food_quality,node_meal_planner toneMint
class node_memory,node_database,node_db_builder toneRose
class node_grocery,node_reminders,node_fitness,node_places,node_llm,node_fitness_provider,node_llm_provider,node_notification_services toneIndigo
```

## Components

### Dashboard

- [Dashboard pages](https://github.com/lohith400/nutrition_traker/tree/main/frontend/app): `frontend/app`
- [Coach chat](https://github.com/lohith400/nutrition_traker/blob/main/frontend/app/chat/page.tsx): `frontend/app/chat/page.tsx`
- [Voice chat](https://github.com/lohith400/nutrition_traker/blob/main/frontend/app/hooks/useVoiceChat.ts): `frontend/app/hooks/useVoiceChat.ts`
- [Navigation shell](https://github.com/lohith400/nutrition_traker/blob/main/frontend/app/components/Shell.tsx): `frontend/app/components/Shell.tsx`
- [Access gate](https://github.com/lohith400/nutrition_traker/blob/main/frontend/app/components/AccessGate.tsx): `frontend/app/components/AccessGate.tsx`

### API

- [HTTP API](https://github.com/lohith400/nutrition_traker/blob/main/backend/app.py): `backend/app.py`
- [Coach orchestrator](https://github.com/lohith400/nutrition_traker/blob/main/backend/orchestrator.py): `backend/orchestrator.py`

### Nutrition

- [Nutrition calculations](https://github.com/lohith400/nutrition_traker/blob/main/backend/math_engine.py): `backend/math_engine.py`
- [Food resolver](https://github.com/lohith400/nutrition_traker/blob/main/backend/rag_resolver.py): `backend/rag_resolver.py`
- [Food quality rules](https://github.com/lohith400/nutrition_traker/blob/main/backend/food_quality.py): `backend/food_quality.py`
- [Meal planner](https://github.com/lohith400/nutrition_traker/blob/main/backend/menu_planner.py): `backend/menu_planner.py`

### Persistence

- [Profile and meal memory](https://github.com/lohith400/nutrition_traker/blob/main/backend/memory_agent.py): `backend/memory_agent.py`
- [SQLite or Turso](https://github.com/lohith400/nutrition_traker/blob/main/backend/database.py): `backend/database.py`
- [Food database builder](https://github.com/lohith400/nutrition_traker/blob/main/backend/db_setup.py): `backend/db_setup.py`

### Integrations

- [Grocery planning](https://github.com/lohith400/nutrition_traker/blob/main/backend/grocery.py): `backend/grocery.py`
- [Reminders](https://github.com/lohith400/nutrition_traker/blob/main/backend/reminders.py): `backend/reminders.py`
- [Google Fit sync](https://github.com/lohith400/nutrition_traker/blob/main/backend/google_fit.py): `backend/google_fit.py`
- [Restaurant search](https://github.com/lohith400/nutrition_traker/blob/main/backend/places_finder.py): `backend/places_finder.py`
- [LLM provider config](https://github.com/lohith400/nutrition_traker/blob/main/backend/llm_config.py): `backend/llm_config.py`

### Other components

- **User**
- **Google Fit**
- **LLM provider**
- **Notification services**

## Connections

- User → Dashboard pages: uses (evidence: `README.md`)
- Dashboard pages → HTTP API: calls API (evidence: `README.md`)
- Coach chat → Voice chat: uses (evidence: `frontend/app/chat/page.tsx`)
- Dashboard pages → Navigation shell: renders (evidence: `frontend/app/grocery/page.tsx`)
- Dashboard pages → Access gate: gates access (evidence: `frontend/app/layout.tsx`)
- HTTP API → Profile and meal memory: routes profile (evidence: `backend/app.py`)
- HTTP API → Reminders: routes reminders (evidence: `backend/app.py`)
- HTTP API → Coach orchestrator: imports (evidence: `backend/app.py`)
- HTTP API → Nutrition calculations: imports (evidence: `backend/app.py`)
- HTTP API → Meal planner: imports (evidence: `backend/app.py`)
- HTTP API → Food resolver: imports (evidence: `backend/app.py`)
- HTTP API → Google Fit sync: imports (evidence: `backend/app.py`)
- Coach orchestrator → LLM provider config: requests completion (evidence: `backend/orchestrator.py`)
- Coach orchestrator → Nutrition calculations: uses calculations (evidence: `backend/orchestrator.py`)
- Coach orchestrator → Profile and meal memory: uses profile data (evidence: `backend/orchestrator.py`)
- Coach orchestrator → Meal planner: uses suggestions (evidence: `backend/orchestrator.py`)
- Coach orchestrator → Food resolver: resolves foods (evidence: `backend/orchestrator.py`)
- Coach orchestrator → Grocery planning: checks groceries (evidence: `backend/orchestrator.py`)
- Coach orchestrator → Restaurant search: searches restaurants (evidence: `backend/orchestrator.py`)
- Coach orchestrator → Reminders: handles reminders (evidence: `backend/orchestrator.py`)
- Coach orchestrator → Google Fit sync: reads fitness (evidence: `backend/orchestrator.py`)
- LLM provider config → LLM provider: configures access
- Google Fit sync → Google Fit: fetches activity (evidence: `backend/google_fit.py`)
- Reminders → Notification services: sends notices (evidence: `README.md`)
- Reminders → Food resolver: resolves foods (evidence: `backend/reminders.py`)
- Reminders → Nutrition calculations: calculates macros (evidence: `backend/reminders.py`)
- Reminders → Profile and meal memory: logs meals (evidence: `backend/reminders.py`)
- Profile and meal memory → SQLite or Turso: reads and writes (evidence: `backend/memory_agent.py`)
- Nutrition calculations → SQLite or Turso: reads food and logs (evidence: `backend/math_engine.py`)
- Nutrition calculations → Food quality rules: uses diet rules (evidence: `backend/math_engine.py`)
- Food resolver → SQLite or Turso: reads food rows (evidence: `backend/rag_resolver.py`)
- Food resolver → Food quality rules: filters diet (evidence: `backend/rag_resolver.py`)
- Meal planner → SQLite or Turso: reads food data (evidence: `backend/menu_planner.py`)
- Meal planner → Food quality rules: uses quality rules (evidence: `backend/menu_planner.py`)
- Food database builder → SQLite or Turso: uses adapter (evidence: `backend/db_setup.py`)
- Food database builder → Food quality rules: grades food rows (evidence: `backend/db_setup.py`)
