# devesh9461/ai-powered-smart-inventory architecture

> Architecture diagram of the GitHub repository devesh9461/ai-powered-smart-inventory, 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/devesh9461/ai-powered-smart-inventory
- Repository: https://github.com/devesh9461/ai-powered-smart-inventory

## Overview

This is a full-stack smart-inventory application: staff authenticate, manage catalog items and stock movements, then review stock health, alerts, and analytics. The React router exposes these workflows through page components and a JWT-aware API client; Flask routes enforce authentication and operate on SQLAlchemy domain records. Separate AI services provide forecasting, anomaly detection, and predictive insights. The README documents PostgreSQL/SQLite storage and the product capabilities. Some backend route-to-model links are supported by the source index rather than excerpts; analytics-page wiring is not asserted where source evidence is unavailable.

Main entry points: [`frontend/src/App.jsx`](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/App.jsx) (App routing), [`frontend/src/api/client.js`](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/api/client.js) (API client), [`backend/app/models/product.py`](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/product.py) (Product records), [`backend/app/models/transaction.py`](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/transaction.py) (Stock movements)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_router["App routing<br/>[App.jsx]"]
  node_login["Login page<br/>[Login.jsx]"]
  node_dashboard["Dashboard page<br/>[Dashboard.jsx]"]
  node_products_ui["Products page<br/>[Products.jsx]"]
  node_transactions_ui["Transactions page<br/>[Transactions.jsx]"]
  node_analytics_ui["Analytics page<br/>[Analytics.jsx]"]
  node_alerts_ui["Alerts page<br/>[Alerts.jsx]"]
  node_settings_ui["Settings page<br/>[Settings.jsx]"]
  node_auth_state["Auth context<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>[client.js]"]
end

subgraph group_api["API and identity"]
  node_auth_routes["Authentication API<br/>[auth.py]"]
  node_product_routes["Product API<br/>[products.py]"]
  node_transaction_routes["Transaction API<br/>[transactions.py]"]
  node_dashboard_routes["Dashboard API<br/>[dashboard.py]"]
  node_alert_routes["Alert API<br/>[alerts.py]"]
  node_ai_routes["AI API<br/>[ai.py]"]
  node_auth_helpers["JWT helpers<br/>[auth_helpers.py]"]
end

subgraph group_inventory["Inventory domain"]
  node_products[("Product records<br/>[product.py]")]
  node_transactions[("Stock movements<br/>[transaction.py]")]
  node_alerts[("Alert records<br/>[alert.py]")]
  node_categories[("Categories<br/>[category.py]")]
  node_users[("User records<br/>[user.py]")]
end

subgraph group_intelligence["AI intelligence"]
  node_forecasting["Demand forecasting<br/>[forecasting.py]"]
  node_anomaly["Anomaly detection<br/>[anomaly.py]"]
  node_insights["Predictive insights<br/>[insights.py]"]
end

node_staff(("Inventory staff"))
node_database[("SQL database")]

