Labayik Traders ERP is an enterprise-grade Sales, Distribution, Logistics, and Financial management platform designed for wholesale distributors and trading networks. The system streamlines the complete booker-to-retailer supply chain by coordinating inventory tracking, dynamic routing, double-entry ledger bookkeeping, and mobile-friendly booker operations in real-time. Built with React 19, Node.js 24, and Drizzle ORM over PostgreSQL, the ERP is designed for rapid transactions, precise accounting, and resilient offline-first field access. TECHNICAL SPECIFICATIONS & ARCHITECTURE ======================================== 1. Frontend Architecture - Framework: React 19 bootstrapped with Vite 8 for fast builds and hot module replacement. - Styling: Tailwind CSS v4 featuring a premium, Stripe-inspired glassmorphic dashboard theme tailored for readability on mobile tablets and desktops. - Iconography: Material Symbols for a clean Google-style design. - Authentication Client: Better-Auth React SDK for secure sessions, CSRF protection, and OAuth helper hooks. 2. Backend Runtime & Logic Layer - Runtime: Node.js v24+ leveraging experimental native TypeScript support (--experimental-strip-types) for zero-step compilation execution. - Framework: Express.js (v5) powering high-throughput JSON REST APIs. - Validation & Safety: Schema validation using Zod on all incoming request payloads, guaranteeing strict input verification. - Logging: High-performance JSON logging using Pino Logger for distributed debugging and cloud execution monitoring. - Testing: Unit and integration testing with Vitest and Supertest. 3. Database & Storage Layer - Database: Serverless PostgreSQL hosted on Neon.tech, optimizing connection pooling and autoscaling during peak inventory hours. - Object-Relational Mapper (ORM): Drizzle ORM for type-safe SQL query generation, lightweight footprint, and declarative database schema migrations. SYSTEM MODULES & WORKFLOWS =========================== 1. Booker Operations Portal - Dynamic Order Entry: Specialized cart layout enabling field bookers to register orders directly from retail outlets, with live price calculation and active store balance validation. - Flexible Billing: Built-in calculator for invoice rates, retail prices, shipment costs, and custom tax brackets. - Specialized Booker Ledger: An independent credit ledger separating Booker-held cash from retail store debt. Booker credit tracks goods checked out from the warehouse, while Shop credit tracks store balance. - Order-to-Payment Verification Loop: * Booker places order -> Admin confirms request. * Admin generates bill -> Booker collects invoice. * Booker collects physical payment -> Admin verifies cash delivery (separating admin-in-hand cash from booker-in-transit cash). 2. Financial General Ledger & P&L Module - Double-Entry Accounting: Automated credit/debit transaction log posting on all sales, payments, and operational actions. - P&L Statement Engine: Real-time calculation of gross revenue, Cost of Goods Sold (COGS), and net profits based on the spread between product invoice rates, main rates, and retail prices. - Accounts Receivable Aging: Categorized metrics tracking outstanding shop balances. 3. Inventory & Route Directory Management - Shop & Route Registry: Groups retail outlets into logical zones (e.g., North-East Corridor, CBD, Western Ports) to optimize courier delivery paths. - Dynamic Stock Control: Multi-booker product mapping allowing single items to be assigned to multiple sales agents. - Valuation Dashboards: Displays total stock valuation calculated instantly via current invoice rates. 4. HR & Salary Payroll Processing - Payroll Engine: Automates commission tracking for bookers based on targets met and achievements completed. - Deductions & Salaries: Seamlessly manages base salary disbursements, expense deductions, and advance pay logs in the finance dashboard. KEY ENGINEERING ACCOMPLISHMENTS ================================ - Multi-Tier Ledger Separation: Designed and implemented a custom transactional logic separating retailer debt (Shop Balance) from field-agent cash (Booker Credit). This resolved a major industry challenge in distribution systems—tracking cash lost in transit by field agents. - Real-Time Inventory Valuation: Optimized Drizzle queries to compute cumulative stock valuation on fly-weight tables, providing immediate financial health checks without causing database bottlenecks. - Stripe-Inspired Glassmorphic UX: Built a fully responsive Tailwind CSS v4 portal that supports seamless navigation on low-end smartphones used by bookers in remote areas. - Secure API & Session Architecture: Configured Better-Auth with multi-tier role-based access controls (RBAC) to prevent unprivileged personnel from modifying financial records or clearing shop balances.