# nxd010/shelfies architecture

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

- Interactive diagram: https://gitdiagram.com/nxd010/shelfies
- Repository: https://github.com/nxd010/shelfies

## Overview

Shelfies is a React and Flask inventory-management product: users scan product images, review detection results and updated stock, then browse inventory and analytics. The frontend’s scan page sends images through its API client; the backend runs detection, updates product counts and scan history, and persists records. The dashboard and database views use the frontend product cache and API. The README documents webcam scanning and 294 product classes; the sampled scan page shows image upload, but not webcam capture. Backend routing and configuration details not present in excerpts are represented only where the README or SOURCE INDEX supports them.

Main entry points: [`backend/app.py`](https://github.com/nxd010/shelfies/blob/main/backend/app.py) (Flask API and workflows), [`frontend/src/utils/productDatabase.js`](https://github.com/nxd010/shelfies/blob/main/frontend/src/utils/productDatabase.js) (Product cache), [`frontend/src/App.jsx`](https://github.com/nxd010/shelfies/blob/main/frontend/src/App.jsx) (App navigation), [`frontend/src/pages/Dashboard.jsx`](https://github.com/nxd010/shelfies/blob/main/frontend/src/pages/Dashboard.jsx) (Inventory dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Inventory interface"]
  node_app["App navigation<br/>[App.jsx]"]
  node_scanpage["Product scanning<br/>[Scanning.jsx]"]
  node_dashboard["Inventory dashboard<br/>[Dashboard.jsx]"]
  node_chart["Category chart<br/>[CategoryChart.jsx]"]
  node_recent["Recent products<br/>[ProductList.jsx]"]
  node_databaseview["Inventory browser<br/>[Database.jsx]"]
  node_sidebar["Navigation sidebar<br/>[Sidebar.jsx]"]
end

subgraph group_clientdata["Client data"]
  node_productcache["Product cache<br/>[productDatabase.js]"]
  node_apiclient["API client<br/>[api.js]"]
end

subgraph group_backend["Detection and API"]
  node_flaskapi["Flask API and workflows<br/>[app.py]"]
  node_configuration["Backend configuration<br/>[config.py]"]
  node_classification["Class categorization<br/>[utils.py]"]
  node_detector["YOLOv8 detector<br/>[best.pt]"]
end

subgraph group_persistence["Inventory persistence"]
  node_productrecords["Product records<br/>[models.py]"]
  node_scanrecords["Scan history records<br/>[models.py]"]
  node_sqlite[("SQLite inventory store")]
end

node_user(("Inventory user"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_sidebar
node_app -->|"routes to"| node_scanpage
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_databaseview
node_scanpage -->|"submits image"| node_apiclient
node_scanpage -->|"refreshes"| node_productcache
node_dashboard -->|"loads stats"| node_apiclient
node_dashboard -->|"reads products"| node_productcache
node_dashboard -->|"renders"| node_chart
node_dashboard -->|"renders"| node_recent
node_chart -->|"subscribes to"| node_productcache
node_recent -->|"subscribes to"| node_productcache
node_databaseview -->|"reads products"| node_productcache
node_productcache -->|"fetches products"| node_apiclient
node_apiclient -->|"HTTP requests"| node_flaskapi
node_flaskapi -->|"loads settings"| node_configuration
node_flaskapi -->|"runs detection"| node_detector
node_flaskapi -->|"maps classes"| node_classification
node_flaskapi -->|"queries and updates"| node_productrecords
node_flaskapi -->|"records scans"| node_scanrecords
node_productrecords -->|"persists inventory"| node_sqlite
node_scanrecords -->|"persists history"| node_sqlite

click node_app "https://github.com/nxd010/shelfies/blob/main/frontend/src/App.jsx"
click node_scanpage "https://github.com/nxd010/shelfies/blob/main/frontend/src/pages/Scanning.jsx"
click node_dashboard "https://github.com/nxd010/shelfies/blob/main/frontend/src/pages/Dashboard.jsx"
click node_chart "https://github.com/nxd010/shelfies/blob/main/frontend/src/components/CategoryChart.jsx"
click node_recent "https://github.com/nxd010/shelfies/blob/main/frontend/src/components/ProductList.jsx"
click node_databaseview "https://github.com/nxd010/shelfies/blob/main/frontend/src/pages/Database.jsx"
click node_sidebar "https://github.com/nxd010/shelfies/blob/main/frontend/src/components/Sidebar.jsx"
click node_productcache "https://github.com/nxd010/shelfies/blob/main/frontend/src/utils/productDatabase.js"
click node_apiclient "https://github.com/nxd010/shelfies/blob/main/frontend/src/utils/api.js"
click node_flaskapi "https://github.com/nxd010/shelfies/blob/main/backend/app.py"
click node_configuration "https://github.com/nxd010/shelfies/blob/main/backend/config.py"
click node_classification "https://github.com/nxd010/shelfies/blob/main/backend/utils.py"
click node_detector "https://github.com/nxd010/shelfies/blob/main/backend/models/best.pt"
click node_productrecords "https://github.com/nxd010/shelfies/blob/main/backend/models.py"
click node_scanrecords "https://github.com/nxd010/shelfies/blob/main/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,node_scanpage,node_dashboard,node_chart,node_recent,node_databaseview,node_sidebar,node_user toneBlue
class node_productcache,node_apiclient toneAmber
class node_flaskapi,node_configuration,node_classification,node_detector toneMint
class node_productrecords,node_scanrecords,node_sqlite toneRose
```

## Components

### Inventory interface

- [App navigation](https://github.com/nxd010/shelfies/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Product scanning](https://github.com/nxd010/shelfies/blob/main/frontend/src/pages/Scanning.jsx): `frontend/src/pages/Scanning.jsx`
- [Inventory dashboard](https://github.com/nxd010/shelfies/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Category chart](https://github.com/nxd010/shelfies/blob/main/frontend/src/components/CategoryChart.jsx): `frontend/src/components/CategoryChart.jsx`
- [Recent products](https://github.com/nxd010/shelfies/blob/main/frontend/src/components/ProductList.jsx): `frontend/src/components/ProductList.jsx`
- [Inventory browser](https://github.com/nxd010/shelfies/blob/main/frontend/src/pages/Database.jsx): `frontend/src/pages/Database.jsx`
- [Navigation sidebar](https://github.com/nxd010/shelfies/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`

### Client data

- [Product cache](https://github.com/nxd010/shelfies/blob/main/frontend/src/utils/productDatabase.js): `frontend/src/utils/productDatabase.js`
- [API client](https://github.com/nxd010/shelfies/blob/main/frontend/src/utils/api.js): `frontend/src/utils/api.js`

### Detection and API

- [Flask API and workflows](https://github.com/nxd010/shelfies/blob/main/backend/app.py): `backend/app.py`
- [Backend configuration](https://github.com/nxd010/shelfies/blob/main/backend/config.py): `backend/config.py`
- [Class categorization](https://github.com/nxd010/shelfies/blob/main/backend/utils.py): `backend/utils.py`
- [YOLOv8 detector](https://github.com/nxd010/shelfies/blob/main/backend/models/best.pt): `backend/models/best.pt`

### Inventory persistence

- [Product records](https://github.com/nxd010/shelfies/blob/main/backend/models.py): `backend/models.py`
- [Scan history records](https://github.com/nxd010/shelfies/blob/main/backend/models.py): `backend/models.py`
- **SQLite inventory store**

### Other components

- **Inventory user**

## Connections

- Inventory user → App navigation: uses (evidence: `README.md`)
- App navigation → Navigation sidebar: renders (evidence: `frontend/src/App.jsx`)
- App navigation → Product scanning: routes to (evidence: `frontend/src/App.jsx`)
- App navigation → Inventory dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App navigation → Inventory browser: routes to (evidence: `frontend/src/App.jsx`)
- Product scanning → API client: submits image (evidence: `frontend/src/pages/Scanning.jsx`)
- Product scanning → Product cache: refreshes (evidence: `frontend/src/pages/Scanning.jsx`)
- Inventory dashboard → API client: loads stats (evidence: `frontend/src/pages/Dashboard.jsx`)
- Inventory dashboard → Product cache: reads products (evidence: `frontend/src/pages/Dashboard.jsx`)
- Inventory dashboard → Category chart: renders (evidence: `frontend/src/pages/Dashboard.jsx`)
- Inventory dashboard → Recent products: renders (evidence: `frontend/src/pages/Dashboard.jsx`)
- Category chart → Product cache: subscribes to (evidence: `frontend/src/components/CategoryChart.jsx`)
- Recent products → Product cache: subscribes to (evidence: `frontend/src/components/ProductList.jsx`)
- Inventory browser → Product cache: reads products (evidence: `frontend/src/pages/Database.jsx`)
- Product cache → API client: fetches products (evidence: `frontend/src/utils/productDatabase.js`)
- API client → Flask API and workflows: HTTP requests (evidence: `README.md`)
- Flask API and workflows → Backend configuration: loads settings (evidence: `backend/app.py`)
- Flask API and workflows → YOLOv8 detector: runs detection (evidence: `README.md`)
- Flask API and workflows → Class categorization: maps classes (evidence: `backend/app.py`)
- Flask API and workflows → Product records: queries and updates (evidence: `backend/app.py`)
- Flask API and workflows → Scan history records: records scans (evidence: `backend/app.py`)
- Product records → SQLite inventory store: persists inventory (evidence: `README.md`)
- Scan history records → SQLite inventory store: persists history (evidence: `README.md`)
