# sunnel987/bill-snap architecture

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

- Interactive diagram: https://gitdiagram.com/sunnel987/bill-snap
- Repository: https://github.com/sunnel987/bill-snap

## Overview

Bill Snap is an installable receipt-scanning PWA. A user captures or selects an image, sends it for Gemini bill classification and field extraction, reviews and edits the result, then saves it locally; the history view supports review and deletion. A separate PWA branch provides installation and offline app-shell caching. The provided tree has no API implementation file, so the documented extraction endpoint is shown without an invented source path; endpoint internals are limited to README evidence.

Main entry points: [`src/App.tsx`](https://github.com/sunnel987/bill-snap/blob/main/src/App.tsx) (Image capture and upload), [`src/main.tsx`](https://github.com/sunnel987/bill-snap/blob/main/src/main.tsx) (React app entry), [`public/sw.js`](https://github.com/sunnel987/bill-snap/blob/main/public/sw.js) (Offline service worker), [`src/db.ts`](https://github.com/sunnel987/bill-snap/blob/main/src/db.ts) (IndexedDB bill store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_scan["Capture and extraction"]
  node_app["React app entry<br/>[main.tsx]"]
  node_capture["Image capture and upload<br/>[App.tsx]"]
  node_extract["Bill extraction endpoint"]
end

subgraph group_review["Review and records"]
  node_review["Editable result review<br/>[App.tsx]"]
  node_history["Bill history and deletion<br/>[App.tsx]"]
  node_store[("IndexedDB bill store<br/>[db.ts]")]
end

subgraph group_pwa["PWA shell"]
  node_manifest["PWA manifest"]
  node_worker["Offline service worker<br/>[sw.js]"]
end

node_user(("User"))
node_gemini["Gemini Vision"]
node_browser["Web browser"]

node_user -->|"selects image"| node_capture
node_app -->|"renders"| node_capture
node_capture -->|"submits image"| node_extract
node_extract -->|"requests extraction"| node_gemini
node_extract -->|"returns fields"| node_review
node_user -->|"edits fields"| node_review
node_review -->|"saves bill"| node_store
node_user -->|"reviews or deletes"| node_history
node_history -->|"loads and deletes"| node_store
node_app -->|"registers"| node_worker
node_worker -->|"caches app shell"| node_browser
node_browser -.->|"offers installation"| node_manifest

click node_app "https://github.com/sunnel987/bill-snap/blob/main/src/main.tsx"
click node_capture "https://github.com/sunnel987/bill-snap/blob/main/src/App.tsx"
click node_review "https://github.com/sunnel987/bill-snap/blob/main/src/App.tsx"
click node_history "https://github.com/sunnel987/bill-snap/blob/main/src/App.tsx"
click node_store "https://github.com/sunnel987/bill-snap/blob/main/src/db.ts"
click node_manifest "https://github.com/sunnel987/bill-snap/blob/main/public/manifest.webmanifest"
click node_worker "https://github.com/sunnel987/bill-snap/blob/main/public/sw.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_capture,node_extract,node_user,node_browser toneBlue
class node_review,node_history,node_store toneAmber
class node_manifest,node_worker toneMint
class node_gemini toneIndigo
```

## Components

### Capture and extraction

- [React app entry](https://github.com/sunnel987/bill-snap/blob/main/src/main.tsx): `src/main.tsx`
- [Image capture and upload](https://github.com/sunnel987/bill-snap/blob/main/src/App.tsx): `src/App.tsx`
- **Bill extraction endpoint**

### Review and records

- [Editable result review](https://github.com/sunnel987/bill-snap/blob/main/src/App.tsx): `src/App.tsx`
- [Bill history and deletion](https://github.com/sunnel987/bill-snap/blob/main/src/App.tsx): `src/App.tsx`
- [IndexedDB bill store](https://github.com/sunnel987/bill-snap/blob/main/src/db.ts): `src/db.ts`

### PWA shell

- [PWA manifest](https://github.com/sunnel987/bill-snap/blob/main/public/manifest.webmanifest): `public/manifest.webmanifest`
- [Offline service worker](https://github.com/sunnel987/bill-snap/blob/main/public/sw.js): `public/sw.js`

### Other components

- **User**
- **Gemini Vision**
- **Web browser**

## Connections

- User → Image capture and upload: selects image (evidence: `README.md`)
- React app entry → Image capture and upload: renders (evidence: `src/main.tsx`)
- Image capture and upload → Bill extraction endpoint: submits image (evidence: `README.md`)
- Bill extraction endpoint → Gemini Vision: requests extraction (evidence: `README.md`)
- Bill extraction endpoint → Editable result review: returns fields (evidence: `README.md`)
- User → Editable result review: edits fields (evidence: `README.md`)
- Editable result review → IndexedDB bill store: saves bill (evidence: `src/App.tsx`)
- User → Bill history and deletion: reviews or deletes (evidence: `README.md`)
- Bill history and deletion → IndexedDB bill store: loads and deletes (evidence: `src/App.tsx`)
- React app entry → Offline service worker: registers (evidence: `src/main.tsx`)
- Offline service worker → Web browser: caches app shell (evidence: `public/sw.js`)
- Web browser → PWA manifest: offers installation (evidence: `README.md`)
