# vkkumar4000/inventory-app architecture

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

- Interactive diagram: https://gitdiagram.com/vkkumar4000/inventory-app
- Repository: https://github.com/vkkumar4000/inventory-app

## Overview

1. This repository is a single Next.js application built with the App Router. There is no separate backend service in the tree; the app itself contains the UI, route handlers, and integration glue.

2. The product domain is an inventory / sales / purchasing management system. The main top-level route groups map to business areas: products, categories, customers, suppliers, inventory, purchases, sales, bills, stock movements, reports, and settings. That structure is the clearest basis for a system diagram.

3. The application shell lives in `app/layout.tsx` and global styling in `app/globals.css`. Route-specific layouts exist for `app/login/layout.tsx` and `app/sales/[id]/layout.tsx`, which suggests the sales detail flow has its own presentation wrapper distinct from the main authenticated shell.

4. Authentication or access control is likely enforced at the routing layer through `middleware.ts`. In a diagram, treat middleware as the first boundary in front of protected pages, with login as the unauthenticated entry path.

5. The only explicit API endpoint is `app/api/send-email/route.ts`. That is the server-side integration point for outbound email, and it is separate from the page routes. The UI likely triggers it through the `EmailButton` component.

6. External data access is centralized in `lib/supabase.js`, which strongly indicates Supabase is the application’s persistence/backend service. The pages likely read and write business entities through that shared Supabase client rather than through a custom backend layer.

7. Shared UI behavior is factored into reusable components under `components/`. Notable cross-cutting pieces include `Sidebar`, `MobileHeader`, `ShopHeader`, `PrintButton`, `ReportPrintButton`, `EmailButton`, and `WhatsAppButton`, plus search components for customers and products. These are orchestration and interaction components rather than domain pages.

8. The reusable UI primitives in `components/ui/` (`button`, `card`, `dialog`, `input`, `select`, `table`, etc.) form the design-system layer. They sit below the business components and are used across many pages to keep presentation consistent.

9. The route pages under `app/` are the primary data-entry and data-view screens. Dynamic detail routes like `app/bill/[id]`, `app/purchases/[id]`, and `app/sales/[id]` represent record-specific workflows, while the collection pages (`/products`, `/customers`, `/sales`, etc.) represent list/manage views.

10. The most important data flow is: authenticated user opens a domain page → page component queries Supabase → shared components support search/edit/print/share actions → record-specific pages render details and trigger side effects such as email or WhatsApp. Printing is handled locally through dedicated button components rather than a separate service.

11. `components.json`, `tailwind/postcss`-style config files, `eslint.config.mjs`, `tsconfig.json`, and `next.config.ts` indicate a standard Next.js/TypeScript frontend stack with component-driven UI and build-time tooling. `public/` contains static assets only; it is not a separate architectural subsystem.

12. If you are drawing the architecture, the key boundaries are: browser UI, Next.js route layer, shared component layer, Supabase-backed persistence, and the small email API route. The app is fundamentally a modular admin console with domain-separated pages rather than a microservice-based system.

