# shubh321h/storeflow architecture

> Architecture diagram of the GitHub repository shubh321h/storeflow, 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/shubh321h/storeflow
- Repository: https://github.com/shubh321h/storeflow

## Overview

StoreFlow is a mobile operations app for small retailers. A principal workflow is selecting products and a customer, creating and completing a bill, recording the sale, and presenting an invoice; product and inventory management, purchasing, and business records are supporting workflows. The graph includes documented feature areas whose screens were not sampled. Some links rely on the README or SOURCE INDEX; unsampled implementations are not asserted beyond those references.

Main entry points: [`lib/database.ts`](https://github.com/shubh321h/storeflow/blob/main/lib/database.ts) (Data access), [`screens/ProductsScreen.tsx`](https://github.com/shubh321h/storeflow/blob/main/screens/ProductsScreen.tsx) (Product management), [`screens/BillingScreen.tsx`](https://github.com/shubh321h/storeflow/blob/main/screens/BillingScreen.tsx) (Billing & sale), [`App.tsx`](https://github.com/shubh321h/storeflow/blob/main/App.tsx) (App navigation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access &amp; setup"]
  node_app["App navigation<br/>[App.tsx]"]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
  node_login["Login &amp; registration<br/>[LoginScreen.tsx]"]
  node_setup["Business setup"]
  node_businessctx["Active business context"]
end

subgraph group_catalog["Catalog &amp; stock"]
  node_products["Product management<br/>[ProductsScreen.tsx]"]
  node_scanner["Barcode scanning"]
  node_metadata["Product metadata lookup<br/>[openFoodFacts.ts]"]
  node_barcode["Barcode metadata<br/>[barcodeMetadata.ts]"]
  node_inventory["Inventory &amp; movements<br/>[database.ts]"]
end

subgraph group_commerce["Sales &amp; purchasing"]
  node_billing["Billing &amp; sale<br/>[BillingScreen.tsx]"]
  node_invoice["Invoice preview &amp; sharing<br/>[InvoicePreview.tsx]"]
  node_sales["Sales history"]
  node_purchases["Purchases<br/>[PurchaseScreen.tsx]"]
end

subgraph group_records["Business records"]
  node_customers["Customer accounts"]
  node_suppliers["Supplier accounts"]
  node_expenses["Expenses<br/>[ExpensesScreen.tsx]"]
  node_reports["Reports<br/>[ReportsScreen.tsx]"]
  node_settings["Business settings"]
end

subgraph group_foundation["Shared foundation"]
  node_database["Data access<br/>[database.ts]"]
  node_supabase[("Supabase backend<br/>[supabase.ts]")]
  node_ui["Shared UI components"]
end

node_shopkeeper(("Shopkeeper"))

node_shopkeeper -->|"uses"| node_app
node_app -->|"provides"| node_auth
node_app -->|"provides"| node_businessctx
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_setup
node_auth -->|"authenticates via"| node_supabase
node_businessctx -->|"loads businesses"| node_database
node_products -->|"reads and writes"| node_database
node_products -->|"looks up products"| node_metadata
node_products -->|"uses metadata"| node_barcode
node_scanner -->|"finds or adds products"| node_products
node_scanner -.->|"looks up information"| node_metadata
node_scanner -.->|"uses barcode support"| node_barcode
node_products -->|"updates stock"| node_inventory
node_billing -->|"searches products"| node_database
node_billing -->|"previews invoice"| node_invoice
node_billing -->|"updates sale records"| node_inventory
node_billing -->|"records sale"| node_sales
node_sales -->|"previews invoice"| node_invoice
node_purchases -->|"records purchases"| node_database
node_purchases -->|"updates stock"| node_inventory
node_customers -->|"manages accounts"| node_database
node_suppliers -->|"manages accounts"| node_database
node_expenses -->|"records expenses"| node_database
node_reports -->|"queries summaries"| node_database
node_settings -.->|"manages settings"| node_database
node_database -->|"queries backend"| node_supabase
node_products -->|"renders"| node_ui
node_billing -->|"renders"| node_ui

click node_app "https://github.com/shubh321h/storeflow/blob/main/App.tsx"
click node_auth "https://github.com/shubh321h/storeflow/blob/main/context/AuthContext.tsx"
click node_login "https://github.com/shubh321h/storeflow/blob/main/screens/LoginScreen.tsx"
click node_setup "https://github.com/shubh321h/storeflow/blob/main/screens/BusinessSetupScreen.tsx"
click node_businessctx "https://github.com/shubh321h/storeflow/blob/main/context/BusinessContext.tsx"
click node_products "https://github.com/shubh321h/storeflow/blob/main/screens/ProductsScreen.tsx"
click node_scanner "https://github.com/shubh321h/storeflow/blob/main/screens/BarcodeScannerScreen.tsx"
click node_metadata "https://github.com/shubh321h/storeflow/blob/main/lib/openFoodFacts.ts"
click node_barcode "https://github.com/shubh321h/storeflow/blob/main/lib/barcodeMetadata.ts"
click node_inventory "https://github.com/shubh321h/storeflow/blob/main/lib/database.ts"
click node_billing "https://github.com/shubh321h/storeflow/blob/main/screens/BillingScreen.tsx"
click node_invoice "https://github.com/shubh321h/storeflow/blob/main/components/InvoicePreview.tsx"
click node_sales "https://github.com/shubh321h/storeflow/blob/main/screens/SalesHistoryScreen.tsx"
click node_purchases "https://github.com/shubh321h/storeflow/blob/main/screens/PurchaseScreen.tsx"
click node_customers "https://github.com/shubh321h/storeflow/blob/main/screens/CustomersScreen.tsx"
click node_suppliers "https://github.com/shubh321h/storeflow/blob/main/screens/SuppliersScreen.tsx"
click node_expenses "https://github.com/shubh321h/storeflow/blob/main/screens/ExpensesScreen.tsx"
click node_reports "https://github.com/shubh321h/storeflow/blob/main/screens/ReportsScreen.tsx"
click node_settings "https://github.com/shubh321h/storeflow/blob/main/screens/BusinessSettingsScreen.tsx"
click node_database "https://github.com/shubh321h/storeflow/blob/main/lib/database.ts"
click node_supabase "https://github.com/shubh321h/storeflow/blob/main/lib/supabase.ts"
click node_ui "https://github.com/shubh321h/storeflow/tree/main/components"

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_auth,node_login,node_setup,node_businessctx toneBlue
class node_products,node_scanner,node_metadata,node_barcode,node_inventory toneAmber
class node_billing,node_invoice,node_sales,node_purchases toneMint
class node_customers,node_suppliers,node_expenses,node_reports,node_settings toneRose
class node_database,node_supabase,node_ui,node_shopkeeper toneIndigo
```

## Components

### Access & setup

- [App navigation](https://github.com/shubh321h/storeflow/blob/main/App.tsx): `App.tsx`
- [Authentication](https://github.com/shubh321h/storeflow/blob/main/context/AuthContext.tsx): `context/AuthContext.tsx`
- [Login & registration](https://github.com/shubh321h/storeflow/blob/main/screens/LoginScreen.tsx): `screens/LoginScreen.tsx`
- [Business setup](https://github.com/shubh321h/storeflow/blob/main/screens/BusinessSetupScreen.tsx): `screens/BusinessSetupScreen.tsx`
- [Active business context](https://github.com/shubh321h/storeflow/blob/main/context/BusinessContext.tsx): `context/BusinessContext.tsx`

### Catalog & stock

- [Product management](https://github.com/shubh321h/storeflow/blob/main/screens/ProductsScreen.tsx): `screens/ProductsScreen.tsx`
- [Barcode scanning](https://github.com/shubh321h/storeflow/blob/main/screens/BarcodeScannerScreen.tsx): `screens/BarcodeScannerScreen.tsx`
- [Product metadata lookup](https://github.com/shubh321h/storeflow/blob/main/lib/openFoodFacts.ts): `lib/openFoodFacts.ts`
- [Barcode metadata](https://github.com/shubh321h/storeflow/blob/main/lib/barcodeMetadata.ts): `lib/barcodeMetadata.ts`
- [Inventory & movements](https://github.com/shubh321h/storeflow/blob/main/lib/database.ts): `lib/database.ts`

### Sales & purchasing

- [Billing & sale](https://github.com/shubh321h/storeflow/blob/main/screens/BillingScreen.tsx): `screens/BillingScreen.tsx`
- [Invoice preview & sharing](https://github.com/shubh321h/storeflow/blob/main/components/InvoicePreview.tsx): `components/InvoicePreview.tsx`
- [Sales history](https://github.com/shubh321h/storeflow/blob/main/screens/SalesHistoryScreen.tsx): `screens/SalesHistoryScreen.tsx`
- [Purchases](https://github.com/shubh321h/storeflow/blob/main/screens/PurchaseScreen.tsx): `screens/PurchaseScreen.tsx`

### Business records

- [Customer accounts](https://github.com/shubh321h/storeflow/blob/main/screens/CustomersScreen.tsx): `screens/CustomersScreen.tsx`
- [Supplier accounts](https://github.com/shubh321h/storeflow/blob/main/screens/SuppliersScreen.tsx): `screens/SuppliersScreen.tsx`
- [Expenses](https://github.com/shubh321h/storeflow/blob/main/screens/ExpensesScreen.tsx): `screens/ExpensesScreen.tsx`
- [Reports](https://github.com/shubh321h/storeflow/blob/main/screens/ReportsScreen.tsx): `screens/ReportsScreen.tsx`
- [Business settings](https://github.com/shubh321h/storeflow/blob/main/screens/BusinessSettingsScreen.tsx): `screens/BusinessSettingsScreen.tsx`

### Shared foundation

- [Data access](https://github.com/shubh321h/storeflow/blob/main/lib/database.ts): `lib/database.ts`
- [Supabase backend](https://github.com/shubh321h/storeflow/blob/main/lib/supabase.ts): `lib/supabase.ts`
- [Shared UI components](https://github.com/shubh321h/storeflow/tree/main/components): `components`

### Other components

- **Shopkeeper**

## Connections

- Shopkeeper → App navigation: uses (evidence: `README.md`)
- App navigation → Authentication: provides (evidence: `App.tsx`)
- App navigation → Active business context: provides (evidence: `App.tsx`)
- App navigation → Login & registration: routes to (evidence: `App.tsx`)
- App navigation → Business setup: routes to (evidence: `App.tsx`)
- Authentication → Supabase backend: authenticates via (evidence: `context/AuthContext.tsx`)
- Active business context → Data access: loads businesses (evidence: `context/BusinessContext.tsx`)
- Product management → Data access: reads and writes (evidence: `screens/ProductsScreen.tsx`)
- Product management → Product metadata lookup: looks up products (evidence: `screens/ProductsScreen.tsx`)
- Product management → Barcode metadata: uses metadata (evidence: `screens/ProductsScreen.tsx`)
- Barcode scanning → Product management: finds or adds products (evidence: `README.md`)
- Barcode scanning → Product metadata lookup: looks up information (evidence: `README.md`)
- Barcode scanning → Barcode metadata: uses barcode support (evidence: `README.md`)
- Product management → Inventory & movements: updates stock (evidence: `README.md`)
- Billing & sale → Data access: searches products (evidence: `screens/BillingScreen.tsx`)
- Billing & sale → Invoice preview & sharing: previews invoice (evidence: `screens/BillingScreen.tsx`)
- Billing & sale → Inventory & movements: updates sale records (evidence: `README.md`)
- Billing & sale → Sales history: records sale (evidence: `README.md`)
- Sales history → Invoice preview & sharing: previews invoice (evidence: `screens/SalesHistoryScreen.tsx`)
- Purchases → Data access: records purchases (evidence: `screens/PurchaseScreen.tsx`)
- Purchases → Inventory & movements: updates stock (evidence: `README.md`)
- Customer accounts → Data access: manages accounts (evidence: `README.md`)
- Supplier accounts → Data access: manages accounts (evidence: `README.md`)
- Expenses → Data access: records expenses (evidence: `screens/ExpensesScreen.tsx`)
- Reports → Data access: queries summaries (evidence: `screens/ReportsScreen.tsx`)
- Business settings → Data access: manages settings (evidence: `README.md`)
- Data access → Supabase backend: queries backend (evidence: `lib/database.ts`)
- Product management → Shared UI components: renders (evidence: `screens/ProductsScreen.tsx`)
- Billing & sale → Shared UI components: renders (evidence: `screens/BillingScreen.tsx`)
