# abirami-mj/smart_grocery_planner_ui architecture

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

- Interactive diagram: https://gitdiagram.com/abirami-mj/smart_grocery_planner_ui
- Repository: https://github.com/abirami-mj/smart_grocery_planner_ui

## Overview

Smart Grocery Planner is a React application for tracking grocery freshness, reducing waste, and supporting accessible food decisions, backed by a device-scoped API. The main flow is user entry of groceries, state/API synchronization, expiry and health calculations, then dashboard, alert, consume-today, and analytics views. Settings provide elder mode and voice/sound accessibility. The backend stores items and computes analytics in memory. Feature pages beyond the sampled excerpts are included from the README and source index; their internal implementation links are omitted where not evidenced.

Main entry points: [`src/App.jsx`](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/App.jsx) (Routes and layout), [`src/context/GroceryContext.jsx`](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/context/GroceryContext.jsx) (Inventory and expiry state), [`src/components/Grocery/GroceryItem.jsx`](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/components/Grocery/GroceryItem.jsx) (Grocery item actions), [`src/pages/Dashboard.jsx`](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/Dashboard.jsx) (Health dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_app["Routes and layout<br/>[App.jsx]"]
end

subgraph group_grocery["Grocery lifecycle"]
  node_add["Add groceries<br/>[GroceryForm.jsx]"]
  node_state["Inventory and expiry state<br/>[GroceryContext.jsx]"]
  node_item["Grocery item actions<br/>[GroceryItem.jsx]"]
  node_progress["Freshness display<br/>[ProgressBar.jsx]"]
end

subgraph group_insights["Freshness insights"]
  node_dashboard["Health dashboard<br/>[Dashboard.jsx]"]
  node_tracker["Expiry tracker<br/>[ExpiryTracker.jsx]"]
  node_alerts["Smart alerts<br/>[SmartAlerts.jsx]"]
  node_consume["Consume today<br/>[ConsumeToday.jsx]"]
  node_analytics["Waste analytics<br/>[WasteAnalytics.jsx]"]
end

subgraph group_access["Accessibility settings"]
  node_elder["Elder mode<br/>[ElderMode.jsx]"]
  node_settings["Settings controls<br/>[Settings.jsx]"]
  node_settingsstate["Accessibility preferences"]
end

subgraph group_backend["Backend services"]
  node_api["Frontend API client<br/>[api.js]"]
  node_service["Grocery API routes<br/>[main.py]"]
  node_storage[("Inventory and analytics store<br/>[database.py]")]
  node_models["Grocery data models<br/>[models.py]"]
end

node_person(("Grocery planner"))
node_server{{"API service"}}
node_browserstore[("Browser localStorage")]

node_person -->|"opens app"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_add
node_app -->|"routes to"| node_tracker
node_app -->|"routes to"| node_alerts
node_app -->|"routes to"| node_consume
node_app -->|"routes to"| node_analytics
node_app -->|"routes to"| node_elder
node_app -->|"routes to"| node_settings
node_add -->|"adds item"| node_state
node_add -->|"submits item"| node_api
node_state -->|"syncs inventory"| node_api
node_tracker -->|"renders items"| node_item
node_dashboard -->|"renders items"| node_item
node_alerts -->|"renders items"| node_item
node_consume -->|"renders items"| node_item
node_item -->|"updates actions"| node_state
node_item -->|"records actions"| node_api
node_dashboard -->|"reads metrics"| node_state
node_tracker -->|"reads inventory"| node_state
node_alerts -->|"reads inventory"| node_state
node_consume -->|"reads suggestions"| node_state
node_analytics -->|"reads waste stats"| node_state
node_dashboard -->|"shows freshness"| node_progress
node_item -->|"shows expiry"| node_progress
node_settings -->|"updates preferences"| node_settingsstate
node_elder -->|"updates preferences"| node_settingsstate
node_settingsstate -->|"persists settings"| node_browserstore
node_server -.->|"serves requests"| node_service
node_api -->|"sends HTTP requests"| node_service
node_service -->|"reads and writes"| node_storage
node_storage -->|"creates responses"| node_models

click node_app "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/App.jsx"
click node_add "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/components/Grocery/GroceryForm.jsx"
click node_state "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/context/GroceryContext.jsx"
click node_item "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/components/Grocery/GroceryItem.jsx"
click node_dashboard "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/Dashboard.jsx"
click node_tracker "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/ExpiryTracker.jsx"
click node_alerts "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/SmartAlerts.jsx"
click node_consume "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/ConsumeToday.jsx"
click node_analytics "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/WasteAnalytics.jsx"
click node_elder "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/ElderMode.jsx"
click node_settings "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/Settings.jsx"
click node_settingsstate "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/context/SettingsContext.jsx"
click node_progress "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/components/UI/ProgressBar.jsx"
click node_api "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/services/api.js"
click node_service "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/backend/main.py"
click node_storage "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/backend/database.py"
click node_models "https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/backend/models.py"

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 toneBlue
class node_add,node_state,node_item,node_progress,node_browserstore toneAmber
class node_dashboard,node_tracker,node_alerts,node_consume,node_analytics,node_server toneMint
class node_elder,node_settings,node_settingsstate toneRose
class node_api,node_service,node_storage,node_models,node_person toneIndigo
```

## Components

### Application

- [Routes and layout](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/App.jsx): `src/App.jsx`

### Grocery lifecycle

- [Add groceries](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/components/Grocery/GroceryForm.jsx): `src/components/Grocery/GroceryForm.jsx`
- [Inventory and expiry state](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/context/GroceryContext.jsx): `src/context/GroceryContext.jsx`
- [Grocery item actions](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/components/Grocery/GroceryItem.jsx): `src/components/Grocery/GroceryItem.jsx`
- [Freshness display](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/components/UI/ProgressBar.jsx): `src/components/UI/ProgressBar.jsx`

### Freshness insights

- [Health dashboard](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/Dashboard.jsx): `src/pages/Dashboard.jsx`
- [Expiry tracker](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/ExpiryTracker.jsx): `src/pages/ExpiryTracker.jsx`
- [Smart alerts](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/SmartAlerts.jsx): `src/pages/SmartAlerts.jsx`
- [Consume today](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/ConsumeToday.jsx): `src/pages/ConsumeToday.jsx`
- [Waste analytics](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/WasteAnalytics.jsx): `src/pages/WasteAnalytics.jsx`

### Accessibility settings

- [Elder mode](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/ElderMode.jsx): `src/pages/ElderMode.jsx`
- [Settings controls](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/pages/Settings.jsx): `src/pages/Settings.jsx`
- [Accessibility preferences](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/context/SettingsContext.jsx): `src/context/SettingsContext.jsx`

### Backend services

- [Frontend API client](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/src/services/api.js): `src/services/api.js`
- [Grocery API routes](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/backend/main.py): `backend/main.py`
- [Inventory and analytics store](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/backend/database.py): `backend/database.py`
- [Grocery data models](https://github.com/abirami-mj/smart_grocery_planner_ui/blob/master/backend/models.py): `backend/models.py`

### Other components

- **Grocery planner**
- **API service**
- **Browser localStorage**

## Connections

- Grocery planner → Routes and layout: opens app (evidence: `src/App.jsx`)
- Routes and layout → Health dashboard: routes to (evidence: `src/App.jsx`)
- Routes and layout → Add groceries: routes to (evidence: `src/App.jsx`)
- Routes and layout → Expiry tracker: routes to (evidence: `src/App.jsx`)
- Routes and layout → Smart alerts: routes to (evidence: `src/App.jsx`)
- Routes and layout → Consume today: routes to (evidence: `src/App.jsx`)
- Routes and layout → Waste analytics: routes to (evidence: `src/App.jsx`)
- Routes and layout → Elder mode: routes to (evidence: `src/App.jsx`)
- Routes and layout → Settings controls: routes to (evidence: `src/App.jsx`)
- Add groceries → Inventory and expiry state: adds item (evidence: `src/components/Grocery/GroceryForm.jsx`)
- Add groceries → Frontend API client: submits item (evidence: `src/components/Grocery/GroceryForm.jsx`)
- Inventory and expiry state → Frontend API client: syncs inventory (evidence: `src/context/GroceryContext.jsx`)
- Expiry tracker → Grocery item actions: renders items (evidence: `src/pages/ExpiryTracker.jsx`)
- Health dashboard → Grocery item actions: renders items (evidence: `src/pages/Dashboard.jsx`)
- Smart alerts → Grocery item actions: renders items (evidence: `src/pages/SmartAlerts.jsx`)
- Consume today → Grocery item actions: renders items (evidence: `src/pages/ConsumeToday.jsx`)
- Grocery item actions → Inventory and expiry state: updates actions (evidence: `src/components/Grocery/GroceryItem.jsx`)
- Grocery item actions → Frontend API client: records actions (evidence: `src/components/Grocery/GroceryItem.jsx`)
- Health dashboard → Inventory and expiry state: reads metrics (evidence: `src/pages/Dashboard.jsx`)
- Expiry tracker → Inventory and expiry state: reads inventory (evidence: `src/pages/ExpiryTracker.jsx`)
- Smart alerts → Inventory and expiry state: reads inventory (evidence: `src/pages/SmartAlerts.jsx`)
- Consume today → Inventory and expiry state: reads suggestions (evidence: `src/pages/ConsumeToday.jsx`)
- Waste analytics → Inventory and expiry state: reads waste stats (evidence: `src/pages/WasteAnalytics.jsx`)
- Health dashboard → Freshness display: shows freshness (evidence: `src/pages/Dashboard.jsx`)
- Grocery item actions → Freshness display: shows expiry (evidence: `src/components/Grocery/GroceryItem.jsx`)
- Settings controls → Accessibility preferences: updates preferences (evidence: `src/pages/Settings.jsx`)
- Elder mode → Accessibility preferences: updates preferences (evidence: `src/pages/ElderMode.jsx`)
- Accessibility preferences → Browser localStorage: persists settings (evidence: `src/context/SettingsContext.jsx`)
- API service → Grocery API routes: serves requests
- Frontend API client → Grocery API routes: sends HTTP requests (evidence: `src/services/api.js`)
- Grocery API routes → Inventory and analytics store: reads and writes (evidence: `backend/main.py`)
- Inventory and analytics store → Grocery data models: creates responses (evidence: `backend/database.py`)
