# mdtoufiq-dev/nutriguard architecture

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

- Interactive diagram: https://gitdiagram.com/mdtoufiq-dev/nutriguard
- Repository: https://github.com/mdtoufiq-dev/nutriguard

## Overview

NUTRIGUARD combines a React nutrition-planning app with an Express API for plans, chat, calendar, scanning, restaurants, maps, and user endpoints. The principal user flow is entering preferences in the landing-page sandbox, revealing the app, and navigating its dashboard and nutrition features. The README documents several interactions as placeholders or future integrations, so the graph distinguishes those documented UI capabilities from backend calls visible in the sampled source. Unsampled backend routes and database behavior are represented only at their supported directory level.

Main entry points: [`src/App.jsx`](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/App.jsx) (App routing), [`server/src/app.js`](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/app.js) (Express API), [`src/components/Meals.jsx`](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/components/Meals.jsx) (Meal plans), [`src/components/Dashboard.jsx`](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/components/Dashboard.jsx) (Health dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Nutrition app"]
  node_app["App routing<br/>[App.jsx]"]
  node_hero["Preferences form<br/>[Hero.jsx]"]
  node_dashboard["Health dashboard<br/>[Dashboard.jsx]"]
  node_meals["Meal plans<br/>[Meals.jsx]"]
  node_chatui["Nutrition chat<br/>[ChatView.jsx]"]
  node_calendarui["Adherence calendar<br/>[CalendarView.jsx]"]
  node_api["HTTP client<br/>[api.js]"]
  node_loader["Loader state<br/>[LoaderContext.jsx]"]
  node_toast["Toast state<br/>[ToastContext.jsx]"]
end

subgraph group_planning["Plans and health"]
  node_healthprofile["Health profile"]
  node_currentuser["Current user<br/>[useCurrentUser.js]"]
  node_planservice["Plan API client<br/>[planService.js]"]
  node_generator["Plan generator<br/>[planGenerator.js]"]
  node_meallibrary["Meal library<br/>[mealLibrary.js]"]
  node_safety["Safety checks<br/>[safetyChecker.js]"]
end

subgraph group_discovery["Food discovery"]
  node_radarui["Restaurant radar<br/>[RadarView.jsx]"]
  node_scannerui["Food scanner<br/>[ScannerView.jsx]"]
  node_deliveryclient["Delivery client<br/>[deliveryService.js]"]
  node_scanclient["Scanner client<br/>[scannerService.js]"]
end

subgraph group_backend["API and AI"]
  node_server["Express API<br/>[app.js]"]
  node_plansroute["Plan endpoints<br/>[plans.js]"]
  node_calendarroute["Calendar endpoints<br/>[calendar.js]"]
  node_scanroute["Scan endpoints<br/>[scan.js]"]
  node_restaurantroute["Restaurant endpoints<br/>[restaurants.js]"]
  node_mapsroute["Maps endpoints<br/>[maps.js]"]
  node_chatroute["Chat endpoint<br/>[chat.js]"]
  node_llm["LLM service<br/>[llmService.js]"]
  node_geocoding["Geocoding service"]
  node_delivery["Delivery service<br/>[deliveryService.js]"]
  node_dbmodels[("Domain models")]
end

node_user(("User"))

node_user -->|"sets preferences"| node_hero
node_hero -->|"reveals app"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_chatui
node_app -->|"routes to"| node_calendarui
node_app -->|"routes to"| node_radarui
node_app -->|"routes to"| node_scannerui
node_app -->|"routes to"| node_meals
node_dashboard -->|"reads user"| node_currentuser
node_dashboard -->|"requests plans"| node_planservice
node_meals -->|"reads user"| node_currentuser
node_meals -->|"requests plans"| node_planservice
node_meals -->|"generates plan"| node_generator
node_generator -->|"selects meals"| node_meallibrary
node_chatui -->|"reads profile"| node_healthprofile
node_chatui -->|"requests plans"| node_planservice
node_radarui -->|"reads profile"| node_healthprofile
node_radarui -->|"searches restaurants"| node_deliveryclient
node_scannerui -->|"reads profile"| node_healthprofile
node_scannerui -->|"submits scans"| node_scanclient
node_scannerui -->|"checks safety"| node_safety
node_planservice -->|"sends requests"| node_api
node_deliveryclient -->|"sends requests"| node_api
node_scanclient -->|"sends requests"| node_api
node_server -->|"mounts route"| node_plansroute
node_server -->|"mounts route"| node_calendarroute
node_server -->|"mounts route"| node_scanroute
node_server -->|"mounts route"| node_restaurantroute
node_server -->|"mounts route"| node_mapsroute
node_server -->|"mounts route"| node_chatroute
node_chatroute -->|"requests response"| node_llm
node_mapsroute -->|"geocodes locations"| node_geocoding
node_restaurantroute -->|"requests delivery"| node_delivery
node_restaurantroute -->|"uses order and favorite models"| node_dbmodels
node_dashboard -->|"uses loading state"| node_loader
node_meals -->|"uses notifications"| node_toast

click node_app "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/App.jsx"
click node_hero "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/components/Hero.jsx"
click node_dashboard "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/components/Dashboard.jsx"
click node_meals "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/components/Meals.jsx"
click node_chatui "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/features/chat/ChatView.jsx"
click node_calendarui "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/features/calendar/CalendarView.jsx"
click node_radarui "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/features/radar/RadarView.jsx"
click node_scannerui "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/features/scanner/ScannerView.jsx"
click node_healthprofile "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/integration/getHealthProfile.js"
click node_currentuser "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/integration/useCurrentUser.js"
click node_planservice "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/services/planService.js"
click node_generator "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/utils/planGenerator.js"
click node_meallibrary "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/data/mealLibrary.js"
click node_safety "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/utils/safetyChecker.js"
click node_deliveryclient "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/services/deliveryService.js"
click node_scanclient "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/services/scannerService.js"
click node_api "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/services/api.js"
click node_server "https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/app.js"
click node_plansroute "https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/plans.js"
click node_calendarroute "https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/calendar.js"
click node_scanroute "https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/scan.js"
click node_restaurantroute "https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/restaurants.js"
click node_mapsroute "https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/maps.js"
click node_chatroute "https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/chat.js"
click node_llm "https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/services/llmService.js"
click node_geocoding "https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/services/geocodingService.js"
click node_delivery "https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/services/deliveryService.js"
click node_dbmodels "https://github.com/mdtoufiq-dev/nutriguard/tree/main/server/src/db/models"
click node_loader "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/contexts/LoaderContext.jsx"
click node_toast "https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/contexts/ToastContext.jsx"

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_app,node_hero,node_dashboard,node_meals,node_chatui,node_calendarui,node_api,node_loader,node_toast,node_user toneBlue
class node_healthprofile,node_currentuser,node_planservice,node_generator,node_meallibrary,node_safety toneAmber
class node_radarui,node_scannerui,node_deliveryclient,node_scanclient toneMint
class node_server,node_plansroute,node_calendarroute,node_scanroute,node_restaurantroute,node_mapsroute,node_chatroute,node_llm,node_geocoding,node_delivery,node_dbmodels toneRose
```

## Components

### Nutrition app

- [App routing](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/App.jsx): `src/App.jsx`
- [Preferences form](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/components/Hero.jsx): `src/components/Hero.jsx`
- [Health dashboard](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/components/Dashboard.jsx): `src/components/Dashboard.jsx`
- [Meal plans](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/components/Meals.jsx): `src/components/Meals.jsx`
- [Nutrition chat](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/features/chat/ChatView.jsx): `src/features/chat/ChatView.jsx`
- [Adherence calendar](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/features/calendar/CalendarView.jsx): `src/features/calendar/CalendarView.jsx`
- [HTTP client](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/services/api.js): `src/services/api.js`
- [Loader state](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/contexts/LoaderContext.jsx): `src/contexts/LoaderContext.jsx`
- [Toast state](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/contexts/ToastContext.jsx): `src/contexts/ToastContext.jsx`

### Plans and health

- [Health profile](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/integration/getHealthProfile.js): `src/integration/getHealthProfile.js`
- [Current user](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/integration/useCurrentUser.js): `src/integration/useCurrentUser.js`
- [Plan API client](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/services/planService.js): `src/services/planService.js`
- [Plan generator](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/utils/planGenerator.js): `src/utils/planGenerator.js`
- [Meal library](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/data/mealLibrary.js): `src/data/mealLibrary.js`
- [Safety checks](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/utils/safetyChecker.js): `src/utils/safetyChecker.js`

### Food discovery

- [Restaurant radar](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/features/radar/RadarView.jsx): `src/features/radar/RadarView.jsx`
- [Food scanner](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/features/scanner/ScannerView.jsx): `src/features/scanner/ScannerView.jsx`
- [Delivery client](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/services/deliveryService.js): `src/services/deliveryService.js`
- [Scanner client](https://github.com/mdtoufiq-dev/nutriguard/blob/main/src/services/scannerService.js): `src/services/scannerService.js`

### API and AI

- [Express API](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/app.js): `server/src/app.js`
- [Plan endpoints](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/plans.js): `server/src/routes/plans.js`
- [Calendar endpoints](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/calendar.js): `server/src/routes/calendar.js`
- [Scan endpoints](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/scan.js): `server/src/routes/scan.js`
- [Restaurant endpoints](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/restaurants.js): `server/src/routes/restaurants.js`
- [Maps endpoints](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/maps.js): `server/src/routes/maps.js`
- [Chat endpoint](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/routes/chat.js): `server/src/routes/chat.js`
- [LLM service](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/services/llmService.js): `server/src/services/llmService.js`
- [Geocoding service](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/services/geocodingService.js): `server/src/services/geocodingService.js`
- [Delivery service](https://github.com/mdtoufiq-dev/nutriguard/blob/main/server/src/services/deliveryService.js): `server/src/services/deliveryService.js`
- [Domain models](https://github.com/mdtoufiq-dev/nutriguard/tree/main/server/src/db/models): `server/src/db/models`

### Other components

- **User**

## Connections

- User → Preferences form: sets preferences
- Preferences form → App routing: reveals app (evidence: `src/App.jsx`)
- App routing → Health dashboard: routes to (evidence: `src/App.jsx`)
- App routing → Nutrition chat: routes to (evidence: `src/App.jsx`)
- App routing → Adherence calendar: routes to (evidence: `src/App.jsx`)
- App routing → Restaurant radar: routes to (evidence: `src/App.jsx`)
- App routing → Food scanner: routes to (evidence: `src/App.jsx`)
- App routing → Meal plans: routes to (evidence: `src/App.jsx`)
- Health dashboard → Current user: reads user (evidence: `src/components/Dashboard.jsx`)
- Health dashboard → Plan API client: requests plans (evidence: `src/components/Dashboard.jsx`)
- Meal plans → Current user: reads user (evidence: `src/components/Meals.jsx`)
- Meal plans → Plan API client: requests plans (evidence: `src/components/Meals.jsx`)
- Meal plans → Plan generator: generates plan (evidence: `src/components/Meals.jsx`)
- Plan generator → Meal library: selects meals (evidence: `src/utils/planGenerator.js`)
- Nutrition chat → Health profile: reads profile (evidence: `src/features/chat/ChatView.jsx`)
- Nutrition chat → Plan API client: requests plans (evidence: `src/features/chat/ChatView.jsx`)
- Restaurant radar → Health profile: reads profile (evidence: `src/features/radar/RadarView.jsx`)
- Restaurant radar → Delivery client: searches restaurants (evidence: `src/features/radar/RadarView.jsx`)
- Food scanner → Health profile: reads profile (evidence: `src/features/scanner/ScannerView.jsx`)
- Food scanner → Scanner client: submits scans (evidence: `src/features/scanner/ScannerView.jsx`)
- Food scanner → Safety checks: checks safety (evidence: `src/features/scanner/ScannerView.jsx`)
- Plan API client → HTTP client: sends requests (evidence: `src/services/planService.js`)
- Delivery client → HTTP client: sends requests (evidence: `src/services/deliveryService.js`)
- Scanner client → HTTP client: sends requests (evidence: `src/services/scannerService.js`)
- Express API → Plan endpoints: mounts route (evidence: `server/src/app.js`)
- Express API → Calendar endpoints: mounts route (evidence: `server/src/app.js`)
- Express API → Scan endpoints: mounts route (evidence: `server/src/app.js`)
- Express API → Restaurant endpoints: mounts route (evidence: `server/src/app.js`)
- Express API → Maps endpoints: mounts route (evidence: `server/src/app.js`)
- Express API → Chat endpoint: mounts route (evidence: `server/src/app.js`)
- Chat endpoint → LLM service: requests response (evidence: `server/src/routes/chat.js`)
- Maps endpoints → Geocoding service: geocodes locations (evidence: `server/src/routes/maps.js`)
- Restaurant endpoints → Delivery service: requests delivery (evidence: `server/src/routes/restaurants.js`)
- Restaurant endpoints → Domain models: uses order and favorite models (evidence: `server/src/routes/restaurants.js`)
- Health dashboard → Loader state: uses loading state (evidence: `src/components/Dashboard.jsx`)
- Meal plans → Toast state: uses notifications (evidence: `src/components/Meals.jsx`)
