How rootme254/mitumba-shop works
1. This repository is a Next.js App Router application for retail/POS operations, not a generic website. The route structure and feature names suggest a store-management system covering sales, inventory, customers, staff, expenses, refunds, reporting, and layaway.
2. The app is organized primarily by route segment under app/, with each major business area exposed as its own page. Examples include pos, products, customers, staff, expenses, refunds, reports, notifications, bales, layaway, dashboard, and diagnostic.
3. The central transaction flow appears to live in the POS area. app/pos/page.js, app/pos/sell/page.js, app/pos/shift-open/page.js, and app/pos/shift-close/page.js indicate a cashier workflow with shift lifecycle management and an explicit sell path.
4. State and persistence are likely backed by Supabase. The presence of lib/supabase.js and lib/supabase-server.js implies both client-side and server-side access layers, while lib/session.js and lib/auth.js handle user/session concerns around that backend.
5. Authentication and route protection are enforced at the framework boundary. middleware.js, together with login-related code in app/login/page.js, suggests requests are gated before they reach protected application routes, rather than relying only on in-page checks.
6. There is a clear offline/PWA subsystem. public/manifest.json, public/sw.js, components/SWRegistrar.jsx, components/PWAComponents.jsx, and app/offline/page.js indicate the app is designed to install as a PWA and continue working in reduced-connectivity scenarios.
7. The offline support is not just cosmetic; lib/offline.js exists as a dedicated utility layer, so offline behavior is treated as a first-class architectural concern rather than a browser add-on. The offline page likely serves as a fallback or recovery surface when network access is unavailable.
8. Payment integration is present through lib/mpesa.js, which points to an external M-Pesa dependency. That means at least part of the sales flow likely coordinates with an external payment provider rather than using only local bookkeeping.
9. The application includes serverless/API functionality, but it is minimal compared with the page-based UI. The only explicit API route shown is app/api/diagnostic/route.js, which likely supports health checks, environment verification, or operational troubleshooting.
10. Shared layout and navigation are separated from business pages. app/layout.js, components/NavWrapper.jsx, and components/BottomNav.jsx suggest a reusable shell that wraps the different modules and probably supports a mobile-friendly navigation model.
11. Styling and static assets are standard Next.js concerns: app/globals.css provides global styles, while public/ contains the web app manifest and service worker artifacts. next.config.mjs, postcss.config.mjs, and eslint.config.mjs indicate normal app build/tooling boundaries rather than custom infrastructure.
12. The top-level dashboard, reports, and diagnostic pages act as operational views rather than core transaction entry points. In an architecture diagram, these should sit as read/monitoring surfaces fed by the same backend data used by POS and inventory features.
13. Overall data flow is: authenticated user enters via login, middleware protects routes, feature pages read/write through Supabase-backed helpers, POS and payment actions may call M-Pesa, and the PWA layer plus service worker supports offline access and installable behavior.
Main entry points: supabase.js Supabase Client · page.js POS · PWAComponents.jsx PWA Layer · supabase-server.js Supabase Server
Components 26
App Router
Route-driven UI and server endpoints
- Login · Entry page for user sign-in
app/login/page.js - Offline · Dedicated offline/recovery surface
app/offline/page.js - POS · Cashier entry point and transaction flow
app/pos/page.js - Shift Ops · Open and close shift lifecycle
app/pos/shift-open/page.js - Sell · Explicit sale checkout path
app/pos/sell/page.js - Products · Product and catalogue management
app/products/page.js - Customers · Customer records and interactions
app/customers/page.js - Staff · Employee and staff management
app/staff/page.js - Expenses · Operational spending management
app/expenses/page.js - Refunds · Refund processing and reversals
app/refunds/page.js - Reports · Operational reporting and summaries
app/reports/page.js - Dashboard · High-level operational summary
app/dashboard/page.js - Diagnostic · Troubleshooting and health surface
app/diagnostic/page.js - API Diagnostic · Server endpoint for checks and diagnostics
app/api/diagnostic/route.js
Core Services
Auth, session, persistence, payment, and offline helpers
- Middleware · Protects app routes before they load
middleware.js - Auth · Authentication and session helpers
lib/auth.js - Session · Session handling utilities
lib/session.js - Supabase Client · Client-side Supabase access layer
lib/supabase.js - Supabase Server · Server-side Supabase access layer
lib/supabase-server.js - M-Pesa · External payment integration for sales
lib/mpesa.js - Offline Utils · Offline behavior and sync helpers
lib/offline.js
Shell & PWA
Shared layout, navigation, and install/offline support
- App Shell · Root layout for the application
app/layout.js - Navigation · Shared navigation wrappers and bottom nav
components/NavWrapper.jsx - PWA Layer · Service worker registration and offline-aware UI
components/PWAComponents.jsx - Service Worker · Installable app and caching runtime
public/sw.js - Manifest · Web app install metadata
public/manifest.json
Connections 25
- Middleware → Login: gates · Unauthenticated users are routed to login
- Middleware → POS: protects · Middleware shields protected app areas
- Middleware → Dashboard: protects · Middleware shields protected app areas
- App Shell → Navigation: wraps · Shared shell composes navigation
- App Shell → PWA Layer: includes · Root layout enables PWA behavior
- PWA Layer → Service Worker: registers · Client layer hooks up the service worker
- PWA Layer → Manifest: uses · PWA UI depends on install metadata
- PWA Layer → Offline: fallback · Offline UI points to recovery surface
- Offline Utils → Offline: supports · Offline helpers back the offline route
- Login → Auth: uses · Login relies on auth helpers
- Auth → Session: manages · Authentication builds on session state
- Auth → Supabase Server: checks · Server-side auth integrates with backend access
- POS → Shift Ops: coordinates · POS includes shift lifecycle actions
- POS → Sell: routes to · Sales flow branches into checkout
- Sell → M-Pesa: charges · Checkout may invoke external payment handling
- POS → Supabase Client: reads/writes · Client POS state persists through Supabase
- Products → Supabase Client: reads/writes · Inventory data is managed through Supabase
- Customers → Supabase Client: reads/writes · Customer records persist through Supabase
- Staff → Supabase Client: reads/writes · Staff data persists through Supabase
- Expenses → Supabase Client: reads/writes · Expense records persist through Supabase
- Refunds → Supabase Client: reads/writes · Refund records persist through Supabase
- Reports → Supabase Server: aggregates · Reports likely compute from server data access
- Dashboard → Supabase Server: summarizes · Dashboard is fed by backend data
- Diagnostic → API Diagnostic: calls · Diagnostic page can hit the API health endpoint
- API Diagnostic → Supabase Server: verifies · API diagnostic can validate server-side access