How vkkumar4000/inventory-app works
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: supabase.js Supabase client · layout.tsx Root layout · Sidebar.tsx Sidebar · page.tsx Products
Components 32
App shell
Routing boundaries, layouts, and auth gatekeeping.
- Middleware · First access boundary before protected pages.
middleware.ts - Root layout · Global application frame and providers.
app/layout.tsx - Global styles · Base styling for the whole app.
app/globals.css - Login layout · Presentation wrapper for the sign-in flow.
app/login/layout.tsx - Sales detail layout · Specialized wrapper for sales record views.
app/sales/[id]/layout.tsx
Domain routes
Primary product screens for each business area.
- Home · Top-level landing route for the app.
app/page.tsx - Login · Unauthenticated entry path.
app/login/page.tsx - Products · Manage product records.
app/products/page.tsx - Categories · Manage product categories.
app/categories/page.tsx - Customers · Manage customer records.
app/customers/page.tsx - Suppliers · Manage supplier records.
app/suppliers/page.tsx - Inventory · View and manage stock state.
app/inventory/page.tsx - Purchases · List and manage purchase workflows.
app/purchases/page.tsx - Purchase detail · Record-specific purchase workflow.
app/purchases/[id]/page.tsx - Sales · List and manage sales workflows.
app/sales/page.tsx - Sale detail · Record-specific sales workflow.
app/sales/[id]/page.tsx - Bill detail · Record-specific bill view and actions.
app/bill/[id]/page.tsx - Stock moves · Track stock movement history.
app/stock-movements/page.tsx - Reports · Operational reporting and summaries.
app/reports/page.tsx - Settings · Application configuration and preferences.
app/settings/page.tsx
Shared UI
Reusable business components and UI primitives.
- Sidebar · Primary navigation across business areas.
components/Sidebar.tsx - Mobile header · Compact header for small screens.
components/MobileHeader.tsx - Shop header · Contextual header for shop-facing screens.
components/ShopHeader.tsx - Customer search · Reusable customer selection/search UI.
components/CustomerSearch.tsx - Product search · Reusable product selection/search UI.
components/ProductSearch.tsx - Email button · Triggers outbound email actions.
components/EmailButton.tsx - Print button · Client-side printing control.
components/PrintButton.tsx - Report print · Printing control for report views.
components/ReportPrintButton.tsx - WhatsApp button · Share or contact action via WhatsApp.
components/WhatsAppButton.tsx - UI primitives · Reusable base controls used across screens.
components/ui/button.tsx
Data & integration
Persistence client and server-side integration endpoints.
- Supabase client · Shared persistence and backend access layer.
lib/supabase.js - Send email API · Server-side endpoint for outbound email.
app/api/send-email/route.ts
Connections 42
- 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.