node_staff -->|"uses"| node_router
node_router -->|"routes to"| node_login
node_router -->|"routes to"| node_dashboard
node_router -->|"routes to"| node_products_ui
node_router -->|"routes to"| node_transactions_ui
node_router -->|"routes to"| node_analytics_ui
node_router -->|"routes to"| node_alerts_ui
node_router -->|"routes to"| node_settings_ui
node_login -->|"authenticates through"| node_auth_state
node_auth_state -->|"requests through"| node_api_client
node_products_ui -->|"requests through"| node_api_client
node_transactions_ui -->|"requests through"| node_api_client
node_dashboard -->|"requests through"| node_api_client
node_alerts_ui -->|"requests through"| node_api_client
node_settings_ui -->|"requests through"| node_api_client
node_api_client -.->|"calls API"| node_auth_routes
node_auth_routes -->|"uses"| node_auth_helpers
node_auth_helpers -->|"loads user"| node_users
node_auth_routes -->|"reads and updates"| node_users
node_product_routes -->|"manages"| node_products
node_product_routes -->|"reads"| node_categories
node_transaction_routes -->|"records"| node_transactions
node_transaction_routes -->|"updates stock"| node_products
node_transaction_routes -->|"creates alerts"| node_alerts
node_dashboard_routes -->|"aggregates"| node_products
node_dashboard_routes -->|"aggregates"| node_transactions
node_dashboard_routes -->|"aggregates"| node_categories
node_dashboard_routes -->|"aggregates"| node_alerts
node_alert_routes -->|"lists and updates"| node_alerts
node_ai_routes -->|"dispatches"| node_forecasting
node_ai_routes -->|"dispatches"| node_anomaly
node_ai_routes -->|"dispatches"| node_insights
node_forecasting -->|"reads history"| node_transactions
node_insights -->|"uses forecasts"| node_forecasting
node_insights -->|"reads stock"| node_products
node_insights -->|"reads history"| node_transactions
node_products -->|"persists in"| node_database
node_transactions -->|"persists in"| node_database
node_alerts -->|"persists in"| node_database
node_categories -->|"persists in"| node_database
node_users -->|"persists in"| node_database

