File size: 2,882 Bytes
fcf8749 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | # π Hyper-Local Logistics & Relay Optimizer
An advanced, end-to-end logistics orchestration platform designed to maximize truck utilization and driver efficiency. This project features a unique **Driver Relay (Handshake) System** and an automated, API-free **e-Way Bill Generator**.
---
## π Key Features
### π Driver Relay & Workload Balancing
Intelligent assignment logic based on custom business rules:
* **Experience-Based Assignment:** Automatically matches long-haul missions (e.g., >300km) with experienced drivers (high historical `totalDistanceKm`).
* **Workload Balancing:** Assigns shorter missions to newer drivers to ensure a fair and safe distribution of labor.
* **ID Resolution:** Dispatchers use "Human-Readable" identifiers like **Phone Numbers** and **License Plates** instead of complex Database UUIDs.
### π€ Absorption Handshake System
A peer-to-peer "handover" mechanism allowing trucks to exchange goods at virtual hubs:
* **Offline Verification:** Supports a "Digital Handshake" via cryptographic QR codes for areas with zero cellular connectivity.
* **Dual-Bill Updates:** Automatically handles the transfer of responsibility between an "Exporter" driver and an "Importer" driver.
### π Dynamic e-Way Bill Mimicry
Generates professional e-Way Bills using **Node.js & Puppeteer**:
* **No External APIs:** Mimics the official government layout purely via HTML/CSS.
* **Auto-Data Resolution:** Fetches GSTINs (Supplier/Recipient), License Plates, and Phone Numbers automatically from the database.
* **Dual Generation:** Produces two updated PDFs (for both trucks) instantly during an absorption event, delivered in a single `.zip` file.
---
## ποΈ Technical Architecture
### **Tech Stack**
* **Backend:** Node.js, Express.js
* **Database:** PostgreSQL (Optimized with Prisma ORM)
* **PDF Engine:** Puppeteer (Headless Chrome for high-fidelity rendering)
* **Auth:** JWT with Role-Based Access Control (RBAC)
* **File Handling:** `archiver` for ZIP generation and `qrcode` for local QR generation.
---
## π Project Structure
```text
βββ config/
β βββ prisma.js # Prisma Client initialization
βββ controllers/
β βββ routeController.js # Relay logic & assignment
β βββ ewayBillController.js # PDF generation & absorption logic
βββ services/
β βββ puppeteer.service.js # PDF rendering engine (Virtual Printer)
β βββ qr.service.js # Base64 QR code generation
βββ templates/
β βββ ewayBill.html # HTML layout mimicking official format
βββ public/
β βββ css/ewayBill.css # Print-optimized styles (@media print)
βββ routes/
β βββ api.js # Protected API endpoints
βββ prisma/
βββ schema.prisma # Relational Database Models |