Main entry points: [`lib/supabase.js`](https://github.com/vkkumar4000/inventory-app/blob/main/lib/supabase.js) (Supabase client), [`app/layout.tsx`](https://github.com/vkkumar4000/inventory-app/blob/main/app/layout.tsx) (Root layout), [`components/Sidebar.tsx`](https://github.com/vkkumar4000/inventory-app/blob/main/components/Sidebar.tsx) (Sidebar), [`app/products/page.tsx`](https://github.com/vkkumar4000/inventory-app/blob/main/app/products/page.tsx) (Products)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["App shell"]
  node_middleware{{"Middleware<br/>auth gate<br/>[middleware.ts]"}}
  node_app_layout["Root layout<br/>app shell<br/>[layout.tsx]"]
  node_app_globals["Global styles<br/>styling<br/>[globals.css]"]
  node_login_layout["Login layout<br/>auth layout<br/>[layout.tsx]"]
  node_sales_detail_layout["Sales detail layout<br/>[layout.tsx]"]
end

subgraph group_routes["Domain routes"]
  node_home_page["Home<br/>entry page<br/>[page.tsx]"]
  node_login_page["Login<br/>auth page<br/>[page.tsx]"]
  node_products_page["Products<br/>catalog page<br/>[page.tsx]"]
  node_categories_page["Categories<br/>catalog page<br/>[page.tsx]"]
  node_customers_page["Customers<br/>crm page<br/>[page.tsx]"]
  node_suppliers_page["Suppliers<br/>vendor page<br/>[page.tsx]"]
  node_inventory_page["Inventory<br/>stock page<br/>[page.tsx]"]
  node_purchases_page["Purchases<br/>procurement page<br/>[page.tsx]"]
  node_purchase_detail["Purchase detail<br/>procurement detail<br/>[page.tsx]"]
  node_sales_page["Sales<br/>[page.tsx]"]
  node_sales_detail["Sale detail<br/>sales detail<br/>[page.tsx]"]
  node_bill_detail["Bill detail<br/>billing detail<br/>[page.tsx]"]
  node_movements_page["Stock moves<br/>inventory flow<br/>[page.tsx]"]
  node_reports_page["Reports<br/>analytics page<br/>[page.tsx]"]
  node_settings_page["Settings<br/>admin page<br/>[page.tsx]"]
end

subgraph group_shared["Shared UI"]
  node_sidebar["Sidebar<br/>navigation shell<br/>[Sidebar.tsx]"]
  node_mobile_header["Mobile header<br/>responsive shell<br/>[MobileHeader.tsx]"]
  node_shop_header["Shop header<br/>page header<br/>[ShopHeader.tsx]"]
  node_customer_search["Customer search<br/>lookup component<br/>[CustomerSearch.tsx]"]
  node_product_search["Product search<br/>lookup component<br/>[ProductSearch.tsx]"]
  node_email_button["Email button<br/>side effect ui<br/>[EmailButton.tsx]"]
  node_print_button["Print button<br/>print action<br/>[PrintButton.tsx]"]
  node_report_print["Report print<br/>print action"]
  node_wa_button["WhatsApp button<br/>share action<br/>[WhatsAppButton.tsx]"]
  node_ui_button["UI primitives<br/>design system<br/>[button.tsx]"]
end

subgraph group_data["Data & integration"]
  node_supabase[("Supabase client<br/>data client<br/>[supabase.js]")]
  node_send_email_api{{"Send email API<br/>route handler<br/>[route.ts]"}}
end

node_middleware -->|"allows"| node_login_page
node_middleware -->|"protects"| node_app_layout
node_app_layout -->|"wraps"| node_home_page
node_app_layout -->|"wraps"| node_products_page
node_app_layout -->|"wraps"| node_customers_page
node_app_layout -->|"wraps"| node_suppliers_page
node_app_layout -->|"wraps"| node_categories_page
node_app_layout -->|"wraps"| node_inventory_page
node_app_layout -->|"wraps"| node_purchases_page
node_app_layout -->|"wraps"| node_sales_page
node_app_layout -->|"wraps"| node_reports_page
node_login_layout -->|"wraps"| node_login_page
node_sales_detail_layout -->|"wraps"| node_sales_detail
node_sidebar -->|"navigates"| node_products_page
node_sidebar -->|"navigates"| node_customers_page
node_sidebar -->|"navigates"| node_suppliers_page
node_sidebar -->|"navigates"| node_inventory_page
node_sidebar -->|"navigates"| node_purchases_page
node_sidebar -->|"navigates"| node_sales_page
node_mobile_header -->|"supports"| node_sidebar
node_shop_header -->|"supports"| node_sales_detail
node_customer_search -->|"supports"| node_customers_page
node_product_search -->|"supports"| node_products_page
node_print_button -->|"supports"| node_purchase_detail
node_print_button -->|"supports"| node_sales_detail
node_report_print -->|"supports"| node_reports_page
node_email_button -->|"calls"| node_send_email_api
node_wa_button -->|"supports"| node_sales_detail
node_ui_button -->|"used by"| node_products_page
node_ui_button -->|"used by"| node_customers_page
node_ui_button -->|"used by"| node_sales_page
node_supabase -->|"backing data"| node_products_page
node_supabase -->|"backing data"| node_customers_page
node_supabase -->|"backing data"| node_suppliers_page
node_supabase -->|"backing data"| node_inventory_page
node_supabase -->|"backing data"| node_purchases_page
node_supabase -->|"backing data"| node_purchase_detail
node_supabase -->|"backing data"| node_sales_page
node_supabase -->|"backing data"| node_sales_detail
node_supabase -->|"backing data"| node_bill_detail
node_supabase -->|"backing data"| node_movements_page
node_supabase -->|"backing data"| node_reports_page

click node_middleware "https://github.com/vkkumar4000/inventory-app/blob/main/middleware.ts"
click node_app_layout "https://github.com/vkkumar4000/inventory-app/blob/main/app/layout.tsx"
click node_app_globals "https://github.com/vkkumar4000/inventory-app/blob/main/app/globals.css"
click node_login_layout "https://github.com/vkkumar4000/inventory-app/blob/main/app/login/layout.tsx"
click node_sales_detail_layout "https://github.com/vkkumar4000/inventory-app/blob/main/app/sales/[id]/layout.tsx"
click node_home_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/page.tsx"
click node_login_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/login/page.tsx"
click node_products_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/products/page.tsx"
click node_categories_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/categories/page.tsx"
click node_customers_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/customers/page.tsx"
click node_suppliers_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/suppliers/page.tsx"
click node_inventory_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/inventory/page.tsx"
click node_purchases_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/purchases/page.tsx"
click node_purchase_detail "https://github.com/vkkumar4000/inventory-app/blob/main/app/purchases/[id]/page.tsx"
click node_sales_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/sales/page.tsx"
click node_sales_detail "https://github.com/vkkumar4000/inventory-app/blob/main/app/sales/[id]/page.tsx"
click node_bill_detail "https://github.com/vkkumar4000/inventory-app/blob/main/app/bill/[id]/page.tsx"
click node_movements_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/stock-movements/page.tsx"
click node_reports_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/reports/page.tsx"
click node_settings_page "https://github.com/vkkumar4000/inventory-app/blob/main/app/settings/page.tsx"
click node_sidebar "https://github.com/vkkumar4000/inventory-app/blob/main/components/Sidebar.tsx"
click node_mobile_header "https://github.com/vkkumar4000/inventory-app/blob/main/components/MobileHeader.tsx"
click node_shop_header "https://github.com/vkkumar4000/inventory-app/blob/main/components/ShopHeader.tsx"
click node_customer_search "https://github.com/vkkumar4000/inventory-app/blob/main/components/CustomerSearch.tsx"
click node_product_search "https://github.com/vkkumar4000/inventory-app/blob/main/components/ProductSearch.tsx"
click node_email_button "https://github.com/vkkumar4000/inventory-app/blob/main/components/EmailButton.tsx"
click node_print_button "https://github.com/vkkumar4000/inventory-app/blob/main/components/PrintButton.tsx"
click node_report_print "https://github.com/vkkumar4000/inventory-app/blob/main/components/ReportPrintButton.tsx"
click node_wa_button "https://github.com/vkkumar4000/inventory-app/blob/main/components/WhatsAppButton.tsx"
click node_ui_button "https://github.com/vkkumar4000/inventory-app/blob/main/components/ui/button.tsx"
click node_supabase "https://github.com/vkkumar4000/inventory-app/blob/main/lib/supabase.js"
click node_send_email_api "https://github.com/vkkumar4000/inventory-app/blob/main/app/api/send-email/route.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_middleware,node_app_layout,node_app_globals,node_login_layout,node_sales_detail_layout toneBlue
class node_home_page,node_login_page,node_products_page,node_categories_page,node_customers_page,node_suppliers_page,node_inventory_page,node_purchases_page,node_purchase_detail,node_sales_page,node_sales_detail,node_bill_detail,node_movements_page,node_reports_page,node_settings_page toneAmber
class node_sidebar,node_mobile_header,node_shop_header,node_customer_search,node_product_search,node_email_button,node_print_button,node_report_print,node_wa_button,node_ui_button toneMint
class node_supabase,node_send_email_api toneRose
```

## Components

### App shell

Routing boundaries, layouts, and auth gatekeeping.

- [Middleware](https://github.com/vkkumar4000/inventory-app/blob/main/middleware.ts): auth gate · First access boundary before protected pages. · `middleware.ts`
- [Root layout](https://github.com/vkkumar4000/inventory-app/blob/main/app/layout.tsx): app shell · Global application frame and providers. · `app/layout.tsx`
- [Global styles](https://github.com/vkkumar4000/inventory-app/blob/main/app/globals.css): styling · Base styling for the whole app. · `app/globals.css`
- [Login layout](https://github.com/vkkumar4000/inventory-app/blob/main/app/login/layout.tsx): auth layout · Presentation wrapper for the sign-in flow. · `app/login/layout.tsx`
- [Sales detail layout](https://github.com/vkkumar4000/inventory-app/blob/main/app/sales/[id]/layout.tsx): detail layout · Specialized wrapper for sales record views. · `app/sales/[id]/layout.tsx`

### Domain routes

Primary product screens for each business area.

- [Home](https://github.com/vkkumar4000/inventory-app/blob/main/app/page.tsx): entry page · Top-level landing route for the app. · `app/page.tsx`
- [Login](https://github.com/vkkumar4000/inventory-app/blob/main/app/login/page.tsx): auth page · Unauthenticated entry path. · `app/login/page.tsx`
- [Products](https://github.com/vkkumar4000/inventory-app/blob/main/app/products/page.tsx): catalog page · Manage product records. · `app/products/page.tsx`
- [Categories](https://github.com/vkkumar4000/inventory-app/blob/main/app/categories/page.tsx): catalog page · Manage product categories. · `app/categories/page.tsx`
- [Customers](https://github.com/vkkumar4000/inventory-app/blob/main/app/customers/page.tsx): crm page · Manage customer records. · `app/customers/page.tsx`
- [Suppliers](https://github.com/vkkumar4000/inventory-app/blob/main/app/suppliers/page.tsx): vendor page · Manage supplier records. · `app/suppliers/page.tsx`
- [Inventory](https://github.com/vkkumar4000/inventory-app/blob/main/app/inventory/page.tsx): stock page · View and manage stock state. · `app/inventory/page.tsx`
- [Purchases](https://github.com/vkkumar4000/inventory-app/blob/main/app/purchases/page.tsx): procurement page · List and manage purchase workflows. · `app/purchases/page.tsx`
- [Purchase detail](https://github.com/vkkumar4000/inventory-app/blob/main/app/purchases/[id]/page.tsx): procurement detail · Record-specific purchase workflow. · `app/purchases/[id]/page.tsx`
- [Sales](https://github.com/vkkumar4000/inventory-app/blob/main/app/sales/page.tsx): sales page · List and manage sales workflows. · `app/sales/page.tsx`
- [Sale detail](https://github.com/vkkumar4000/inventory-app/blob/main/app/sales/[id]/page.tsx): sales detail · Record-specific sales workflow. · `app/sales/[id]/page.tsx`
- [Bill detail](https://github.com/vkkumar4000/inventory-app/blob/main/app/bill/[id]/page.tsx): billing detail · Record-specific bill view and actions. · `app/bill/[id]/page.tsx`
- [Stock moves](https://github.com/vkkumar4000/inventory-app/blob/main/app/stock-movements/page.tsx): inventory flow · Track stock movement history. · `app/stock-movements/page.tsx`
- [Reports](https://github.com/vkkumar4000/inventory-app/blob/main/app/reports/page.tsx): analytics page · Operational reporting and summaries. · `app/reports/page.tsx`
- [Settings](https://github.com/vkkumar4000/inventory-app/blob/main/app/settings/page.tsx): admin page · Application configuration and preferences. · `app/settings/page.tsx`

### Shared UI

Reusable business components and UI primitives.

- [Sidebar](https://github.com/vkkumar4000/inventory-app/blob/main/components/Sidebar.tsx): navigation shell · Primary navigation across business areas. · `components/Sidebar.tsx`
- [Mobile header](https://github.com/vkkumar4000/inventory-app/blob/main/components/MobileHeader.tsx): responsive shell · Compact header for small screens. · `components/MobileHeader.tsx`
- [Shop header](https://github.com/vkkumar4000/inventory-app/blob/main/components/ShopHeader.tsx): page header · Contextual header for shop-facing screens. · `components/ShopHeader.tsx`
- [Customer search](https://github.com/vkkumar4000/inventory-app/blob/main/components/CustomerSearch.tsx): lookup component · Reusable customer selection/search UI. · `components/CustomerSearch.tsx`
- [Product search](https://github.com/vkkumar4000/inventory-app/blob/main/components/ProductSearch.tsx): lookup component · Reusable product selection/search UI. · `components/ProductSearch.tsx`
- [Email button](https://github.com/vkkumar4000/inventory-app/blob/main/components/EmailButton.tsx): side effect ui · Triggers outbound email actions. · `components/EmailButton.tsx`
- [Print button](https://github.com/vkkumar4000/inventory-app/blob/main/components/PrintButton.tsx): print action · Client-side printing control. · `components/PrintButton.tsx`
- [Report print](https://github.com/vkkumar4000/inventory-app/blob/main/components/ReportPrintButton.tsx): print action · Printing control for report views. · `components/ReportPrintButton.tsx`
- [WhatsApp button](https://github.com/vkkumar4000/inventory-app/blob/main/components/WhatsAppButton.tsx): share action · Share or contact action via WhatsApp. · `components/WhatsAppButton.tsx`
- [UI primitives](https://github.com/vkkumar4000/inventory-app/blob/main/components/ui/button.tsx): design system · Reusable base controls used across screens. · `components/ui/button.tsx`

### Data & integration

Persistence client and server-side integration endpoints.

- [Supabase client](https://github.com/vkkumar4000/inventory-app/blob/main/lib/supabase.js): data client · Shared persistence and backend access layer. · `lib/supabase.js`
- [Send email API](https://github.com/vkkumar4000/inventory-app/blob/main/app/api/send-email/route.ts): route handler · Server-side endpoint for outbound email. · `app/api/send-email/route.ts`

## Connections

- Middleware → Login: allows · Unauthenticated entry path.
- Middleware → Root layout: protects · Gates protected app routes.
- Root layout → Home: wraps · Provides the main app shell.
- Root layout → Products: wraps · Provides the main app shell.
- Root layout → Customers: wraps · Provides the main app shell.
- Root layout → Suppliers: wraps · Provides the main app shell.
- Root layout → Categories: wraps · Provides the main app shell.
- Root layout → Inventory: wraps · Provides the main app shell.
- Root layout → Purchases: wraps · Provides the main app shell.
- Root layout → Sales: wraps · Provides the main app shell.
- Root layout → Reports: wraps · Provides the main app shell.
- Login layout → Login: wraps · Specialized auth presentation.
- Sales detail layout → Sale detail: wraps · Specialized record presentation.
- Sidebar → Products: navigates · Cross-domain navigation.
- Sidebar → Customers: navigates · Cross-domain navigation.
- Sidebar → Suppliers: navigates · Cross-domain navigation.
- Sidebar → Inventory: navigates · Cross-domain navigation.
- Sidebar → Purchases: navigates · Cross-domain navigation.
- Sidebar → Sales: navigates · Cross-domain navigation.
- Mobile header → Sidebar: supports · Responsive navigation complement.
- Shop header → Sale detail: supports · Contextual presentation on detail screens.
- Customer search → Customers: supports · Reusable lookup in customer workflows.
- Product search → Products: supports · Reusable lookup in product workflows.
- Print button → Purchase detail: supports · Local print workflow.
- Print button → Sale detail: supports · Local print workflow.
- Report print → Reports: supports · Local print workflow.
- Email button → Send email API: calls · Triggers the server-side email endpoint.
- WhatsApp button → Sale detail: supports · Sales sharing/contact action.
- UI primitives → Products: used by · Base presentation primitive.
- UI primitives → Customers: used by · Base presentation primitive.
- UI primitives → Sales: used by · Base presentation primitive.
- Supabase client → Products: backing data · Primary persistence access for domain pages.
- Supabase client → Customers: backing data · Primary persistence access for domain pages.
- Supabase client → Suppliers: backing data · Primary persistence access for domain pages.
- Supabase client → Inventory: backing data · Primary persistence access for domain pages.
- Supabase client → Purchases: backing data · Primary persistence access for domain pages.
- Supabase client → Purchase detail: backing data · Primary persistence access for domain pages.
- Supabase client → Sales: backing data · Primary persistence access for domain pages.
- Supabase client → Sale detail: backing data · Primary persistence access for domain pages.
- Supabase client → Bill detail: backing data · Primary persistence access for domain pages.
- Supabase client → Stock moves: backing data · Primary persistence access for domain pages.
- Supabase client → Reports: backing data · Primary persistence access for domain pages.
