# liamstainton21/pantry-loop architecture

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

- Interactive diagram: https://gitdiagram.com/liamstainton21/pantry-loop
- Repository: https://github.com/liamstainton21/pantry-loop

## Overview

Pantry Loop is an offline-first grocery tracker: a person scans or manually enters a product, identifies it locally or through optional online lookup, records a purchase or depletion, and reviews inventory and a persistent shopping list. The app stores its authoritative data in browser IndexedDB and also supports catalogue editing, backups, restore, and spreadsheet snapshots. The graph follows the sampled runtime modules and documented capabilities; some integration details are documented in the README rather than shown in the sampled source.

Main entry points: [`src/main.js`](https://github.com/liamstainton21/pantry-loop/blob/main/src/main.js) (App router), [`src/lookup.js`](https://github.com/liamstainton21/pantry-loop/blob/main/src/lookup.js) (Product lookup), [`src/db.js`](https://github.com/liamstainton21/pantry-loop/blob/main/src/db.js) (IndexedDB data), [`src/identification.js`](https://github.com/liamstainton21/pantry-loop/blob/main/src/identification.js) (Product identification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture &amp; identification"]
  node_scanner["Camera scanner<br/>[scanner.js]"]
  node_barcode["Barcode rules<br/>[barcode.js]"]
  node_identification["Product identification<br/>[identification.js]"]
  node_lookup["Product lookup<br/>[lookup.js]"]
  node_confirmation["Scan confirmation<br/>[confirmation.js]"]
end

subgraph group_shopping["Inventory &amp; shopping"]
  node_inventory["Stock replay<br/>[inventory.js]"]
  node_listlogic["List generation<br/>[list.js]"]
end

subgraph group_persistence["Local data &amp; export"]
  node_database[("IndexedDB data<br/>[db.js]")]
  node_export["Backup &amp; export<br/>[export.js]"]
end

subgraph group_app["App interface"]
  node_app["App router<br/>[main.js]"]
  node_scanview["Scan screen<br/>[scan.js]"]
  node_catalogueview["Catalogue screen<br/>[catalogue.js]"]
  node_listview["List screen<br/>[list.js]"]
  node_settingsview["Settings screen<br/>[settings.js]"]
  node_ui["UI helpers<br/>[ui.js]"]
end

node_person(("Shopper"))
node_tesco{{"Tesco proxy"}}
node_off{{"Open Food Facts"}}
node_vision{{"Vision proxy"}}

node_person -->|"uses"| node_scanview
node_person -->|"manages products"| node_catalogueview
node_person -->|"shops from"| node_listview
node_person -->|"configures"| node_settingsview
node_scanview -->|"starts camera"| node_scanner
node_scanview -->|"normalizes codes"| node_barcode
node_scanner -->|"maps formats"| node_barcode
node_app -->|"routes to"| node_scanview
node_app -->|"routes to"| node_listview
node_app -->|"routes to"| node_catalogueview
node_app -->|"routes to"| node_settingsview
node_app -->|"identifies codes"| node_lookup
node_app -->|"requests fallback"| node_identification
node_app -->|"confirms scans"| node_confirmation
node_app -->|"records events"| node_database
node_app -->|"processes queue"| node_lookup
node_identification -->|"checks barcode"| node_lookup
node_identification -->|"scans barcode"| node_scanner
node_lookup -->|"checks eligibility"| node_barcode
node_lookup -->|"reads and updates"| node_database
node_lookup -.->|"queries proxy"| node_tesco
node_lookup -.->|"queries fallback"| node_off
node_identification -.->|"sends chosen photo"| node_vision
node_catalogueview -->|"reads and edits"| node_database
node_listview -->|"generates suggestions"| node_listlogic
node_listview -->|"loads and saves draft"| node_database
node_listlogic -->|"uses stock history"| node_inventory
node_database -->|"replays stock"| node_inventory
node_settingsview -->|"saves settings"| node_database
node_settingsview -->|"offers backups"| node_export
node_export -->|"reads and restores"| node_database

click node_app "https://github.com/liamstainton21/pantry-loop/blob/main/src/main.js"
click node_scanview "https://github.com/liamstainton21/pantry-loop/blob/main/src/views/scan.js"
click node_catalogueview "https://github.com/liamstainton21/pantry-loop/blob/main/src/views/catalogue.js"
click node_listview "https://github.com/liamstainton21/pantry-loop/blob/main/src/views/list.js"
click node_settingsview "https://github.com/liamstainton21/pantry-loop/blob/main/src/views/settings.js"
click node_ui "https://github.com/liamstainton21/pantry-loop/blob/main/src/ui.js"
click node_scanner "https://github.com/liamstainton21/pantry-loop/blob/main/src/scanner.js"
click node_barcode "https://github.com/liamstainton21/pantry-loop/blob/main/src/barcode.js"
click node_identification "https://github.com/liamstainton21/pantry-loop/blob/main/src/identification.js"
click node_lookup "https://github.com/liamstainton21/pantry-loop/blob/main/src/lookup.js"
click node_confirmation "https://github.com/liamstainton21/pantry-loop/blob/main/src/confirmation.js"
click node_inventory "https://github.com/liamstainton21/pantry-loop/blob/main/src/inventory.js"
click node_listlogic "https://github.com/liamstainton21/pantry-loop/blob/main/src/list.js"
click node_database "https://github.com/liamstainton21/pantry-loop/blob/main/src/db.js"
click node_export "https://github.com/liamstainton21/pantry-loop/blob/main/src/export.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_scanner,node_barcode,node_identification,node_lookup,node_confirmation toneBlue
class node_inventory,node_listlogic toneAmber
class node_database,node_export toneMint
class node_app,node_scanview,node_catalogueview,node_listview,node_settingsview,node_ui toneRose
class node_person,node_tesco,node_off,node_vision toneIndigo
```

## Components

### Capture & identification

- [Camera scanner](https://github.com/liamstainton21/pantry-loop/blob/main/src/scanner.js): `src/scanner.js`
- [Barcode rules](https://github.com/liamstainton21/pantry-loop/blob/main/src/barcode.js): `src/barcode.js`
- [Product identification](https://github.com/liamstainton21/pantry-loop/blob/main/src/identification.js): `src/identification.js`
- [Product lookup](https://github.com/liamstainton21/pantry-loop/blob/main/src/lookup.js): `src/lookup.js`
- [Scan confirmation](https://github.com/liamstainton21/pantry-loop/blob/main/src/confirmation.js): `src/confirmation.js`

### Inventory & shopping

- [Stock replay](https://github.com/liamstainton21/pantry-loop/blob/main/src/inventory.js): `src/inventory.js`
- [List generation](https://github.com/liamstainton21/pantry-loop/blob/main/src/list.js): `src/list.js`

### Local data & export

- [IndexedDB data](https://github.com/liamstainton21/pantry-loop/blob/main/src/db.js): `src/db.js`
- [Backup & export](https://github.com/liamstainton21/pantry-loop/blob/main/src/export.js): `src/export.js`

### App interface

- [App router](https://github.com/liamstainton21/pantry-loop/blob/main/src/main.js): `src/main.js`
- [Scan screen](https://github.com/liamstainton21/pantry-loop/blob/main/src/views/scan.js): `src/views/scan.js`
- [Catalogue screen](https://github.com/liamstainton21/pantry-loop/blob/main/src/views/catalogue.js): `src/views/catalogue.js`
- [List screen](https://github.com/liamstainton21/pantry-loop/blob/main/src/views/list.js): `src/views/list.js`
- [Settings screen](https://github.com/liamstainton21/pantry-loop/blob/main/src/views/settings.js): `src/views/settings.js`
- [UI helpers](https://github.com/liamstainton21/pantry-loop/blob/main/src/ui.js): `src/ui.js`

### Other components

- **Shopper**
- **Tesco proxy**
- **Open Food Facts**
- **Vision proxy**

## Connections

- Shopper → Scan screen: uses (evidence: `README.md`)
- Shopper → Catalogue screen: manages products (evidence: `README.md`)
- Shopper → List screen: shops from (evidence: `README.md`)
- Shopper → Settings screen: configures (evidence: `README.md`)
- Scan screen → Camera scanner: starts camera (evidence: `src/views/scan.js`)
- Scan screen → Barcode rules: normalizes codes (evidence: `src/views/scan.js`)
- Camera scanner → Barcode rules: maps formats (evidence: `src/scanner.js`)
- App router → Scan screen: routes to (evidence: `src/main.js`)
- App router → List screen: routes to (evidence: `src/main.js`)
- App router → Catalogue screen: routes to (evidence: `src/main.js`)
- App router → Settings screen: routes to (evidence: `src/main.js`)
- App router → Product lookup: identifies codes (evidence: `src/main.js`)
- App router → Product identification: requests fallback (evidence: `src/main.js`)
- App router → Scan confirmation: confirms scans (evidence: `src/main.js`)
- App router → IndexedDB data: records events (evidence: `src/main.js`)
- App router → Product lookup: processes queue (evidence: `src/main.js`)
- Product identification → Product lookup: checks barcode (evidence: `src/identification.js`)
- Product identification → Camera scanner: scans barcode (evidence: `src/identification.js`)
- Product lookup → Barcode rules: checks eligibility (evidence: `src/lookup.js`)
- Product lookup → IndexedDB data: reads and updates (evidence: `src/lookup.js`)
- Product lookup → Tesco proxy: queries proxy (evidence: `README.md`)
- Product lookup → Open Food Facts: queries fallback (evidence: `README.md`)
- Product identification → Vision proxy: sends chosen photo (evidence: `README.md`)
- Catalogue screen → IndexedDB data: reads and edits (evidence: `src/views/catalogue.js`)
- List screen → List generation: generates suggestions (evidence: `src/views/list.js`)
- List screen → IndexedDB data: loads and saves draft (evidence: `src/views/list.js`)
- List generation → Stock replay: uses stock history (evidence: `src/list.js`)
- IndexedDB data → Stock replay: replays stock (evidence: `src/db.js`)
- Settings screen → IndexedDB data: saves settings (evidence: `src/views/settings.js`)
- Settings screen → Backup & export: offers backups (evidence: `src/views/settings.js`)
- Backup & export → IndexedDB data: reads and restores (evidence: `src/export.js`)
