# gaganashreea/ai-food-recipe architecture

> Architecture diagram of the GitHub repository gaganashreea/ai-food-recipe, 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/gaganashreea/ai-food-recipe
- Repository: https://github.com/gaganashreea/ai-food-recipe

## Overview

This is a recipe-generation web app: users upload a food image, review detected ingredients, optionally set a dietary preference, and request a full recipe or suggestions. The client context holds workflow state and makes API requests; the server routes those requests to image-analysis, generation, suggestions, and saved-recipe handlers. Generated recipes can be saved, searched/filtered, viewed, and deleted. The server handlers use a Groq-backed AI client and a MongoDB recipe model. The README is empty, and several UI/server files were not excerpted, so unsampled details and unsupported connections are omitted.

Main entry points: [`client/src/pages/Home.jsx`](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/pages/Home.jsx) (Ingredient workflow), [`client/src/context/RecipeContext.jsx`](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/context/RecipeContext.jsx) (Workflow state and API), [`client/src/App.jsx`](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/App.jsx) (Route shell), [`client/src/pages/RecipeResult.jsx`](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/pages/RecipeResult.jsx) (Recipe result)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Recipe client"]
  node_app["Route shell<br/>[App.jsx]"]
  node_home["Ingredient workflow<br/>[Home.jsx]"]
  node_uploader["Image upload<br/>[ImageUploader.jsx]"]
  node_ingredientlist["Ingredient list<br/>[IngredientList.jsx]"]
  node_dietfilter["Diet filter<br/>[DietaryFilter.jsx]"]
  node_suggestionsview["Suggestion choices"]
  node_recipecontext["Workflow state and API<br/>[RecipeContext.jsx]"]
  node_resultpage["Recipe result<br/>[RecipeResult.jsx]"]
  node_detailpage["Saved detail<br/>[RecipeDetail.jsx]"]
  node_savedpage["Saved collection<br/>[SavedRecipes.jsx]"]
  node_recipedisplay["Recipe details view<br/>[RecipeDisplay.jsx]"]
  node_recipecard["Recipe card<br/>[RecipeCard.jsx]"]
  node_loader["Loading indicator<br/>[Loader.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
end

subgraph group_server["Recipe API"]
  node_api["Recipe routes<br/>[recipeRoutes.js]"]
  node_upload["Image validation<br/>[upload.js]"]
  node_controller["Recipe handlers"]
end

subgraph group_ai["AI generation"]
  node_groq{{"Groq AI service"}}
  node_geminiconfig["AI client config<br/>[gemini.js]"]
end

subgraph group_persistence["Saved recipes"]
  node_recipe["Recipe schema<br/>[Recipe.js]"]
  node_mongodb[("MongoDB")]
  node_dbconfig["Database connection<br/>[db.js]"]
end

node_user(("User"))

node_user -->|"uses"| node_home
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_resultpage
node_app -->|"routes to"| node_savedpage
node_app -->|"routes to"| node_detailpage
node_home -->|"renders"| node_uploader
node_home -->|"renders"| node_ingredientlist
node_home -->|"renders"| node_dietfilter
node_home -->|"renders"| node_suggestionsview
node_home -->|"requests generation"| node_recipecontext
node_uploader -->|"analyzes image"| node_recipecontext
node_resultpage -->|"reads recipe"| node_recipecontext
node_resultpage -->|"renders"| node_recipedisplay
node_recipedisplay -->|"renders"| node_recipecard
node_savedpage -->|"fetches recipes"| node_recipecontext
node_savedpage -->|"renders"| node_recipecard
node_detailpage -->|"renders"| node_recipedisplay
node_recipecard -->|"saves or deletes"| node_recipecontext
node_recipecontext -->|"requests API"| node_api
node_api -->|"validates image"| node_upload
node_api -->|"dispatches handlers"| node_controller
node_controller -->|"uses AI client"| node_geminiconfig
node_geminiconfig -.->|"configures"| node_groq
node_controller -->|"queries or saves"| node_recipe
node_dbconfig -->|"connects"| node_mongodb

click node_app "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/App.jsx"
click node_home "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/pages/Home.jsx"
click node_uploader "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/ImageUploader.jsx"
click node_ingredientlist "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/IngredientList.jsx"
click node_dietfilter "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/DietaryFilter.jsx"
click node_suggestionsview "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/SuggestionsList.jsx"
click node_recipecontext "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/context/RecipeContext.jsx"
click node_resultpage "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/pages/RecipeResult.jsx"
click node_detailpage "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/pages/RecipeDetail.jsx"
click node_savedpage "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/pages/SavedRecipes.jsx"
click node_recipedisplay "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/RecipeDisplay.jsx"
click node_recipecard "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/RecipeCard.jsx"
click node_loader "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/Loader.jsx"
click node_navbar "https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/Navbar.jsx"
click node_api "https://github.com/gaganashreea/ai-food-recipe/blob/main/server/routes/recipeRoutes.js"
click node_upload "https://github.com/gaganashreea/ai-food-recipe/blob/main/server/middleware/upload.js"
click node_controller "https://github.com/gaganashreea/ai-food-recipe/blob/main/server/controllers/recipeController.js"
click node_geminiconfig "https://github.com/gaganashreea/ai-food-recipe/blob/main/server/config/gemini.js"
click node_recipe "https://github.com/gaganashreea/ai-food-recipe/blob/main/server/models/Recipe.js"
click node_dbconfig "https://github.com/gaganashreea/ai-food-recipe/blob/main/server/config/db.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_app,node_home,node_uploader,node_ingredientlist,node_dietfilter,node_suggestionsview,node_recipecontext,node_resultpage,node_detailpage,node_savedpage,node_recipedisplay,node_recipecard,node_loader,node_navbar,node_user toneBlue
class node_api,node_upload,node_controller toneAmber
class node_groq,node_geminiconfig toneMint
class node_recipe,node_mongodb,node_dbconfig toneRose
```

## Components

### Recipe client

- [Route shell](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Ingredient workflow](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/pages/Home.jsx): `client/src/pages/Home.jsx`
- [Image upload](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/ImageUploader.jsx): `client/src/components/ImageUploader.jsx`
- [Ingredient list](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/IngredientList.jsx): `client/src/components/IngredientList.jsx`
- [Diet filter](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/DietaryFilter.jsx): `client/src/components/DietaryFilter.jsx`
- [Suggestion choices](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/SuggestionsList.jsx): `client/src/components/SuggestionsList.jsx`
- [Workflow state and API](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/context/RecipeContext.jsx): `client/src/context/RecipeContext.jsx`
- [Recipe result](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/pages/RecipeResult.jsx): `client/src/pages/RecipeResult.jsx`
- [Saved detail](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/pages/RecipeDetail.jsx): `client/src/pages/RecipeDetail.jsx`
- [Saved collection](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/pages/SavedRecipes.jsx): `client/src/pages/SavedRecipes.jsx`
- [Recipe details view](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/RecipeDisplay.jsx): `client/src/components/RecipeDisplay.jsx`
- [Recipe card](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/RecipeCard.jsx): `client/src/components/RecipeCard.jsx`
- [Loading indicator](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/Loader.jsx): `client/src/components/Loader.jsx`
- [Navigation](https://github.com/gaganashreea/ai-food-recipe/blob/main/client/src/components/Navbar.jsx): `client/src/components/Navbar.jsx`

### Recipe API

- [Recipe routes](https://github.com/gaganashreea/ai-food-recipe/blob/main/server/routes/recipeRoutes.js): `server/routes/recipeRoutes.js`
- [Image validation](https://github.com/gaganashreea/ai-food-recipe/blob/main/server/middleware/upload.js): `server/middleware/upload.js`
- [Recipe handlers](https://github.com/gaganashreea/ai-food-recipe/blob/main/server/controllers/recipeController.js): `server/controllers/recipeController.js`

### AI generation

- **Groq AI service**
- [AI client config](https://github.com/gaganashreea/ai-food-recipe/blob/main/server/config/gemini.js): `server/config/gemini.js`

### Saved recipes

- [Recipe schema](https://github.com/gaganashreea/ai-food-recipe/blob/main/server/models/Recipe.js): `server/models/Recipe.js`
- **MongoDB**
- [Database connection](https://github.com/gaganashreea/ai-food-recipe/blob/main/server/config/db.js): `server/config/db.js`

### Other components

- **User**

## Connections

- User → Ingredient workflow: uses
- Route shell → Ingredient workflow: routes to (evidence: `client/src/App.jsx`)
- Route shell → Recipe result: routes to (evidence: `client/src/App.jsx`)
- Route shell → Saved collection: routes to (evidence: `client/src/App.jsx`)
- Route shell → Saved detail: routes to (evidence: `client/src/App.jsx`)
- Ingredient workflow → Image upload: renders (evidence: `client/src/pages/Home.jsx`)
- Ingredient workflow → Ingredient list: renders (evidence: `client/src/pages/Home.jsx`)
- Ingredient workflow → Diet filter: renders (evidence: `client/src/pages/Home.jsx`)
- Ingredient workflow → Suggestion choices: renders (evidence: `client/src/pages/Home.jsx`)
- Ingredient workflow → Workflow state and API: requests generation (evidence: `client/src/pages/Home.jsx`)
- Image upload → Workflow state and API: analyzes image (evidence: `client/src/components/ImageUploader.jsx`)
- Recipe result → Workflow state and API: reads recipe (evidence: `client/src/pages/RecipeResult.jsx`)
- Recipe result → Recipe details view: renders (evidence: `client/src/pages/RecipeResult.jsx`)
- Recipe details view → Recipe card: renders (evidence: `client/src/components/RecipeDisplay.jsx`)
- Saved collection → Workflow state and API: fetches recipes (evidence: `client/src/pages/SavedRecipes.jsx`)
- Saved collection → Recipe card: renders (evidence: `client/src/pages/SavedRecipes.jsx`)
- Saved detail → Recipe details view: renders (evidence: `client/src/pages/RecipeDetail.jsx`)
- Recipe card → Workflow state and API: saves or deletes (evidence: `client/src/components/RecipeCard.jsx`)
- Workflow state and API → Recipe routes: requests API (evidence: `client/src/context/RecipeContext.jsx`)
- Recipe routes → Image validation: validates image (evidence: `server/routes/recipeRoutes.js`)
- Recipe routes → Recipe handlers: dispatches handlers (evidence: `server/routes/recipeRoutes.js`)
- Recipe handlers → AI client config: uses AI client (evidence: `server/controllers/recipeController.js`)
- AI client config → Groq AI service: configures
- Recipe handlers → Recipe schema: queries or saves (evidence: `server/controllers/recipeController.js`)
- Database connection → MongoDB: connects (evidence: `server/config/db.js`)
