# bijuliji19-code/smart-pantry-tracker architecture

> Architecture diagram of the GitHub repository bijuliji19-code/smart-pantry-tracker, 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/bijuliji19-code/smart-pantry-tracker
- Repository: https://github.com/bijuliji19-code/smart-pantry-tracker

## Overview

Smart Pantry Tracker supports account access, pantry and expiry/stock tracking, barcode lookup, grocery lists, recipe suggestions, and waste tracking. The principal workflow is to sign in, manage pantry items, then use pantry state for alerts and recipe matching while tracking shopping and waste separately. The graph includes the frontend navigation and backend route/model layers. Frontend-to-API calls are not shown because the sampled frontend references do not establish them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/App.jsx) (Application router), [`backend/server.js`](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/server.js) (Express server), [`backend/middleware/auth.js`](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/middleware/auth.js) (JWT authentication), [`backend/routes/recipeRoutes.js`](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/recipeRoutes.js) (Recipe routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend navigation"]
  node_app["Application router<br/>[App.jsx]"]
  node_landing["Landing page<br/>[Landing.jsx]"]
  node_authui["Sign-in UI<br/>[Auth.jsx]"]
end

subgraph group_pantry["Pantry and insights"]
  node_pantryui["Pantry management<br/>[Pantry.jsx]"]
  node_scanner["Barcode scanner<br/>[BarcodeScanner.jsx]"]
  node_loader["Loading state<br/>[Loader.jsx]"]
  node_wasteui["Waste tracking<br/>[Waste.jsx]"]
  node_groceryui["Grocery list<br/>[GroceryList.jsx]"]
  node_recipesui["Recipe suggestions<br/>[Recipes.jsx]"]
end

subgraph group_api["Backend API"]
  node_server["Express server<br/>[server.js]"]
  node_authroutes["Authentication routes<br/>[authRoutes.js]"]
  node_itemroutes["Pantry item routes<br/>[itemRoutes.js]"]
  node_groceryroutes["Grocery routes<br/>[groceryRoutes.js]"]
  node_productroutes["Local product routes"]
  node_reciperoutes["Recipe routes<br/>[recipeRoutes.js]"]
  node_userroutes["User routes<br/>[userRoutes.js]"]
  node_middleware["JWT authentication<br/>[auth.js]"]
end

subgraph group_data["MongoDB models"]
  node_pantrymodel[("Pantry item model<br/>[PantryItem.js]")]
  node_grocerymodel[("Grocery item model<br/>[GroceryItem.js]")]
  node_productmodel[("Local product model<br/>[LocalProduct.js]")]
  node_recipemodel[("Recipe model<br/>[Recipe.js]")]
  node_usermodel[("User model<br/>[User.js]")]
  node_seed["Recipe seed data<br/>[seedRecipes.js]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_pantryui
node_app -->|"routes to"| node_wasteui
node_app -->|"routes to"| node_groceryui
node_app -->|"routes to"| node_recipesui
node_pantryui -->|"uses"| node_scanner
node_pantryui -->|"renders"| node_loader
node_server -->|"mounts"| node_itemroutes
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_productroutes
node_server -->|"mounts"| node_groceryroutes
node_server -->|"mounts"| node_userroutes
node_server -->|"mounts"| node_reciperoutes
node_authroutes -->|"reads and writes"| node_usermodel
node_itemroutes -->|"reads and writes"| node_pantrymodel
node_groceryroutes -->|"reads and writes"| node_grocerymodel
node_productroutes -->|"reads and writes"| node_productmodel
node_reciperoutes -->|"reads"| node_pantrymodel
node_reciperoutes -->|"reads"| node_recipemodel
node_userroutes -->|"reads"| node_usermodel
node_itemroutes -->|"authenticates"| node_middleware
node_groceryroutes -->|"authenticates"| node_middleware
node_productroutes -->|"authenticates"| node_middleware
node_reciperoutes -->|"authenticates"| node_middleware
node_userroutes -->|"authenticates"| node_middleware
node_middleware -->|"updates activity"| node_usermodel
node_seed -->|"populates"| node_recipemodel

click node_app "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/App.jsx"
click node_landing "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Landing.jsx"
click node_authui "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Auth.jsx"
click node_pantryui "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Pantry.jsx"
click node_scanner "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/BarcodeScanner.jsx"
click node_loader "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Loader.jsx"
click node_wasteui "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Waste.jsx"
click node_groceryui "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/GroceryList.jsx"
click node_recipesui "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Recipes.jsx"
click node_server "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/server.js"
click node_authroutes "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/authRoutes.js"
click node_itemroutes "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/itemRoutes.js"
click node_groceryroutes "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/groceryRoutes.js"
click node_productroutes "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/localProductRoutes.js"
click node_reciperoutes "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/recipeRoutes.js"
click node_userroutes "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/userRoutes.js"
click node_middleware "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/middleware/auth.js"
click node_pantrymodel "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/models/PantryItem.js"
click node_grocerymodel "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/models/GroceryItem.js"
click node_productmodel "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/models/LocalProduct.js"
click node_recipemodel "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/models/Recipe.js"
click node_usermodel "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/models/User.js"
click node_seed "https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/seedRecipes.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_landing,node_authui,node_user toneBlue
class node_pantryui,node_scanner,node_loader,node_wasteui,node_groceryui,node_recipesui toneAmber
class node_server,node_authroutes,node_itemroutes,node_groceryroutes,node_productroutes,node_reciperoutes,node_userroutes,node_middleware toneMint
class node_pantrymodel,node_grocerymodel,node_productmodel,node_recipemodel,node_usermodel,node_seed toneRose
```

## Components

### Frontend navigation

- [Application router](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Landing page](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Landing.jsx): `frontend/src/Landing.jsx`
- [Sign-in UI](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Auth.jsx): `frontend/src/Auth.jsx`

### Pantry and insights

- [Pantry management](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Pantry.jsx): `frontend/src/Pantry.jsx`
- [Barcode scanner](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/BarcodeScanner.jsx): `frontend/src/BarcodeScanner.jsx`
- [Loading state](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Loader.jsx): `frontend/src/Loader.jsx`
- [Waste tracking](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Waste.jsx): `frontend/src/Waste.jsx`
- [Grocery list](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/GroceryList.jsx): `frontend/src/GroceryList.jsx`
- [Recipe suggestions](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/frontend/src/Recipes.jsx): `frontend/src/Recipes.jsx`

### Backend API

- [Express server](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/server.js): `backend/server.js`
- [Authentication routes](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Pantry item routes](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/itemRoutes.js): `backend/routes/itemRoutes.js`
- [Grocery routes](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/groceryRoutes.js): `backend/routes/groceryRoutes.js`
- [Local product routes](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/localProductRoutes.js): `backend/routes/localProductRoutes.js`
- [Recipe routes](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/recipeRoutes.js): `backend/routes/recipeRoutes.js`
- [User routes](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/routes/userRoutes.js): `backend/routes/userRoutes.js`
- [JWT authentication](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`

### MongoDB models

- [Pantry item model](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/models/PantryItem.js): `backend/models/PantryItem.js`
- [Grocery item model](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/models/GroceryItem.js): `backend/models/GroceryItem.js`
- [Local product model](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/models/LocalProduct.js): `backend/models/LocalProduct.js`
- [Recipe model](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/models/Recipe.js): `backend/models/Recipe.js`
- [User model](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/models/User.js): `backend/models/User.js`
- [Recipe seed data](https://github.com/bijuliji19-code/smart-pantry-tracker/blob/main/backend/seedRecipes.js): `backend/seedRecipes.js`

### Other components

- **User**

## Connections

- User → Application router: uses (evidence: `frontend/src/App.jsx`)
- Application router → Landing page: routes to (evidence: `frontend/src/App.jsx`)
- Application router → Sign-in UI: routes to (evidence: `frontend/src/App.jsx`)
- Application router → Pantry management: routes to (evidence: `frontend/src/App.jsx`)
- Application router → Waste tracking: routes to (evidence: `frontend/src/App.jsx`)
- Application router → Grocery list: routes to (evidence: `frontend/src/App.jsx`)
- Application router → Recipe suggestions: routes to (evidence: `frontend/src/App.jsx`)
- Pantry management → Barcode scanner: uses (evidence: `frontend/src/Pantry.jsx`)
- Pantry management → Loading state: renders (evidence: `frontend/src/Pantry.jsx`)
- Express server → Pantry item routes: mounts (evidence: `backend/server.js`)
- Express server → Authentication routes: mounts (evidence: `backend/server.js`)
- Express server → Local product routes: mounts (evidence: `backend/server.js`)
- Express server → Grocery routes: mounts (evidence: `backend/server.js`)
- Express server → User routes: mounts (evidence: `backend/server.js`)
- Express server → Recipe routes: mounts (evidence: `backend/server.js`)
- Authentication routes → User model: reads and writes (evidence: `backend/routes/authRoutes.js`)
- Pantry item routes → Pantry item model: reads and writes (evidence: `backend/routes/itemRoutes.js`)
- Grocery routes → Grocery item model: reads and writes (evidence: `backend/routes/groceryRoutes.js`)
- Local product routes → Local product model: reads and writes (evidence: `backend/routes/localProductRoutes.js`)
- Recipe routes → Pantry item model: reads (evidence: `backend/routes/recipeRoutes.js`)
- Recipe routes → Recipe model: reads (evidence: `backend/routes/recipeRoutes.js`)
- User routes → User model: reads (evidence: `backend/routes/userRoutes.js`)
- Pantry item routes → JWT authentication: authenticates (evidence: `backend/routes/itemRoutes.js`)
- Grocery routes → JWT authentication: authenticates (evidence: `backend/routes/groceryRoutes.js`)
- Local product routes → JWT authentication: authenticates (evidence: `backend/routes/localProductRoutes.js`)
- Recipe routes → JWT authentication: authenticates (evidence: `backend/routes/recipeRoutes.js`)
- User routes → JWT authentication: authenticates (evidence: `backend/routes/userRoutes.js`)
- JWT authentication → User model: updates activity (evidence: `backend/middleware/auth.js`)
- Recipe seed data → Recipe model: populates (evidence: `backend/seedRecipes.js`)
