# kaniska-praba007/nutrimind-ai architecture

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

- Interactive diagram: https://gitdiagram.com/kaniska-praba007/nutrimind-ai
- Repository: https://github.com/kaniska-praba007/nutrimind-ai

## Overview

NutriMind AI is an Indian-food nutrition tracker and assistant. Users can log or photograph meals, get deterministic nutrition totals, and use AI for meal plans, food swaps, recovery suggestions, and evidence-backed chat; analytics, grocery planning, and clinical safety are additional capabilities. The graph traces documented backend calls and app wiring. Several frontend feature pages and agent integrations are unsampled, so their connections are shown only where the README documents them or omitted when implementation links are uncertain.

Main entry points: [`backend/app/main.py`](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/main.py) (FastAPI application), [`backend/app/db/supabase_client.py`](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/db/supabase_client.py) (Supabase client), [`backend/app/agents/orchestrator.py`](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/orchestrator.py) (Intent orchestration), [`backend/app/agents/meal_plan_agent.py`](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/meal_plan_agent.py) (Meal planning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_frontend["Web application<br/>[App.tsx]"]
  node_router["Page routing<br/>[router.tsx]"]
  node_food_ui["Food logging UI<br/>[FoodLogPage.tsx]"]
  node_chat_ui["Chat UI<br/>[ChatPage.tsx]"]
  node_planner_ui["Meal planner UI<br/>[PlannerPage.tsx]"]
  node_insights_ui["Analytics UI<br/>[DashboardPage.tsx]"]
  node_safety_ui["Safety tools"]
end

subgraph group_nutrition["Nutrition tracking"]
  node_food_api["Food routes<br/>[food.py]"]
  node_food_service["Food data and logs<br/>[food_service.py]"]
  node_nutrition_engine["Nutrition calculations"]
  node_analytics_api["Analytics routes<br/>[analytics.py]"]
  node_users_api["Profile routes<br/>[users.py]"]
end

subgraph group_intelligence["AI assistance"]
  node_meals_api["Meal routes<br/>[meals.py]"]
  node_meal_agent["Meal planning<br/>[meal_plan_agent.py]"]
  node_swap_agent["Food swaps<br/>[swap_agent.py]"]
  node_rescue_agent["Meal rescue<br/>[rescue_agent.py]"]
  node_grocery_api["Grocery routes<br/>[grocery.py]"]
  node_grocery_agent["Grocery planning<br/>[grocery_agent.py]"]
  node_chat_api["Chat routes<br/>[chat.py]"]
  node_orchestrator["Intent orchestration<br/>[orchestrator.py]"]
  node_knowledge_agent["Knowledge answers<br/>[knowledge_agent.py]"]
  node_rag["Guideline retrieval<br/>[retriever.py]"]
  node_context["Answer context<br/>[context_builder.py]"]
  node_food_recognition["Plate recognition"]
  node_feedback_api["Feedback routes<br/>[feedback.py]"]
  node_feedback_agent["Feedback analysis<br/>[feedback_agent.py]"]
end

subgraph group_platform["Identity and data"]
  node_api["FastAPI application<br/>[main.py]"]
  node_auth["Token verification<br/>[supabase_auth.py]"]
  node_db_client["Supabase client<br/>[supabase_client.py]"]
  node_database[("Supabase data store")]
  node_ai_factory["AI provider factory<br/>[factory.py]"]
  node_groq["Groq provider<br/>[groq_provider.py]"]
  node_google["Google AI provider<br/>[google_provider.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_frontend
node_frontend -->|"mounts"| node_router
node_api -->|"registers"| node_food_api
node_api -->|"registers"| node_meals_api
node_api -->|"registers"| node_chat_api
node_api -->|"registers"| node_users_api
node_api -->|"registers"| node_feedback_api
node_api -->|"registers"| node_grocery_api
node_api -->|"registers"| node_analytics_api
node_food_api -->|"calls"| node_food_service
node_food_api -->|"calculates with"| node_nutrition_engine
node_food_api -->|"invokes"| node_food_recognition
node_analytics_api -->|"reads"| node_db_client
node_analytics_api -->|"calculates with"| node_nutrition_engine
node_analytics_api -->|"uses"| node_food_service
node_users_api -->|"reads and writes"| node_db_client
node_users_api -->|"calculates with"| node_nutrition_engine
node_meals_api -->|"invokes"| node_meal_agent
node_meals_api -->|"invokes"| node_swap_agent
node_meals_api -->|"invokes"| node_rescue_agent
node_meal_agent -->|"gets foods"| node_food_service
node_meal_agent -->|"calculates with"| node_nutrition_engine
node_meal_agent -->|"reads and writes"| node_db_client
node_grocery_api -->|"invokes"| node_grocery_agent
node_grocery_api -->|"uses"| node_db_client
node_chat_api -->|"calls"| node_orchestrator
node_orchestrator -->|"routes queries"| node_knowledge_agent
node_orchestrator -->|"dispatches plans"| node_meal_agent
node_orchestrator -->|"dispatches rescue"| node_rescue_agent
node_orchestrator -->|"builds personal context"| node_context
node_orchestrator -->|"reads personal data"| node_db_client
node_knowledge_agent -->|"retrieves evidence"| node_rag
node_knowledge_agent -->|"builds answer context"| node_context
node_rag -->|"embeds queries"| node_ai_factory
node_rag -->|"searches chunks"| node_db_client
node_feedback_api -->|"invokes"| node_feedback_agent
node_food_service -->|"reads and logs"| node_db_client
node_db_client -->|"queries"| node_database
node_auth -->|"verifies tokens"| node_database
node_ai_factory -->|"generates text"| node_groq
node_ai_factory -->|"generates or embeds"| node_google

click node_frontend "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/App.tsx"
click node_router "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/router.tsx"
click node_food_ui "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/pages/FoodLogPage.tsx"
click node_chat_ui "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/pages/ChatPage.tsx"
click node_planner_ui "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/pages/PlannerPage.tsx"
click node_insights_ui "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/pages/DashboardPage.tsx"
click node_safety_ui "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/pages/SafetyAuditorPage.tsx"
click node_api "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/main.py"
click node_food_api "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/food.py"
click node_food_service "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/services/food_service.py"
click node_nutrition_engine "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/services/nutrition_engine.py"
click node_analytics_api "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/analytics.py"
click node_users_api "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/users.py"
click node_meals_api "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/meals.py"
click node_meal_agent "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/meal_plan_agent.py"
click node_swap_agent "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/swap_agent.py"
click node_rescue_agent "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/rescue_agent.py"
click node_grocery_api "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/grocery.py"
click node_grocery_agent "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/grocery_agent.py"
click node_chat_api "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/chat.py"
click node_orchestrator "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/orchestrator.py"
click node_knowledge_agent "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/knowledge_agent.py"
click node_rag "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/rag/retriever.py"
click node_context "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/rag/context_builder.py"
click node_food_recognition "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/food_recognition_agent.py"
click node_feedback_api "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/feedback.py"
click node_feedback_agent "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/feedback_agent.py"
click node_auth "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/middleware/supabase_auth.py"
click node_db_client "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/db/supabase_client.py"
click node_ai_factory "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/ai/factory.py"
click node_groq "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/ai/groq_provider.py"
click node_google "https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/ai/google_provider.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_frontend,node_router,node_food_ui,node_chat_ui,node_planner_ui,node_insights_ui,node_safety_ui,node_user toneBlue
class node_food_api,node_food_service,node_nutrition_engine,node_analytics_api,node_users_api toneAmber
class node_meals_api,node_meal_agent,node_swap_agent,node_rescue_agent,node_grocery_api,node_grocery_agent,node_chat_api,node_orchestrator,node_knowledge_agent,node_rag,node_context,node_food_recognition,node_feedback_api,node_feedback_agent toneMint
class node_api,node_auth,node_db_client,node_database,node_ai_factory,node_groq,node_google toneRose
```

## Components

### User experience

- [Web application](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Page routing](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/router.tsx): `frontend/src/router.tsx`
- [Food logging UI](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/pages/FoodLogPage.tsx): `frontend/src/pages/FoodLogPage.tsx`
- [Chat UI](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/pages/ChatPage.tsx): `frontend/src/pages/ChatPage.tsx`
- [Meal planner UI](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/pages/PlannerPage.tsx): `frontend/src/pages/PlannerPage.tsx`
- [Analytics UI](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/pages/DashboardPage.tsx): `frontend/src/pages/DashboardPage.tsx`
- [Safety tools](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/frontend/src/pages/SafetyAuditorPage.tsx): `frontend/src/pages/SafetyAuditorPage.tsx`

### Nutrition tracking

- [Food routes](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/food.py): `backend/app/api/food.py`
- [Food data and logs](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/services/food_service.py): `backend/app/services/food_service.py`
- [Nutrition calculations](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/services/nutrition_engine.py): `backend/app/services/nutrition_engine.py`
- [Analytics routes](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/analytics.py): `backend/app/api/analytics.py`
- [Profile routes](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/users.py): `backend/app/api/users.py`

### AI assistance

- [Meal routes](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/meals.py): `backend/app/api/meals.py`
- [Meal planning](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/meal_plan_agent.py): `backend/app/agents/meal_plan_agent.py`
- [Food swaps](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/swap_agent.py): `backend/app/agents/swap_agent.py`
- [Meal rescue](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/rescue_agent.py): `backend/app/agents/rescue_agent.py`
- [Grocery routes](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/grocery.py): `backend/app/api/grocery.py`
- [Grocery planning](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/grocery_agent.py): `backend/app/agents/grocery_agent.py`
- [Chat routes](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/chat.py): `backend/app/api/chat.py`
- [Intent orchestration](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/orchestrator.py): `backend/app/agents/orchestrator.py`
- [Knowledge answers](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/knowledge_agent.py): `backend/app/agents/knowledge_agent.py`
- [Guideline retrieval](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/rag/retriever.py): `backend/app/rag/retriever.py`
- [Answer context](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/rag/context_builder.py): `backend/app/rag/context_builder.py`
- [Plate recognition](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/food_recognition_agent.py): `backend/app/agents/food_recognition_agent.py`
- [Feedback routes](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/api/feedback.py): `backend/app/api/feedback.py`
- [Feedback analysis](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/agents/feedback_agent.py): `backend/app/agents/feedback_agent.py`

### Identity and data

- [FastAPI application](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/main.py): `backend/app/main.py`
- [Token verification](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/middleware/supabase_auth.py): `backend/app/middleware/supabase_auth.py`
- [Supabase client](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/db/supabase_client.py): `backend/app/db/supabase_client.py`
- **Supabase data store**
- [AI provider factory](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/ai/factory.py): `backend/app/ai/factory.py`
- [Groq provider](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/ai/groq_provider.py): `backend/app/ai/groq_provider.py`
- [Google AI provider](https://github.com/kaniska-praba007/nutrimind-ai/blob/development/backend/app/ai/google_provider.py): `backend/app/ai/google_provider.py`

### Other components

- **User**

## Connections

- User → Web application: uses
- Web application → Page routing: mounts (evidence: `frontend/src/App.tsx`)
- FastAPI application → Food routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Meal routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Chat routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Profile routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Feedback routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Grocery routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Analytics routes: registers (evidence: `backend/app/main.py`)
- Food routes → Food data and logs: calls (evidence: `backend/app/api/food.py`)
- Food routes → Nutrition calculations: calculates with (evidence: `backend/app/api/food.py`)
- Food routes → Plate recognition: invokes (evidence: `backend/app/api/food.py`)
- Analytics routes → Supabase client: reads (evidence: `backend/app/api/analytics.py`)
- Analytics routes → Nutrition calculations: calculates with (evidence: `backend/app/api/analytics.py`)
- Analytics routes → Food data and logs: uses (evidence: `backend/app/api/analytics.py`)
- Profile routes → Supabase client: reads and writes (evidence: `backend/app/api/users.py`)
- Profile routes → Nutrition calculations: calculates with (evidence: `backend/app/api/users.py`)
- Meal routes → Meal planning: invokes (evidence: `backend/app/api/meals.py`)
- Meal routes → Food swaps: invokes (evidence: `backend/app/api/meals.py`)
- Meal routes → Meal rescue: invokes (evidence: `backend/app/api/meals.py`)
- Meal planning → Food data and logs: gets foods (evidence: `backend/app/agents/meal_plan_agent.py`)
- Meal planning → Nutrition calculations: calculates with (evidence: `backend/app/agents/meal_plan_agent.py`)
- Meal planning → Supabase client: reads and writes (evidence: `backend/app/agents/meal_plan_agent.py`)
- Grocery routes → Grocery planning: invokes (evidence: `backend/app/api/grocery.py`)
- Grocery routes → Supabase client: uses (evidence: `backend/app/api/grocery.py`)
- Chat routes → Intent orchestration: calls (evidence: `backend/app/api/chat.py`)
- Intent orchestration → Knowledge answers: routes queries (evidence: `backend/app/agents/orchestrator.py`)
- Intent orchestration → Meal planning: dispatches plans (evidence: `backend/app/agents/orchestrator.py`)
- Intent orchestration → Meal rescue: dispatches rescue (evidence: `backend/app/agents/orchestrator.py`)
- Intent orchestration → Answer context: builds personal context (evidence: `backend/app/agents/orchestrator.py`)
- Intent orchestration → Supabase client: reads personal data (evidence: `backend/app/agents/orchestrator.py`)
- Knowledge answers → Guideline retrieval: retrieves evidence (evidence: `backend/app/agents/knowledge_agent.py`)
- Knowledge answers → Answer context: builds answer context (evidence: `backend/app/agents/knowledge_agent.py`)
- Guideline retrieval → AI provider factory: embeds queries (evidence: `backend/app/rag/retriever.py`)
- Guideline retrieval → Supabase client: searches chunks (evidence: `backend/app/rag/retriever.py`)
- Feedback routes → Feedback analysis: invokes (evidence: `backend/app/api/feedback.py`)
- Food data and logs → Supabase client: reads and logs (evidence: `backend/app/services/food_service.py`)
- Supabase client → Supabase data store: queries (evidence: `backend/app/db/supabase_client.py`)
- Token verification → Supabase data store: verifies tokens (evidence: `backend/app/middleware/supabase_auth.py`)
- AI provider factory → Groq provider: generates text (evidence: `backend/app/ai/factory.py`)
- AI provider factory → Google AI provider: generates or embeds (evidence: `backend/app/ai/factory.py`)
