# ownertest-byte/kuventory architecture

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

## Overview

KUVENTORY is a browser-based, real-time restaurant inventory system backed by Supabase. Users sign in, enter a protected application shell, and manage stock, daily counts, reports, notifications, and settings. Inventory operations cover catalog items and stock mutations; daily inventory provides a separate date-based count and finalization workflow; reporting and administration form additional product branches. Shared authentication and Supabase access support these workflows. The README documents PostgreSQL, Auth, RLS, and Edge Functions; sampled source confirms client-side Supabase access, but does not establish every integration or data relationship.

Main entry points: [`src/app/App.tsx`](https://github.com/ownertest-byte/kuventory/blob/master/src/app/App.tsx) (Route coordinator), [`src/features/inventory/api/index.ts`](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/api/index.ts) (Inventory data operations), [`src/features/reports/pages/ReportsLibraryPage.tsx`](https://github.com/ownertest-byte/kuventory/blob/master/src/features/reports/pages/ReportsLibraryPage.tsx) (Reports library), [`src/features/auth/context/AuthContext.tsx`](https://github.com/ownertest-byte/kuventory/blob/master/src/features/auth/context/AuthContext.tsx) (Authentication context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and shell"]
  node_app["Route coordinator<br/>[App.tsx]"]
  node_auth["Authentication context<br/>[AuthContext.tsx]"]
  node_login["Login experience<br/>[LoginPage.tsx]"]
  node_guard["Protected-route guard<br/>[RequireAuth.tsx]"]
  node_shell["Application shell<br/>[AppLayout.tsx]"]
  node_command["Command palette<br/>[CommandPalette.tsx]"]
end

subgraph group_stock["Inventory operations"]
  node_catalog["Item catalog"]
  node_itemdetails["Item details"]
  node_inventoryhome["Inventory overview"]
  node_inventoryapi["Inventory data operations<br/>[index.ts]"]
  node_itemform["Item editor<br/>[ItemFormModal.tsx]"]
  node_mutations["Stock mutations"]
  node_batches["Stock batches"]
  node_history["Stock history"]
end

subgraph group_counting["Daily counting"]
  node_daily["Daily inventory screen"]
  node_dailyhook["Daily inventory state"]
  node_dailyapi["Daily count operations<br/>[index.ts]"]
end

subgraph group_insight["Reports and alerts"]
  node_reports["Reports library"]
  node_reportview["Report detail<br/>[ReportViewPage.tsx]"]
  node_reportapi["Report data operations<br/>[reports.ts]"]
  node_exports["Report exports"]
  node_notifications["Notification center"]
end

subgraph group_platform["Shared platform"]
  node_admin["Settings and administration<br/>[AdminPage.tsx]"]
  node_categories["Category management<br/>[CategoriesPage.tsx]"]
  node_suppliers["Supplier directory"]
  node_realtime["Realtime synchronization<br/>[useRealtimeSync.ts]"]
  node_keepalive["Database keepalive<br/>[keepalive.ts]"]
  node_client["Supabase client<br/>[supabase.ts]"]
end

node_user(("Restaurant user"))
node_supabase[("Supabase platform")]

node_user -->|"uses"| node_app
node_app -->|"provides auth"| node_auth
node_app -->|"routes to"| node_login
node_app -->|"protects routes"| node_guard
node_app -->|"mounts shell"| node_shell
node_app -->|"routes to"| node_daily
node_app -->|"routes to"| node_catalog
node_app -->|"routes to"| node_itemdetails
node_app -->|"routes to"| node_inventoryhome
node_app -->|"routes to"| node_reports
node_app -->|"routes to"| node_reportview
node_app -->|"routes to"| node_notifications
node_app -->|"routes to"| node_admin
node_app -->|"starts sync"| node_realtime
node_app -->|"starts heartbeat"| node_keepalive
node_auth -->|"uses"| node_client
node_auth -->|"auth and profile queries"| node_supabase
node_shell -->|"reads session"| node_auth
node_shell -->|"opens palette"| node_command
node_command -->|"queries items"| node_inventoryapi
node_inventoryhome -->|"loads inventory"| node_inventoryapi
node_inventoryapi -->|"uses"| node_client
node_inventoryapi -->|"reads and writes stock"| node_supabase
node_itemform -->|"loads supplier options"| node_suppliers
node_daily -->|"uses count state"| node_dailyhook
node_dailyhook -->|"fetches and finalizes"| node_dailyapi
node_dailyapi -->|"reads and writes counts"| node_supabase
node_reports -->|"loads report data"| node_reportapi
node_reports -->|"queries inventory"| node_inventoryapi
node_reportapi -.->|"queries reports"| node_supabase
node_reports -.->|"exports reports"| node_exports
node_keepalive -->|"uses"| node_client
node_keepalive -->|"pings database"| node_supabase
node_realtime -->|"uses"| node_client
node_admin -.->|"manages settings"| node_supabase

click node_app "https://github.com/ownertest-byte/kuventory/blob/master/src/app/App.tsx"
click node_auth "https://github.com/ownertest-byte/kuventory/blob/master/src/features/auth/context/AuthContext.tsx"
click node_login "https://github.com/ownertest-byte/kuventory/blob/master/src/features/auth/pages/LoginPage.tsx"
click node_guard "https://github.com/ownertest-byte/kuventory/blob/master/src/features/auth/components/RequireAuth.tsx"
click node_shell "https://github.com/ownertest-byte/kuventory/blob/master/src/components/layout/AppLayout.tsx"
click node_command "https://github.com/ownertest-byte/kuventory/blob/master/src/components/layout/CommandPalette.tsx"
click node_catalog "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/ItemsCatalogPage.tsx"
click node_itemdetails "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/ItemDetailsPage.tsx"
click node_inventoryhome "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/InventoryLandingPage.tsx"
click node_inventoryapi "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/api/index.ts"
click node_itemform "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/components/ItemFormModal.tsx"
click node_mutations "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/hooks/useStockMutations.ts"
click node_batches "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/StockBatchesPage.tsx"
click node_history "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/StockHistoryPage.tsx"
click node_daily "https://github.com/ownertest-byte/kuventory/blob/master/src/features/daily-inventory/pages/DailyInventoryPage.tsx"
click node_dailyhook "https://github.com/ownertest-byte/kuventory/blob/master/src/features/daily-inventory/hooks/useDailyInventory.ts"
click node_dailyapi "https://github.com/ownertest-byte/kuventory/blob/master/src/features/daily-inventory/api/index.ts"
click node_reports "https://github.com/ownertest-byte/kuventory/blob/master/src/features/reports/pages/ReportsLibraryPage.tsx"
click node_reportview "https://github.com/ownertest-byte/kuventory/blob/master/src/features/reports/pages/ReportViewPage.tsx"
click node_reportapi "https://github.com/ownertest-byte/kuventory/blob/master/src/features/reports/api/reports.ts"
click node_exports "https://github.com/ownertest-byte/kuventory/tree/master/src/features/reports/export"
click node_notifications "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/NotificationCenter.tsx"
click node_admin "https://github.com/ownertest-byte/kuventory/blob/master/src/features/admin/pages/AdminPage.tsx"
click node_categories "https://github.com/ownertest-byte/kuventory/blob/master/src/features/categories/pages/CategoriesPage.tsx"
click node_suppliers "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/components/SuppliersDirectoryTab.tsx"
click node_realtime "https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/hooks/useRealtimeSync.ts"
click node_keepalive "https://github.com/ownertest-byte/kuventory/blob/master/src/lib/keepalive.ts"
click node_client "https://github.com/ownertest-byte/kuventory/blob/master/src/lib/supabase.ts"

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_guard,node_shell,node_command,node_user toneBlue
class node_catalog,node_itemdetails,node_inventoryhome,node_inventoryapi,node_itemform,node_mutations,node_batches,node_history,node_supabase toneAmber
class node_daily,node_dailyhook,node_dailyapi toneMint
class node_reports,node_reportview,node_reportapi,node_exports,node_notifications toneRose
class node_admin,node_categories,node_suppliers,node_realtime,node_keepalive,node_client toneIndigo
```

## Components

### Access and shell

- [Route coordinator](https://github.com/ownertest-byte/kuventory/blob/master/src/app/App.tsx): `src/app/App.tsx`
- [Authentication context](https://github.com/ownertest-byte/kuventory/blob/master/src/features/auth/context/AuthContext.tsx): `src/features/auth/context/AuthContext.tsx`
- [Login experience](https://github.com/ownertest-byte/kuventory/blob/master/src/features/auth/pages/LoginPage.tsx): `src/features/auth/pages/LoginPage.tsx`
- [Protected-route guard](https://github.com/ownertest-byte/kuventory/blob/master/src/features/auth/components/RequireAuth.tsx): `src/features/auth/components/RequireAuth.tsx`
- [Application shell](https://github.com/ownertest-byte/kuventory/blob/master/src/components/layout/AppLayout.tsx): `src/components/layout/AppLayout.tsx`
- [Command palette](https://github.com/ownertest-byte/kuventory/blob/master/src/components/layout/CommandPalette.tsx): `src/components/layout/CommandPalette.tsx`

### Inventory operations

- [Item catalog](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/ItemsCatalogPage.tsx): `src/features/inventory/pages/ItemsCatalogPage.tsx`
- [Item details](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/ItemDetailsPage.tsx): `src/features/inventory/pages/ItemDetailsPage.tsx`
- [Inventory overview](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/InventoryLandingPage.tsx): `src/features/inventory/pages/InventoryLandingPage.tsx`
- [Inventory data operations](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/api/index.ts): `src/features/inventory/api/index.ts`
- [Item editor](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/components/ItemFormModal.tsx): `src/features/inventory/components/ItemFormModal.tsx`
- [Stock mutations](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/hooks/useStockMutations.ts): `src/features/inventory/hooks/useStockMutations.ts`
- [Stock batches](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/StockBatchesPage.tsx): `src/features/inventory/pages/StockBatchesPage.tsx`
- [Stock history](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/StockHistoryPage.tsx): `src/features/inventory/pages/StockHistoryPage.tsx`

### Daily counting

- [Daily inventory screen](https://github.com/ownertest-byte/kuventory/blob/master/src/features/daily-inventory/pages/DailyInventoryPage.tsx): `src/features/daily-inventory/pages/DailyInventoryPage.tsx`
- [Daily inventory state](https://github.com/ownertest-byte/kuventory/blob/master/src/features/daily-inventory/hooks/useDailyInventory.ts): `src/features/daily-inventory/hooks/useDailyInventory.ts`
- [Daily count operations](https://github.com/ownertest-byte/kuventory/blob/master/src/features/daily-inventory/api/index.ts): `src/features/daily-inventory/api/index.ts`

### Reports and alerts

- [Reports library](https://github.com/ownertest-byte/kuventory/blob/master/src/features/reports/pages/ReportsLibraryPage.tsx): `src/features/reports/pages/ReportsLibraryPage.tsx`
- [Report detail](https://github.com/ownertest-byte/kuventory/blob/master/src/features/reports/pages/ReportViewPage.tsx): `src/features/reports/pages/ReportViewPage.tsx`
- [Report data operations](https://github.com/ownertest-byte/kuventory/blob/master/src/features/reports/api/reports.ts): `src/features/reports/api/reports.ts`
- [Report exports](https://github.com/ownertest-byte/kuventory/tree/master/src/features/reports/export): `src/features/reports/export`
- [Notification center](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/pages/NotificationCenter.tsx): `src/features/inventory/pages/NotificationCenter.tsx`

### Shared platform

- [Settings and administration](https://github.com/ownertest-byte/kuventory/blob/master/src/features/admin/pages/AdminPage.tsx): `src/features/admin/pages/AdminPage.tsx`
- [Category management](https://github.com/ownertest-byte/kuventory/blob/master/src/features/categories/pages/CategoriesPage.tsx): `src/features/categories/pages/CategoriesPage.tsx`
- [Supplier directory](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/components/SuppliersDirectoryTab.tsx): `src/features/inventory/components/SuppliersDirectoryTab.tsx`
- [Realtime synchronization](https://github.com/ownertest-byte/kuventory/blob/master/src/features/inventory/hooks/useRealtimeSync.ts): `src/features/inventory/hooks/useRealtimeSync.ts`
- [Database keepalive](https://github.com/ownertest-byte/kuventory/blob/master/src/lib/keepalive.ts): `src/lib/keepalive.ts`
- [Supabase client](https://github.com/ownertest-byte/kuventory/blob/master/src/lib/supabase.ts): `src/lib/supabase.ts`

### Other components

- **Restaurant user**
- **Supabase platform**

## Connections

- Restaurant user → Route coordinator: uses (evidence: `src/app/App.tsx`)
- Route coordinator → Authentication context: provides auth (evidence: `src/app/App.tsx`)
- Route coordinator → Login experience: routes to (evidence: `src/app/App.tsx`)
- Route coordinator → Protected-route guard: protects routes (evidence: `src/app/App.tsx`)
- Route coordinator → Application shell: mounts shell (evidence: `src/app/App.tsx`)
- Route coordinator → Daily inventory screen: routes to (evidence: `src/app/App.tsx`)
- Route coordinator → Item catalog: routes to (evidence: `src/app/App.tsx`)
- Route coordinator → Item details: routes to (evidence: `src/app/App.tsx`)
- Route coordinator → Inventory overview: routes to (evidence: `src/app/App.tsx`)
- Route coordinator → Reports library: routes to (evidence: `src/app/App.tsx`)
- Route coordinator → Report detail: routes to (evidence: `src/app/App.tsx`)
- Route coordinator → Notification center: routes to (evidence: `src/app/App.tsx`)
- Route coordinator → Settings and administration: routes to (evidence: `src/app/App.tsx`)
- Route coordinator → Realtime synchronization: starts sync (evidence: `src/app/App.tsx`)
- Route coordinator → Database keepalive: starts heartbeat (evidence: `src/app/App.tsx`)
- Authentication context → Supabase client: uses (evidence: `src/features/auth/context/AuthContext.tsx`)
- Authentication context → Supabase platform: auth and profile queries (evidence: `src/features/auth/context/AuthContext.tsx`)
- Application shell → Authentication context: reads session (evidence: `src/components/layout/AppLayout.tsx`)
- Application shell → Command palette: opens palette (evidence: `src/components/layout/AppLayout.tsx`)
- Command palette → Inventory data operations: queries items (evidence: `src/components/layout/CommandPalette.tsx`)
- Inventory overview → Inventory data operations: loads inventory (evidence: `src/features/inventory/pages/InventoryLandingPage.tsx`)
- Inventory data operations → Supabase client: uses (evidence: `src/features/inventory/api/index.ts`)
- Inventory data operations → Supabase platform: reads and writes stock (evidence: `src/features/inventory/api/index.ts`)
- Item editor → Supplier directory: loads supplier options (evidence: `src/features/inventory/components/ItemFormModal.tsx`)
- Daily inventory screen → Daily inventory state: uses count state (evidence: `src/features/daily-inventory/pages/DailyInventoryPage.tsx`)
- Daily inventory state → Daily count operations: fetches and finalizes (evidence: `src/features/daily-inventory/hooks/useDailyInventory.ts`)
- Daily count operations → Supabase platform: reads and writes counts (evidence: `src/features/daily-inventory/api/index.ts`)
- Reports library → Report data operations: loads report data (evidence: `src/features/reports/pages/ReportsLibraryPage.tsx`)
- Reports library → Inventory data operations: queries inventory (evidence: `src/features/reports/pages/ReportsLibraryPage.tsx`)
- Report data operations → Supabase platform: queries reports
- Reports library → Report exports: exports reports
- Database keepalive → Supabase client: uses (evidence: `src/lib/keepalive.ts`)
- Database keepalive → Supabase platform: pings database (evidence: `src/lib/keepalive.ts`)
- Realtime synchronization → Supabase client: uses (evidence: `src/features/inventory/hooks/useRealtimeSync.ts`)
- Settings and administration → Supabase platform: manages settings
