# yuzzaf/dietary architecture

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

- Interactive diagram: https://gitdiagram.com/yuzzaf/dietary
- Repository: https://github.com/yuzzaf/dietary

## Overview

Dietary is a full-stack nutrition and calorie-tracking app. Users sign in, set profile details and goals, find foods by search or image recognition, log meals, and review dashboard insights, chat coaching, and weekly PDF reports. The graph follows evidenced UI-to-service and server call paths; major features documented in the README are retained where their source wiring was not sampled. Some routing and domain links are therefore omitted rather than inferred.

Main entry points: [`server/app.js`](https://github.com/yuzzaf/dietary/blob/main/server/app.js) (Express API), [`client/src/routes/AppRoutes.jsx`](https://github.com/yuzzaf/dietary/blob/main/client/src/routes/AppRoutes.jsx) (App routes), [`server/services/food.service.js`](https://github.com/yuzzaf/dietary/blob/main/server/services/food.service.js) (Food search and detection), [`server/models/index.js`](https://github.com/yuzzaf/dietary/blob/main/server/models/index.js) (Sequelize models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_routes["App routes<br/>[AppRoutes.jsx]"]
  node_authpages["Sign-in and registration<br/>[Login.jsx]"]
  node_dashboard["Dashboard and reports<br/>[Dashboard.jsx]"]
  node_foodpages["Food search and detect<br/>[Detect.jsx]"]
  node_logsview["Meal history<br/>[Logs.jsx]"]
  node_profile["Profile and goals<br/>[Profile.jsx]"]
  node_chatbot["Nutrition chatbot<br/>[Chatbot.jsx]"]
  node_authsvc["Auth API client<br/>[authService.js]"]
  node_foodsvc["Food API client<br/>[foodService.js]"]
  node_logsvc["Log API client<br/>[logService.js]"]
  node_insightsvc["Insight API client<br/>[insightService.js]"]
  node_api["HTTP client<br/>[api.js]"]
end

subgraph group_server["API and domain"]
  node_serverapp["Express API<br/>[app.js]"]
  node_authctrl["Authentication<br/>[authController.js]"]
  node_foodctrl["Food operations<br/>[foodController.js]"]
  node_logctrl["Meal logging<br/>[logController.js]"]
  node_userctrl["User profile<br/>[userController.js]"]
  node_goalctrl["Goal operations<br/>[goalController.js]"]
  node_foodservice["Food search and detection<br/>[food.service.js]"]
  node_edamam["Edamam search<br/>[edamam.service.js]"]
  node_fatsecret["FatSecret search"]
end

subgraph group_ai["Nutrition intelligence"]
  node_aictrl["Insights, chat, export<br/>[aiController.js]"]
  node_nutrition["Nutrition calculations"]
  node_gemini["Gemini AI<br/>[gemini.service.js]"]
  node_vision["Hugging Face vision<br/>[detect.service.js]"]
end

subgraph group_data["Persistence"]
  node_models[("Sequelize models<br/>[index.js]")]
end

node_user(("User"))
node_google{{"Google OAuth"}}
node_github{{"GitHub OAuth"}}

node_user -->|"uses"| node_routes
node_routes -->|"routes to"| node_authpages
node_routes -->|"routes to"| node_dashboard
node_routes -->|"routes to"| node_foodpages
node_routes -->|"routes to"| node_logsview
node_routes -->|"routes to"| node_profile
node_authpages -->|"calls"| node_authsvc
node_authsvc -->|"sends requests"| node_api
node_foodpages -->|"calls"| node_foodsvc
node_foodpages -->|"creates logs"| node_logsvc
node_logsview -->|"loads logs"| node_logsvc
node_chatbot -->|"sends chat"| node_insightsvc
node_dashboard -->|"loads insights"| node_insightsvc
node_insightsvc -->|"sends requests"| node_api
node_serverapp -.->|"routes requests"| node_authctrl
node_serverapp -.->|"routes requests"| node_foodctrl
node_serverapp -.->|"routes requests"| node_logctrl
node_serverapp -.->|"routes requests"| node_userctrl
node_serverapp -.->|"routes requests"| node_goalctrl
node_serverapp -.->|"routes requests"| node_aictrl
node_authctrl -->|"reads and writes"| node_models
node_authctrl -->|"verifies identity"| node_google
node_authctrl -->|"fetches identity"| node_github
node_foodctrl -->|"searches and detects"| node_foodservice
node_foodctrl -->|"reads and writes"| node_models
node_logctrl -->|"reads and writes"| node_models
node_userctrl -->|"reads and writes"| node_models
node_aictrl -->|"reads and writes"| node_models
node_aictrl -->|"calculates calories"| node_nutrition
node_aictrl -->|"generates and streams"| node_gemini
node_foodservice -->|"searches"| node_edamam
node_foodservice -->|"searches"| node_fatsecret
node_foodservice -->|"detects first"| node_vision
node_foodservice -->|"fallback detection"| node_gemini

click node_routes "https://github.com/yuzzaf/dietary/blob/main/client/src/routes/AppRoutes.jsx"
click node_authpages "https://github.com/yuzzaf/dietary/blob/main/client/src/pages/auth/Login.jsx"
click node_dashboard "https://github.com/yuzzaf/dietary/blob/main/client/src/pages/dashboard/Dashboard.jsx"
click node_foodpages "https://github.com/yuzzaf/dietary/blob/main/client/src/pages/food/Detect.jsx"
click node_logsview "https://github.com/yuzzaf/dietary/blob/main/client/src/pages/logs/Logs.jsx"
click node_profile "https://github.com/yuzzaf/dietary/blob/main/client/src/pages/profile/Profile.jsx"
click node_chatbot "https://github.com/yuzzaf/dietary/blob/main/client/src/components/common/Chatbot.jsx"
click node_authsvc "https://github.com/yuzzaf/dietary/blob/main/client/src/services/authService.js"
click node_foodsvc "https://github.com/yuzzaf/dietary/blob/main/client/src/services/foodService.js"
click node_logsvc "https://github.com/yuzzaf/dietary/blob/main/client/src/services/logService.js"
click node_insightsvc "https://github.com/yuzzaf/dietary/blob/main/client/src/services/insightService.js"
click node_api "https://github.com/yuzzaf/dietary/blob/main/client/src/services/api.js"
click node_serverapp "https://github.com/yuzzaf/dietary/blob/main/server/app.js"
click node_authctrl "https://github.com/yuzzaf/dietary/blob/main/server/controllers/authController.js"
click node_foodctrl "https://github.com/yuzzaf/dietary/blob/main/server/controllers/foodController.js"
click node_logctrl "https://github.com/yuzzaf/dietary/blob/main/server/controllers/logController.js"
click node_userctrl "https://github.com/yuzzaf/dietary/blob/main/server/controllers/userController.js"
click node_goalctrl "https://github.com/yuzzaf/dietary/blob/main/server/controllers/goalController.js"
click node_aictrl "https://github.com/yuzzaf/dietary/blob/main/server/controllers/aiController.js"
click node_foodservice "https://github.com/yuzzaf/dietary/blob/main/server/services/food.service.js"
click node_nutrition "https://github.com/yuzzaf/dietary/blob/main/server/services/nutrition.service.js"
click node_gemini "https://github.com/yuzzaf/dietary/blob/main/server/services/ai/gemini.service.js"
click node_edamam "https://github.com/yuzzaf/dietary/blob/main/server/services/edamam.service.js"
click node_fatsecret "https://github.com/yuzzaf/dietary/blob/main/server/services/fatsecret.service.js"
click node_vision "https://github.com/yuzzaf/dietary/blob/main/server/services/ai/detect.service.js"
click node_models "https://github.com/yuzzaf/dietary/blob/main/server/models/index.js"

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_routes,node_authpages,node_dashboard,node_foodpages,node_logsview,node_profile,node_chatbot,node_authsvc,node_foodsvc,node_logsvc,node_insightsvc,node_api,node_user toneBlue
class node_serverapp,node_authctrl,node_foodctrl,node_logctrl,node_userctrl,node_goalctrl,node_foodservice,node_edamam,node_fatsecret toneAmber
class node_aictrl,node_nutrition,node_gemini,node_vision toneMint
class node_models toneRose
class node_google,node_github toneIndigo
```

## Components

### Client experience

- [App routes](https://github.com/yuzzaf/dietary/blob/main/client/src/routes/AppRoutes.jsx): `client/src/routes/AppRoutes.jsx`
- [Sign-in and registration](https://github.com/yuzzaf/dietary/blob/main/client/src/pages/auth/Login.jsx): `client/src/pages/auth/Login.jsx`
- [Dashboard and reports](https://github.com/yuzzaf/dietary/blob/main/client/src/pages/dashboard/Dashboard.jsx): `client/src/pages/dashboard/Dashboard.jsx`
- [Food search and detect](https://github.com/yuzzaf/dietary/blob/main/client/src/pages/food/Detect.jsx): `client/src/pages/food/Detect.jsx`
- [Meal history](https://github.com/yuzzaf/dietary/blob/main/client/src/pages/logs/Logs.jsx): `client/src/pages/logs/Logs.jsx`
- [Profile and goals](https://github.com/yuzzaf/dietary/blob/main/client/src/pages/profile/Profile.jsx): `client/src/pages/profile/Profile.jsx`
- [Nutrition chatbot](https://github.com/yuzzaf/dietary/blob/main/client/src/components/common/Chatbot.jsx): `client/src/components/common/Chatbot.jsx`
- [Auth API client](https://github.com/yuzzaf/dietary/blob/main/client/src/services/authService.js): `client/src/services/authService.js`
- [Food API client](https://github.com/yuzzaf/dietary/blob/main/client/src/services/foodService.js): `client/src/services/foodService.js`
- [Log API client](https://github.com/yuzzaf/dietary/blob/main/client/src/services/logService.js): `client/src/services/logService.js`
- [Insight API client](https://github.com/yuzzaf/dietary/blob/main/client/src/services/insightService.js): `client/src/services/insightService.js`
- [HTTP client](https://github.com/yuzzaf/dietary/blob/main/client/src/services/api.js): `client/src/services/api.js`

### API and domain

- [Express API](https://github.com/yuzzaf/dietary/blob/main/server/app.js): `server/app.js`
- [Authentication](https://github.com/yuzzaf/dietary/blob/main/server/controllers/authController.js): `server/controllers/authController.js`
- [Food operations](https://github.com/yuzzaf/dietary/blob/main/server/controllers/foodController.js): `server/controllers/foodController.js`
- [Meal logging](https://github.com/yuzzaf/dietary/blob/main/server/controllers/logController.js): `server/controllers/logController.js`
- [User profile](https://github.com/yuzzaf/dietary/blob/main/server/controllers/userController.js): `server/controllers/userController.js`
- [Goal operations](https://github.com/yuzzaf/dietary/blob/main/server/controllers/goalController.js): `server/controllers/goalController.js`
- [Food search and detection](https://github.com/yuzzaf/dietary/blob/main/server/services/food.service.js): `server/services/food.service.js`
- [Edamam search](https://github.com/yuzzaf/dietary/blob/main/server/services/edamam.service.js): `server/services/edamam.service.js`
- [FatSecret search](https://github.com/yuzzaf/dietary/blob/main/server/services/fatsecret.service.js): `server/services/fatsecret.service.js`

### Nutrition intelligence

- [Insights, chat, export](https://github.com/yuzzaf/dietary/blob/main/server/controllers/aiController.js): `server/controllers/aiController.js`
- [Nutrition calculations](https://github.com/yuzzaf/dietary/blob/main/server/services/nutrition.service.js): `server/services/nutrition.service.js`
- [Gemini AI](https://github.com/yuzzaf/dietary/blob/main/server/services/ai/gemini.service.js): `server/services/ai/gemini.service.js`
- [Hugging Face vision](https://github.com/yuzzaf/dietary/blob/main/server/services/ai/detect.service.js): `server/services/ai/detect.service.js`

### Persistence

- [Sequelize models](https://github.com/yuzzaf/dietary/blob/main/server/models/index.js): `server/models/index.js`

### Other components

- **User**
- **Google OAuth**
- **GitHub OAuth**

## Connections

- User → App routes: uses (evidence: `client/src/routes/AppRoutes.jsx`)
- App routes → Sign-in and registration: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- App routes → Dashboard and reports: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- App routes → Food search and detect: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- App routes → Meal history: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- App routes → Profile and goals: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Sign-in and registration → Auth API client: calls (evidence: `client/src/pages/auth/Login.jsx`)
- Auth API client → HTTP client: sends requests (evidence: `client/src/services/authService.js`)
- Food search and detect → Food API client: calls (evidence: `client/src/pages/food/Detect.jsx`)
- Food search and detect → Log API client: creates logs (evidence: `client/src/pages/food/Detect.jsx`)
- Meal history → Log API client: loads logs (evidence: `client/src/pages/logs/Logs.jsx`)
- Nutrition chatbot → Insight API client: sends chat (evidence: `client/src/components/common/Chatbot.jsx`)
- Dashboard and reports → Insight API client: loads insights (evidence: `client/src/pages/dashboard/Dashboard.jsx`)
- Insight API client → HTTP client: sends requests (evidence: `client/src/services/insightService.js`)
- Express API → Authentication: routes requests
- Express API → Food operations: routes requests
- Express API → Meal logging: routes requests
- Express API → User profile: routes requests
- Express API → Goal operations: routes requests
- Express API → Insights, chat, export: routes requests
- Authentication → Sequelize models: reads and writes (evidence: `server/controllers/authController.js`)
- Authentication → Google OAuth: verifies identity (evidence: `server/controllers/authController.js`)
- Authentication → GitHub OAuth: fetches identity (evidence: `server/controllers/authController.js`)
- Food operations → Food search and detection: searches and detects (evidence: `server/controllers/foodController.js`)
- Food operations → Sequelize models: reads and writes (evidence: `server/controllers/foodController.js`)
- Meal logging → Sequelize models: reads and writes (evidence: `server/controllers/logController.js`)
- User profile → Sequelize models: reads and writes (evidence: `server/controllers/userController.js`)
- Insights, chat, export → Sequelize models: reads and writes (evidence: `server/controllers/aiController.js`)
- Insights, chat, export → Nutrition calculations: calculates calories (evidence: `server/controllers/aiController.js`)
- Insights, chat, export → Gemini AI: generates and streams (evidence: `server/controllers/aiController.js`)
- Food search and detection → Edamam search: searches (evidence: `server/services/food.service.js`)
- Food search and detection → FatSecret search: searches (evidence: `server/services/food.service.js`)
- Food search and detection → Hugging Face vision: detects first (evidence: `server/services/food.service.js`)
- Food search and detection → Gemini AI: fallback detection (evidence: `server/services/food.service.js`)
