# mohammadwaseem6/expiry-traker architecture

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

- Interactive diagram: https://gitdiagram.com/mohammadwaseem6/expiry-traker
- Repository: https://github.com/mohammadwaseem6/expiry-traker

## Overview

Expiry Tracker is a full-stack inventory app: store staff sign in, add or import products, monitor expiry and stock, and review inventory analytics. The React client routes authenticated users to stock, dashboard, reports, charts, and settings views; its API client calls the Express service, which authenticates requests, dispatches inventory and account operations, and persists records in MongoDB. Separate upload and AI endpoints extract item data from files or delivery-note images. README capabilities are included where the tree supports them; page-to-API call details and unshown route wiring are not inferred.

Main entry points: [`CLIENT/src/App.jsx`](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/App.jsx) (App routing), [`SERVER/index.js`](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/index.js) (Express entry), [`CLIENT/src/Api/apiClient.js`](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/Api/apiClient.js) (API client), [`CLIENT/src/pages/Login.jsx`](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Login.jsx) (Login and register)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Inventory client"]
  node_app["App routing<br/>[App.jsx]"]
  node_authui["Login and register<br/>[Login.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_stock["Stock management<br/>[Stock.jsx]"]
  node_reports["Reports and charts<br/>[Reports.jsx]"]
  node_charts["Chart views<br/>[Charts.jsx]"]
  node_expired["Expired items<br/>[ExpiredView.jsx]"]
  node_settings["Settings<br/>[SettingsView.jsx]"]
  node_chatbot["AI assistant<br/>[AIChatbot.jsx]"]
  node_apiclient["API client<br/>[apiClient.js]"]
end

subgraph group_service["API service"]
  node_server["Express entry<br/>[index.js]"]
  node_itemroutes["Item routes<br/>[itemRoutes.js]"]
  node_itemcontroller["Item operations<br/>[itemController.js]"]
  node_itemmodel["Inventory records<br/>[Item.js]"]
  node_db[("MongoDB connection<br/>[db.js]")]
  node_orders["Order records<br/>[Order.js]"]
end

subgraph group_extract["Item extraction"]
  node_upload["File extraction<br/>[uploadRoutes.js]"]
  node_ai["Image extraction<br/>[aiRoutes.js]"]
end

subgraph group_identity["Identity and access"]
  node_authstate["Auth context<br/>[AuthContext.jsx]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_authcontroller["Auth controller<br/>[authController.js]"]
  node_middleware["JWT middleware<br/>[auth.js]"]
  node_userroutes["User routes<br/>[userRoutes.js]"]
  node_usercontroller["User administration<br/>[userController.js]"]
  node_usermodel["User records<br/>[User.js]"]
end

node_staff(("Store staff"))
node_gemini{{"Gemini AI"}}

node_staff -->|"opens app"| node_app
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_stock
node_app -->|"routes to"| node_reports
node_app -->|"routes to"| node_charts
node_app -->|"routes to"| node_expired
node_app -->|"routes to"| node_settings
node_staff -->|"submits credentials"| node_authui
node_authui -->|"sets session"| node_authstate
node_authui -->|"requests auth"| node_apiclient
node_dashboard -->|"loads inventory"| node_apiclient
node_stock -->|"manages items"| node_apiclient
node_reports -->|"requests data"| node_apiclient
node_charts -->|"requests data"| node_apiclient
node_expired -->|"requests items"| node_apiclient
node_apiclient -->|"sends API requests"| node_server
node_server -->|"mounts routes"| node_authroutes
node_server -->|"mounts routes"| node_itemroutes
node_server -->|"mounts routes"| node_userroutes
node_server -->|"mounts routes"| node_upload
node_server -->|"mounts routes"| node_ai
node_server -->|"connects"| node_db
node_authroutes -->|"dispatches"| node_authcontroller
node_authcontroller -->|"reads and writes"| node_usermodel
node_itemroutes -->|"protects routes"| node_middleware
node_itemroutes -->|"dispatches"| node_itemcontroller
node_itemcontroller -->|"reads and writes"| node_itemmodel
node_userroutes -->|"protects routes"| node_middleware
node_userroutes -->|"dispatches"| node_usercontroller
node_usercontroller -->|"reads and writes"| node_usermodel
node_upload -->|"authenticates"| node_middleware
node_ai -->|"authenticates"| node_middleware
node_ai -.->|"sends image prompt"| node_gemini
node_chatbot -.->|"uses assistant"| node_apiclient

click node_app "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/App.jsx"
click node_authui "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Login.jsx"
click node_dashboard "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Dashboard.jsx"
click node_stock "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Stock.jsx"
click node_reports "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Reports.jsx"
click node_charts "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Charts.jsx"
click node_expired "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/ExpiredView.jsx"
click node_settings "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/SettingsView.jsx"
click node_chatbot "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/AIChatbot.jsx"
click node_authstate "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/context/AuthContext.jsx"
click node_apiclient "https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/Api/apiClient.js"
click node_server "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/index.js"
click node_authroutes "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/routes/authRoutes.js"
click node_authcontroller "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/controllers/authController.js"
click node_middleware "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/middleware/auth.js"
click node_itemroutes "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/routes/itemRoutes.js"
click node_itemcontroller "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/controllers/itemController.js"
click node_itemmodel "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/models/Item.js"
click node_userroutes "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/routes/userRoutes.js"
click node_usercontroller "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/controllers/userController.js"
click node_usermodel "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/models/User.js"
click node_db "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/config/db.js"
click node_upload "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/routes/uploadRoutes.js"
click node_ai "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/routes/aiRoutes.js"
click node_orders "https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/models/Order.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_authui,node_dashboard,node_stock,node_reports,node_charts,node_expired,node_settings,node_chatbot,node_apiclient toneBlue
class node_server,node_itemroutes,node_itemcontroller,node_itemmodel,node_db,node_orders toneAmber
class node_upload,node_ai toneMint
class node_authstate,node_authroutes,node_authcontroller,node_middleware,node_userroutes,node_usercontroller,node_usermodel toneRose
class node_staff,node_gemini toneIndigo
```

## Components

### Inventory client

- [App routing](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/App.jsx): `CLIENT/src/App.jsx`
- [Login and register](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Login.jsx): `CLIENT/src/pages/Login.jsx`
- [Dashboard](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Dashboard.jsx): `CLIENT/src/pages/Dashboard.jsx`
- [Stock management](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Stock.jsx): `CLIENT/src/pages/Stock.jsx`
- [Reports and charts](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Reports.jsx): `CLIENT/src/pages/Reports.jsx`
- [Chart views](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/Charts.jsx): `CLIENT/src/pages/Charts.jsx`
- [Expired items](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/ExpiredView.jsx): `CLIENT/src/pages/ExpiredView.jsx`
- [Settings](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/SettingsView.jsx): `CLIENT/src/pages/SettingsView.jsx`
- [AI assistant](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/pages/AIChatbot.jsx): `CLIENT/src/pages/AIChatbot.jsx`
- [API client](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/Api/apiClient.js): `CLIENT/src/Api/apiClient.js`

### API service

- [Express entry](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/index.js): `SERVER/index.js`
- [Item routes](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/routes/itemRoutes.js): `SERVER/routes/itemRoutes.js`
- [Item operations](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/controllers/itemController.js): `SERVER/controllers/itemController.js`
- [Inventory records](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/models/Item.js): `SERVER/models/Item.js`
- [MongoDB connection](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/config/db.js): `SERVER/config/db.js`
- [Order records](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/models/Order.js): `SERVER/models/Order.js`

### Item extraction

- [File extraction](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/routes/uploadRoutes.js): `SERVER/routes/uploadRoutes.js`
- [Image extraction](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/routes/aiRoutes.js): `SERVER/routes/aiRoutes.js`

### Identity and access

- [Auth context](https://github.com/mohammadwaseem6/expiry-traker/blob/main/CLIENT/src/context/AuthContext.jsx): `CLIENT/src/context/AuthContext.jsx`
- [Auth routes](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/routes/authRoutes.js): `SERVER/routes/authRoutes.js`
- [Auth controller](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/controllers/authController.js): `SERVER/controllers/authController.js`
- [JWT middleware](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/middleware/auth.js): `SERVER/middleware/auth.js`
- [User routes](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/routes/userRoutes.js): `SERVER/routes/userRoutes.js`
- [User administration](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/controllers/userController.js): `SERVER/controllers/userController.js`
- [User records](https://github.com/mohammadwaseem6/expiry-traker/blob/main/SERVER/models/User.js): `SERVER/models/User.js`

### Other components

- **Store staff**
- **Gemini AI**

## Connections

- Store staff → App routing: opens app
- App routing → Login and register: routes to
- App routing → Dashboard: routes to
- App routing → Stock management: routes to
- App routing → Reports and charts: routes to
- App routing → Chart views: routes to
- App routing → Expired items: routes to
- App routing → Settings: routes to
- Store staff → Login and register: submits credentials
- Login and register → Auth context: sets session
- Login and register → API client: requests auth
- Dashboard → API client: loads inventory
- Stock management → API client: manages items
- Reports and charts → API client: requests data
- Chart views → API client: requests data
- Expired items → API client: requests items
- API client → Express entry: sends API requests
- Express entry → Auth routes: mounts routes
- Express entry → Item routes: mounts routes
- Express entry → User routes: mounts routes
- Express entry → File extraction: mounts routes
- Express entry → Image extraction: mounts routes
- Express entry → MongoDB connection: connects
- Auth routes → Auth controller: dispatches
- Auth controller → User records: reads and writes
- Item routes → JWT middleware: protects routes
- Item routes → Item operations: dispatches
- Item operations → Inventory records: reads and writes
- User routes → JWT middleware: protects routes
- User routes → User administration: dispatches
- User administration → User records: reads and writes
- File extraction → JWT middleware: authenticates
- Image extraction → JWT middleware: authenticates
- Image extraction → Gemini AI: sends image prompt
- AI assistant → API client: uses assistant