click node_router "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/App.jsx"
click node_login "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Login.jsx"
click node_dashboard "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Dashboard.jsx"
click node_products_ui "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Products.jsx"
click node_transactions_ui "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Transactions.jsx"
click node_analytics_ui "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Analytics.jsx"
click node_alerts_ui "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Alerts.jsx"
click node_settings_ui "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Settings.jsx"
click node_auth_state "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/context/AuthContext.jsx"
click node_api_client "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/api/client.js"
click node_auth_routes "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/auth.py"
click node_product_routes "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/products.py"
click node_transaction_routes "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/transactions.py"
click node_dashboard_routes "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/dashboard.py"
click node_alert_routes "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/alerts.py"
click node_ai_routes "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/ai.py"
click node_auth_helpers "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/utils/auth_helpers.py"
click node_products "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/product.py"
click node_transactions "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/transaction.py"
click node_alerts "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/alert.py"
click node_categories "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/category.py"
click node_users "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/user.py"
click node_forecasting "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/services/forecasting.py"
click node_anomaly "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/services/anomaly.py"
click node_insights "https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/services/insights.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_router,node_login,node_dashboard,node_products_ui,node_transactions_ui,node_analytics_ui,node_alerts_ui,node_settings_ui,node_auth_state,node_api_client toneBlue
class node_auth_routes,node_product_routes,node_transaction_routes,node_dashboard_routes,node_alert_routes,node_ai_routes,node_auth_helpers,node_database toneAmber
class node_products,node_transactions,node_alerts,node_categories,node_users toneMint
class node_forecasting,node_anomaly,node_insights toneRose
class node_staff toneIndigo
```

## Components

### Web application

- [App routing](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login page](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Dashboard page](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Products page](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Products.jsx): `frontend/src/pages/Products.jsx`
- [Transactions page](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Transactions.jsx): `frontend/src/pages/Transactions.jsx`
- [Analytics page](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Analytics.jsx): `frontend/src/pages/Analytics.jsx`
- [Alerts page](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Alerts.jsx): `frontend/src/pages/Alerts.jsx`
- [Settings page](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/pages/Settings.jsx): `frontend/src/pages/Settings.jsx`
- [Auth context](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### API and identity

- [Authentication API](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/auth.py): `backend/app/routes/auth.py`
- [Product API](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/products.py): `backend/app/routes/products.py`
- [Transaction API](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/transactions.py): `backend/app/routes/transactions.py`
- [Dashboard API](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/dashboard.py): `backend/app/routes/dashboard.py`
- [Alert API](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/alerts.py): `backend/app/routes/alerts.py`
- [AI API](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/routes/ai.py): `backend/app/routes/ai.py`
- [JWT helpers](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/utils/auth_helpers.py): `backend/app/utils/auth_helpers.py`

### Inventory domain

- [Product records](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/product.py): `backend/app/models/product.py`
- [Stock movements](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/transaction.py): `backend/app/models/transaction.py`
- [Alert records](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/alert.py): `backend/app/models/alert.py`
- [Categories](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/category.py): `backend/app/models/category.py`
- [User records](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/models/user.py): `backend/app/models/user.py`

### AI intelligence

- [Demand forecasting](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/services/forecasting.py): `backend/app/services/forecasting.py`
- [Anomaly detection](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/services/anomaly.py): `backend/app/services/anomaly.py`
- [Predictive insights](https://github.com/devesh9461/ai-powered-smart-inventory/blob/main/backend/app/services/insights.py): `backend/app/services/insights.py`

### Other components

- **Inventory staff**
- **SQL database**

## Connections

- Inventory staff → App routing: uses (evidence: `frontend/src/App.jsx`)
- App routing → Login page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Dashboard page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Products page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Transactions page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Analytics page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Alerts page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Settings page: routes to (evidence: `frontend/src/App.jsx`)
- Login page → Auth context: authenticates through (evidence: `frontend/src/pages/Login.jsx`)
- Auth context → API client: requests through (evidence: `frontend/src/context/AuthContext.jsx`)
- Products page → API client: requests through (evidence: `frontend/src/pages/Products.jsx`)
- Transactions page → API client: requests through (evidence: `frontend/src/pages/Transactions.jsx`)
- Dashboard page → API client: requests through (evidence: `frontend/src/pages/Dashboard.jsx`)
- Alerts page → API client: requests through (evidence: `frontend/src/pages/Alerts.jsx`)
- Settings page → API client: requests through (evidence: `frontend/src/pages/Settings.jsx`)
- API client → Authentication API: calls API
- Authentication API → JWT helpers: uses (evidence: `backend/app/routes/auth.py`)
- JWT helpers → User records: loads user (evidence: `backend/app/utils/auth_helpers.py`)
- Authentication API → User records: reads and updates (evidence: `backend/app/routes/auth.py`)
- Product API → Product records: manages (evidence: `backend/app/routes/products.py`)
- Product API → Categories: reads (evidence: `backend/app/routes/products.py`)
- Transaction API → Stock movements: records (evidence: `backend/app/routes/transactions.py`)
- Transaction API → Product records: updates stock (evidence: `backend/app/routes/transactions.py`)
- Transaction API → Alert records: creates alerts (evidence: `backend/app/routes/transactions.py`)
- Dashboard API → Product records: aggregates (evidence: `backend/app/routes/dashboard.py`)
- Dashboard API → Stock movements: aggregates (evidence: `backend/app/routes/dashboard.py`)
- Dashboard API → Categories: aggregates (evidence: `backend/app/routes/dashboard.py`)
- Dashboard API → Alert records: aggregates (evidence: `backend/app/routes/dashboard.py`)
- Alert API → Alert records: lists and updates (evidence: `backend/app/routes/alerts.py`)
- AI API → Demand forecasting: dispatches (evidence: `backend/app/routes/ai.py`)
- AI API → Anomaly detection: dispatches (evidence: `backend/app/routes/ai.py`)
- AI API → Predictive insights: dispatches (evidence: `backend/app/routes/ai.py`)
- Demand forecasting → Stock movements: reads history (evidence: `backend/app/services/forecasting.py`)
- Predictive insights → Demand forecasting: uses forecasts (evidence: `backend/app/services/insights.py`)
- Predictive insights → Product records: reads stock (evidence: `backend/app/services/insights.py`)
- Predictive insights → Stock movements: reads history (evidence: `backend/app/services/insights.py`)
- Product records → SQL database: persists in (evidence: `backend/app/models/product.py`)
- Stock movements → SQL database: persists in (evidence: `backend/app/models/transaction.py`)
- Alert records → SQL database: persists in (evidence: `backend/app/models/alert.py`)
- Categories → SQL database: persists in (evidence: `backend/app/models/category.py`)
- User records → SQL database: persists in (evidence: `backend/app/models/user.py`)
