# akii-real/budget-based-diet architecture

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

- Interactive diagram: https://gitdiagram.com/akii-real/budget-based-diet
- Repository: https://github.com/akii-real/budget-based-diet

## Overview

Budget-Based Diet Maker is a Next.js meal-planning app that targets a user's calorie and macronutrient goals within a strict INR budget, then adds ingredient price estimates. Its principal workflow is profile input, budget-aware plan generation and reuse, followed by recipe details and price comparison. Ingredient price refresh is a separate backend branch: the frontend asks Express to refresh prices, and the backend uses Python scrapers and MongoDB. The README documents capabilities not fully visible in the excerpts; their links are shown only where documented. Several UI and backend relationships remain unverified.

Main entry points: [`src/pages/index.tsx`](https://github.com/akii-real/budget-based-diet/blob/main/src/pages/index.tsx) (Landing page), [`src/components/Wave.tsx`](https://github.com/akii-real/budget-based-diet/blob/main/src/components/Wave.tsx) (Wave renderer), [`src/pages/api/ai-meal-plan.js`](https://github.com/akii-real/budget-based-diet/blob/main/src/pages/api/ai-meal-plan.js) (Plan generation API), [`backend/server.js`](https://github.com/akii-real/budget-based-diet/blob/main/backend/server.js) (Express API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_landing["Landing page<br/>[index.tsx]"]
  node_header["Navigation<br/>[Header.tsx]"]
  node_hero["Hero section<br/>[MainHero.tsx]"]
  node_heroimage["Hero image<br/>[MainHeroImage.tsx]"]
  node_product["Product section<br/>[Product.tsx]"]
  node_about["About section<br/>[About.tsx]"]
  node_lazy["Lazy display<br/>[LazyShow.tsx]"]
  node_analytics["Analytics UI<br/>[Analytics.tsx]"]
  node_canvas["Canvas display<br/>[Canvas.tsx]"]
  node_wave["Wave renderer<br/>[Wave.tsx]"]
  node_canvasctx["Canvas context<br/>[useCanvas.ts]"]
  node_resize["Responsive sizing"]
  node_waveutil["Wave drawing<br/>[wave.ts]"]
  node_gtag["Analytics tracking<br/>[gtag.ts]"]
end

subgraph group_planning["Meal planning"]
  node_getstarted["Profile input<br/>[GetStarted.tsx]"]
  node_dietplan["Plan selection<br/>[diet-plan.tsx]"]
  node_planapi["Plan generation API<br/>[ai-meal-plan.js]"]
  node_ollama["Local model"]
  node_plancache[("Plan pool")]
  node_recipepage["Recipe details<br/>[recipe.tsx]"]
  node_recipeapi["Recipe API<br/>[recipe.js]"]
end

subgraph group_prices["Ingredient pricing"]
  node_pricehelper["Price refresh helper"]
end

subgraph group_backend["Price backend"]
  node_backendserver["Express API<br/>[server.js]"]
  node_scraper["Price scraper<br/>[scraper.py]"]
  node_simulator["Price simulator<br/>[simulate_prices.py]"]
  node_ingredientmodel["Ingredient model<br/>[Ingredient.js]"]
  node_mongodb[("MongoDB connection<br/>[mongodb.js]")]
  node_ingredientstore[("Ingredient prices")]
end

node_visitor(("User"))

node_visitor -->|"visits"| node_landing
node_landing -->|"renders"| node_header
node_landing -->|"renders"| node_hero
node_landing -->|"renders"| node_heroimage
node_landing -->|"renders"| node_product
node_landing -->|"renders"| node_about
node_landing -->|"renders"| node_lazy
node_landing -->|"renders"| node_analytics
node_landing -->|"renders"| node_canvas
node_canvas -->|"renders"| node_wave
node_wave -->|"uses"| node_canvasctx
node_wave -->|"uses"| node_resize
node_wave -->|"uses"| node_waveutil
node_analytics -->|"uses"| node_gtag
node_visitor -.->|"enters profile"| node_getstarted
node_getstarted -.->|"continues to"| node_dietplan
node_dietplan -.->|"requests plan"| node_planapi
node_planapi -->|"requests inference"| node_ollama
node_planapi -.->|"caches plans"| node_plancache
node_planapi -->|"collects ingredients"| node_pricehelper
node_visitor -.->|"views recipe"| node_recipepage
node_recipepage -.->|"requests details"| node_recipeapi
node_recipeapi -->|"uses prices"| node_pricehelper
node_pricehelper -->|"requests refresh"| node_backendserver
node_backendserver -->|"runs scraper"| node_scraper
node_backendserver -.->|"supports simulation"| node_simulator
node_scraper -.->|"upserts prices"| node_ingredientmodel
node_ingredientmodel -.->|"uses connection"| node_mongodb
node_mongodb -.->|"stores prices"| node_ingredientstore

click node_landing "https://github.com/akii-real/budget-based-diet/blob/main/src/pages/index.tsx"
click node_header "https://github.com/akii-real/budget-based-diet/blob/main/src/components/Header.tsx"
click node_hero "https://github.com/akii-real/budget-based-diet/blob/main/src/components/MainHero.tsx"
click node_heroimage "https://github.com/akii-real/budget-based-diet/blob/main/src/components/MainHeroImage.tsx"
click node_product "https://github.com/akii-real/budget-based-diet/blob/main/src/components/Product.tsx"
click node_about "https://github.com/akii-real/budget-based-diet/blob/main/src/components/About.tsx"
click node_lazy "https://github.com/akii-real/budget-based-diet/blob/main/src/components/LazyShow.tsx"
click node_analytics "https://github.com/akii-real/budget-based-diet/blob/main/src/components/Analytics.tsx"
click node_canvas "https://github.com/akii-real/budget-based-diet/blob/main/src/components/Canvas.tsx"
click node_wave "https://github.com/akii-real/budget-based-diet/blob/main/src/components/Wave.tsx"
click node_canvasctx "https://github.com/akii-real/budget-based-diet/blob/main/src/hooks/useCanvas.ts"
click node_resize "https://github.com/akii-real/budget-based-diet/blob/main/src/hooks/useResponsiveSize.ts"
click node_waveutil "https://github.com/akii-real/budget-based-diet/blob/main/src/utils/wave.ts"
click node_gtag "https://github.com/akii-real/budget-based-diet/blob/main/src/lib/gtag.ts"
click node_getstarted "https://github.com/akii-real/budget-based-diet/blob/main/src/pages/GetStarted.tsx"
click node_dietplan "https://github.com/akii-real/budget-based-diet/blob/main/src/pages/diet-plan.tsx"
click node_planapi "https://github.com/akii-real/budget-based-diet/blob/main/src/pages/api/ai-meal-plan.js"
click node_recipepage "https://github.com/akii-real/budget-based-diet/blob/main/src/pages/recipe.tsx"
click node_recipeapi "https://github.com/akii-real/budget-based-diet/blob/main/src/pages/api/recipe.js"
click node_pricehelper "https://github.com/akii-real/budget-based-diet/blob/main/src/lib/ingredientPrices.js"
click node_backendserver "https://github.com/akii-real/budget-based-diet/blob/main/backend/server.js"
click node_scraper "https://github.com/akii-real/budget-based-diet/blob/main/backend/scrapers/scraper.py"
click node_simulator "https://github.com/akii-real/budget-based-diet/blob/main/backend/scrapers/simulate_prices.py"
click node_ingredientmodel "https://github.com/akii-real/budget-based-diet/blob/main/backend/models/Ingredient.js"
click node_mongodb "https://github.com/akii-real/budget-based-diet/blob/main/backend/database/mongodb.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_landing,node_header,node_hero,node_heroimage,node_product,node_about,node_lazy,node_analytics,node_canvas,node_wave,node_canvasctx,node_resize,node_waveutil,node_gtag,node_visitor toneBlue
class node_getstarted,node_dietplan,node_planapi,node_ollama,node_plancache,node_recipepage,node_recipeapi toneAmber
class node_pricehelper toneMint
class node_backendserver,node_scraper,node_simulator,node_ingredientmodel,node_mongodb,node_ingredientstore toneRose
```

## Components

### Web experience

- [Landing page](https://github.com/akii-real/budget-based-diet/blob/main/src/pages/index.tsx): `src/pages/index.tsx`
- [Navigation](https://github.com/akii-real/budget-based-diet/blob/main/src/components/Header.tsx): `src/components/Header.tsx`
- [Hero section](https://github.com/akii-real/budget-based-diet/blob/main/src/components/MainHero.tsx): `src/components/MainHero.tsx`
- [Hero image](https://github.com/akii-real/budget-based-diet/blob/main/src/components/MainHeroImage.tsx): `src/components/MainHeroImage.tsx`
- [Product section](https://github.com/akii-real/budget-based-diet/blob/main/src/components/Product.tsx): `src/components/Product.tsx`
- [About section](https://github.com/akii-real/budget-based-diet/blob/main/src/components/About.tsx): `src/components/About.tsx`
- [Lazy display](https://github.com/akii-real/budget-based-diet/blob/main/src/components/LazyShow.tsx): `src/components/LazyShow.tsx`
- [Analytics UI](https://github.com/akii-real/budget-based-diet/blob/main/src/components/Analytics.tsx): `src/components/Analytics.tsx`
- [Canvas display](https://github.com/akii-real/budget-based-diet/blob/main/src/components/Canvas.tsx): `src/components/Canvas.tsx`
- [Wave renderer](https://github.com/akii-real/budget-based-diet/blob/main/src/components/Wave.tsx): `src/components/Wave.tsx`
- [Canvas context](https://github.com/akii-real/budget-based-diet/blob/main/src/hooks/useCanvas.ts): `src/hooks/useCanvas.ts`
- [Responsive sizing](https://github.com/akii-real/budget-based-diet/blob/main/src/hooks/useResponsiveSize.ts): `src/hooks/useResponsiveSize.ts`
- [Wave drawing](https://github.com/akii-real/budget-based-diet/blob/main/src/utils/wave.ts): `src/utils/wave.ts`
- [Analytics tracking](https://github.com/akii-real/budget-based-diet/blob/main/src/lib/gtag.ts): `src/lib/gtag.ts`

### Meal planning

- [Profile input](https://github.com/akii-real/budget-based-diet/blob/main/src/pages/GetStarted.tsx): `src/pages/GetStarted.tsx`
- [Plan selection](https://github.com/akii-real/budget-based-diet/blob/main/src/pages/diet-plan.tsx): `src/pages/diet-plan.tsx`
- [Plan generation API](https://github.com/akii-real/budget-based-diet/blob/main/src/pages/api/ai-meal-plan.js): `src/pages/api/ai-meal-plan.js`
- **Local model**
- **Plan pool**
- [Recipe details](https://github.com/akii-real/budget-based-diet/blob/main/src/pages/recipe.tsx): `src/pages/recipe.tsx`
- [Recipe API](https://github.com/akii-real/budget-based-diet/blob/main/src/pages/api/recipe.js): `src/pages/api/recipe.js`

### Ingredient pricing

- [Price refresh helper](https://github.com/akii-real/budget-based-diet/blob/main/src/lib/ingredientPrices.js): `src/lib/ingredientPrices.js`

### Price backend

- [Express API](https://github.com/akii-real/budget-based-diet/blob/main/backend/server.js): `backend/server.js`
- [Price scraper](https://github.com/akii-real/budget-based-diet/blob/main/backend/scrapers/scraper.py): `backend/scrapers/scraper.py`
- [Price simulator](https://github.com/akii-real/budget-based-diet/blob/main/backend/scrapers/simulate_prices.py): `backend/scrapers/simulate_prices.py`
- [Ingredient model](https://github.com/akii-real/budget-based-diet/blob/main/backend/models/Ingredient.js): `backend/models/Ingredient.js`
- [MongoDB connection](https://github.com/akii-real/budget-based-diet/blob/main/backend/database/mongodb.js): `backend/database/mongodb.js`
- **Ingredient prices**

### Other components

- **User**

## Connections

- User → Landing page: visits (evidence: `README.md`)
- Landing page → Navigation: renders (evidence: `src/pages/index.tsx`)
- Landing page → Hero section: renders (evidence: `src/pages/index.tsx`)
- Landing page → Hero image: renders (evidence: `src/pages/index.tsx`)
- Landing page → Product section: renders (evidence: `src/pages/index.tsx`)
- Landing page → About section: renders (evidence: `src/pages/index.tsx`)
- Landing page → Lazy display: renders (evidence: `src/pages/index.tsx`)
- Landing page → Analytics UI: renders (evidence: `src/pages/index.tsx`)
- Landing page → Canvas display: renders (evidence: `src/pages/index.tsx`)
- Canvas display → Wave renderer: renders (evidence: `src/components/Canvas.tsx`)
- Wave renderer → Canvas context: uses (evidence: `src/components/Wave.tsx`)
- Wave renderer → Responsive sizing: uses (evidence: `src/components/Wave.tsx`)
- Wave renderer → Wave drawing: uses (evidence: `src/components/Wave.tsx`)
- Analytics UI → Analytics tracking: uses (evidence: `src/components/Analytics.tsx`)
- User → Profile input: enters profile
- Profile input → Plan selection: continues to
- Plan selection → Plan generation API: requests plan
- Plan generation API → Local model: requests inference (evidence: `src/pages/api/ai-meal-plan.js`)
- Plan generation API → Plan pool: caches plans
- Plan generation API → Price refresh helper: collects ingredients (evidence: `src/pages/api/ai-meal-plan.js`)
- User → Recipe details: views recipe
- Recipe details → Recipe API: requests details
- Recipe API → Price refresh helper: uses prices (evidence: `src/pages/api/recipe.js`)
- Price refresh helper → Express API: requests refresh (evidence: `src/lib/ingredientPrices.js`)
- Express API → Price scraper: runs scraper (evidence: `README.md`)
- Express API → Price simulator: supports simulation (evidence: `README.md`)
- Price scraper → Ingredient model: upserts prices
- Ingredient model → MongoDB connection: uses connection
- MongoDB connection → Ingredient prices: stores prices
