# krishnakant333/shelflife architecture

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

- Interactive diagram: https://gitdiagram.com/krishnakant333/shelflife
- Repository: https://github.com/krishnakant333/shelflife

## Overview

ShelfLife serves consumer households and food businesses through separate authenticated workspaces. Users maintain inventory; deterministic expiry, quantity, unit, and FIFO logic supports alerts, analytics, waste tracking, and safe consumer recipe generation, while AI assists with extraction and recommendations. The graph includes marketing, authentication, inventory operations, and intelligence capabilities. Some features are documented but their implementation was not sampled, so those branches are shown without asserted call relationships; the graph reflects only visible or documented connections.

Main entry points: [`src/app/dashboard/page.tsx`](https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/page.tsx) (Consumer dashboard), [`src/auth.ts`](https://github.com/krishnakant333/shelflife/blob/main/src/auth.ts) (Credentials auth), [`src/app/business/dashboard/page.tsx`](https://github.com/krishnakant333/shelflife/blob/main/src/app/business/dashboard/page.tsx) (Business dashboard), [`src/components/dashboard/AddProductFlow.tsx`](https://github.com/krishnakant333/shelflife/blob/main/src/components/dashboard/AddProductFlow.tsx) (Product entry flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public experience"]
  node_marketing["Marketing site<br/>[page.tsx]"]
end

subgraph group_access["Access and workspaces"]
  node_auth["Credentials auth<br/>[auth.ts]"]
  node_consumer_home["Consumer dashboard<br/>[page.tsx]"]
  node_business_home["Business dashboard<br/>[page.tsx]"]
  node_db[("Postgres data<br/>[db.ts]")]
end

subgraph group_inventory["Inventory operations"]
  node_inventory_read["Consumer inventory read<br/>[inventory.ts]"]
  node_business_inventory["Business inventory"]
  node_inventory_actions["Inventory actions<br/>[inventory.ts]"]
  node_business_actions["Business inventory actions"]
  node_inventory_ui["Inventory workspace<br/>[InventoryView.tsx]"]
  node_product_flow["Product entry flow<br/>[AddProductFlow.tsx]"]
  node_status["Inventory status"]
  node_normalize["Unit normalization<br/>[normalization.ts]"]
  node_file_intake["CSV and invoice intake"]
  node_image_storage["Product image storage<br/>[storage.ts]"]
  node_image_lifecycle["Image lifecycle"]
  node_blob{{"Vercel Blob"}}
end

subgraph group_intelligence["Food intelligence"]
  node_ai_scan["Label and invoice AI<br/>[label-scan.ts]"]
  node_recipes["Recipe generation<br/>[recipes.ts]"]
  node_recipe_ui["Recipe workspace<br/>[page.tsx]"]
  node_groq{{"Groq AI"}}
  node_analytics["Inventory analytics<br/>[page.tsx]"]
  node_waste["Waste tracking<br/>[page.tsx]"]
  node_notifications["Activity notifications<br/>[page.tsx]"]
  node_off{{"Open Food Facts"}}
end

node_visitor(("Visitor"))
node_consumer(("Consumer"))
node_business(("Business user"))

node_visitor -->|"visits"| node_marketing
node_consumer -.->|"signs in"| node_auth
node_business -.->|"signs in"| node_auth
node_auth -->|"checks credentials"| node_db
node_consumer_home -->|"validates session"| node_auth
node_business_home -->|"validates session"| node_auth
node_consumer_home -->|"loads inventory"| node_inventory_read
node_business_home -->|"loads inventory"| node_business_inventory
node_consumer_home -->|"classifies stock"| node_status
node_business_home -->|"classifies stock"| node_status
node_inventory_read -->|"checks ownership"| node_auth
node_inventory_read -->|"reads items"| node_db
node_business_home -->|"renders workspace"| node_inventory_ui
node_consumer_home -->|"renders workspace"| node_inventory_ui
node_product_flow -->|"submits changes"| node_inventory_actions
node_product_flow -->|"submits changes"| node_business_actions
node_product_flow -->|"scans labels"| node_ai_scan
node_product_flow -->|"normalizes units"| node_normalize
node_inventory_actions -->|"cleans image assets"| node_image_lifecycle
node_image_lifecycle -->|"checks references"| node_db
node_image_lifecycle -->|"deletes assets"| node_image_storage
node_image_storage -->|"stores images"| node_blob
node_file_intake -.->|"imports inventory"| node_inventory_actions
node_file_intake -.->|"extracts invoices"| node_ai_scan
node_ai_scan -.->|"extracts label data"| node_groq
node_recipe_ui -.->|"requests recipes"| node_recipes
node_recipes -->|"filters ingredients"| node_inventory_read
node_recipes -->|"generates recipes"| node_groq
node_consumer_home -.->|"opens reports"| node_analytics
node_consumer_home -.->|"tracks waste"| node_waste
node_consumer_home -.->|"views activity"| node_notifications
node_inventory_actions -.->|"looks up imagery"| node_off

click node_marketing "https://github.com/krishnakant333/shelflife/blob/main/src/app/(marketing)/page.tsx"
click node_auth "https://github.com/krishnakant333/shelflife/blob/main/src/auth.ts"
click node_consumer_home "https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/page.tsx"
click node_business_home "https://github.com/krishnakant333/shelflife/blob/main/src/app/business/dashboard/page.tsx"
click node_db "https://github.com/krishnakant333/shelflife/blob/main/src/prisma/db.ts"
click node_inventory_read "https://github.com/krishnakant333/shelflife/blob/main/src/lib/inventory.ts"
click node_business_inventory "https://github.com/krishnakant333/shelflife/blob/main/src/lib/business-inventory.ts"
click node_inventory_actions "https://github.com/krishnakant333/shelflife/blob/main/src/lib/actions/inventory.ts"
click node_business_actions "https://github.com/krishnakant333/shelflife/blob/main/src/lib/actions/business-inventory.ts"
click node_inventory_ui "https://github.com/krishnakant333/shelflife/blob/main/src/components/dashboard/InventoryView.tsx"
click node_product_flow "https://github.com/krishnakant333/shelflife/blob/main/src/components/dashboard/AddProductFlow.tsx"
click node_status "https://github.com/krishnakant333/shelflife/blob/main/src/lib/inventory-status.ts"
click node_normalize "https://github.com/krishnakant333/shelflife/blob/main/src/lib/normalization.ts"
click node_file_intake "https://github.com/krishnakant333/shelflife/tree/main/src/lib/import"
click node_image_storage "https://github.com/krishnakant333/shelflife/blob/main/src/lib/storage.ts"
click node_image_lifecycle "https://github.com/krishnakant333/shelflife/blob/main/src/lib/storage-lifecycle.ts"
click node_ai_scan "https://github.com/krishnakant333/shelflife/blob/main/src/lib/actions/label-scan.ts"
click node_recipes "https://github.com/krishnakant333/shelflife/blob/main/src/lib/actions/recipes.ts"
click node_recipe_ui "https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/recipes/page.tsx"
click node_analytics "https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/analytics/page.tsx"
click node_waste "https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/waste/page.tsx"
click node_notifications "https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/notifications/page.tsx"

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_marketing,node_business toneBlue
class node_auth,node_consumer_home,node_business_home,node_db toneAmber
class node_inventory_read,node_business_inventory,node_inventory_actions,node_business_actions,node_inventory_ui,node_product_flow,node_status,node_normalize,node_file_intake,node_image_storage,node_image_lifecycle,node_blob toneMint
class node_ai_scan,node_recipes,node_recipe_ui,node_groq,node_analytics,node_waste,node_notifications,node_off toneRose
class node_visitor,node_consumer toneIndigo
```

## Components

### Public experience

- [Marketing site](https://github.com/krishnakant333/shelflife/blob/main/src/app/(marketing)/page.tsx): `src/app/(marketing)/page.tsx`

### Access and workspaces

- [Credentials auth](https://github.com/krishnakant333/shelflife/blob/main/src/auth.ts): `src/auth.ts`
- [Consumer dashboard](https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Business dashboard](https://github.com/krishnakant333/shelflife/blob/main/src/app/business/dashboard/page.tsx): `src/app/business/dashboard/page.tsx`
- [Postgres data](https://github.com/krishnakant333/shelflife/blob/main/src/prisma/db.ts): `src/prisma/db.ts`

### Inventory operations

- [Consumer inventory read](https://github.com/krishnakant333/shelflife/blob/main/src/lib/inventory.ts): `src/lib/inventory.ts`
- [Business inventory](https://github.com/krishnakant333/shelflife/blob/main/src/lib/business-inventory.ts): `src/lib/business-inventory.ts`
- [Inventory actions](https://github.com/krishnakant333/shelflife/blob/main/src/lib/actions/inventory.ts): `src/lib/actions/inventory.ts`
- [Business inventory actions](https://github.com/krishnakant333/shelflife/blob/main/src/lib/actions/business-inventory.ts): `src/lib/actions/business-inventory.ts`
- [Inventory workspace](https://github.com/krishnakant333/shelflife/blob/main/src/components/dashboard/InventoryView.tsx): `src/components/dashboard/InventoryView.tsx`
- [Product entry flow](https://github.com/krishnakant333/shelflife/blob/main/src/components/dashboard/AddProductFlow.tsx): `src/components/dashboard/AddProductFlow.tsx`
- [Inventory status](https://github.com/krishnakant333/shelflife/blob/main/src/lib/inventory-status.ts): `src/lib/inventory-status.ts`
- [Unit normalization](https://github.com/krishnakant333/shelflife/blob/main/src/lib/normalization.ts): `src/lib/normalization.ts`
- [CSV and invoice intake](https://github.com/krishnakant333/shelflife/tree/main/src/lib/import): `src/lib/import`
- [Product image storage](https://github.com/krishnakant333/shelflife/blob/main/src/lib/storage.ts): `src/lib/storage.ts`
- [Image lifecycle](https://github.com/krishnakant333/shelflife/blob/main/src/lib/storage-lifecycle.ts): `src/lib/storage-lifecycle.ts`
- **Vercel Blob**

### Food intelligence

- [Label and invoice AI](https://github.com/krishnakant333/shelflife/blob/main/src/lib/actions/label-scan.ts): `src/lib/actions/label-scan.ts`
- [Recipe generation](https://github.com/krishnakant333/shelflife/blob/main/src/lib/actions/recipes.ts): `src/lib/actions/recipes.ts`
- [Recipe workspace](https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/recipes/page.tsx): `src/app/dashboard/recipes/page.tsx`
- **Groq AI**
- [Inventory analytics](https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/analytics/page.tsx): `src/app/dashboard/analytics/page.tsx`
- [Waste tracking](https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/waste/page.tsx): `src/app/dashboard/waste/page.tsx`
- [Activity notifications](https://github.com/krishnakant333/shelflife/blob/main/src/app/dashboard/notifications/page.tsx): `src/app/dashboard/notifications/page.tsx`
- **Open Food Facts**

### Other components

- **Visitor**
- **Consumer**
- **Business user**

## Connections

- Visitor → Marketing site: visits (evidence: `src/app/(marketing)/page.tsx`)
- Consumer → Credentials auth: signs in (evidence: `README.md`)
- Business user → Credentials auth: signs in (evidence: `README.md`)
- Credentials auth → Postgres data: checks credentials (evidence: `src/auth.ts`)
- Consumer dashboard → Credentials auth: validates session (evidence: `src/app/dashboard/page.tsx`)
- Business dashboard → Credentials auth: validates session (evidence: `src/app/business/dashboard/page.tsx`)
- Consumer dashboard → Consumer inventory read: loads inventory (evidence: `src/app/dashboard/page.tsx`)
- Business dashboard → Business inventory: loads inventory (evidence: `src/app/business/dashboard/page.tsx`)
- Consumer dashboard → Inventory status: classifies stock (evidence: `src/app/dashboard/page.tsx`)
- Business dashboard → Inventory status: classifies stock (evidence: `src/app/business/dashboard/page.tsx`)
- Consumer inventory read → Credentials auth: checks ownership (evidence: `src/lib/inventory.ts`)
- Consumer inventory read → Postgres data: reads items (evidence: `src/lib/inventory.ts`)
- Business dashboard → Inventory workspace: renders workspace (evidence: `src/app/business/dashboard/page.tsx`)
- Consumer dashboard → Inventory workspace: renders workspace (evidence: `src/app/dashboard/page.tsx`)
- Product entry flow → Inventory actions: submits changes (evidence: `src/components/dashboard/AddProductFlow.tsx`)
- Product entry flow → Business inventory actions: submits changes (evidence: `src/components/dashboard/AddProductFlow.tsx`)
- Product entry flow → Label and invoice AI: scans labels (evidence: `src/components/dashboard/AddProductFlow.tsx`)
- Product entry flow → Unit normalization: normalizes units (evidence: `src/components/dashboard/AddProductFlow.tsx`)
- Inventory actions → Image lifecycle: cleans image assets (evidence: `src/lib/actions/inventory.ts`)
- Image lifecycle → Postgres data: checks references (evidence: `src/lib/storage-lifecycle.ts`)
- Image lifecycle → Product image storage: deletes assets (evidence: `src/lib/storage-lifecycle.ts`)
- Product image storage → Vercel Blob: stores images (evidence: `src/lib/storage.ts`)
- CSV and invoice intake → Inventory actions: imports inventory
- CSV and invoice intake → Label and invoice AI: extracts invoices
- Label and invoice AI → Groq AI: extracts label data (evidence: `README.md`)
- Recipe workspace → Recipe generation: requests recipes
- Recipe generation → Consumer inventory read: filters ingredients (evidence: `src/lib/actions/recipes.ts`)
- Recipe generation → Groq AI: generates recipes (evidence: `src/lib/actions/recipes.ts`)
- Consumer dashboard → Inventory analytics: opens reports (evidence: `README.md`)
- Consumer dashboard → Waste tracking: tracks waste (evidence: `README.md`)
- Consumer dashboard → Activity notifications: views activity (evidence: `README.md`)
- Inventory actions → Open Food Facts: looks up imagery (evidence: `README.md`)
