Summary
- The whole shipment lifecycle, from creation to delivery in the field and returns, in one platform for admin, operations, customer and driver roles.
- Thin endpoints, thick services: shipment, state transition, return, routing and messaging rules live in separate services.
- Long-lived or risky work (WhatsApp, browser automation) runs in separate Node.js bridges that the main application calls with short-lived signed tokens.
On this page (11 sections)
- Browser / PWA
- Nginx
- PHP-FPM Screens and API endpoints
- Business services Shipments, state transitions, returns, routing, messaging
- MySQL / MariaDB
This is an employer-owned system. Source code, customer data, infrastructure topology and credentials are not published here; the description stays at the architectural level.
Context
A web platform that runs the full shipment lifecycle, from creation to doorstep delivery and returns, for administrators, operations staff, customers and drivers, plus a CRM that works alongside it. I designed and built both as the sole developer; every feature runs in production.
Architecture
Browser / PWA ──► Nginx ──► PHP-FPM (screens and API endpoints) ──► business services ──► MySQL / MariaDB
│
├─► WhatsApp bridge (Node.js)
├─► Accounting session bridge (Node.js + Playwright)
├─► Routing service (OSM + OSRM, Docker)
└─► Vehicle tracking · geocoding · LLM (external APIs)
- Thin endpoints, thick services. Screen and API files only receive requests; the rules for creating shipments, status transitions, returns, routing and messaging live in dedicated services.
- Micro bridges. Long-running or risky work, such as browser automation and WhatsApp, runs in separate Node.js processes. The main application talks to them with short-lived, single-use, path-bound signed tokens.
- CRM. Built on Node.js, Express and SQLite, with one module per domain (orders, deals, finance, stock, tasks, e-invoicing…) and shared access, auth, schema and pagination layers. The process listens on the loopback interface only; browsers reach it through a reverse proxy.
Roles and authorisation
Four roles (administrator, operations, customer, driver) each have their own workspace. Access is checked by role and by company; in the CRM it is layered as session → view → role → company/object ownership. An authorisation matrix documents every route, and access-matrix tests verify it.
Shipment lifecycle
Status transitions follow a rule-based flow. A wrong action can be undone without corrupting the record, and every change is written to the shipment’s activity history. Bulk CSV import detects encoding, previews and validates row by row. Returns are recorded independently of delivery, with history preserved.
Proof of delivery
The driver app (a PWA) scans barcodes with the camera, updates status and produces monthly mileage reports. Deliveries are documented with signature, location record and video. The digital custody flow captures a signature, generates a PDF and publishes it.
Integrations
- Routing. Geoapify for geocoding, and a self-hosted OSM/OSRM service on Docker for distances and routes; intercity mileage reports and route exports.
- Vehicle tracking. Arvento integration with a cached status service for live vehicle and driver status.
- WhatsApp. Templated notifications and an inbox that links conversations to shipments through phone-number normalisation, answered from the admin workspace.
- Accounting (Luca). A Playwright-driven session bridge: single session, allow-listed, never storing credentials; the foundation of the e-waybill module.
- AI assistant. A tool-calling assistant behind a prompt-injection guard.
- External API. Key-authenticated integration endpoints with handover documentation.
- Notifications. Web Push (VAPID), in-app notifications and broadcast announcements.
Security
Multi-factor authentication, remembered devices, session logging and revocation; CSRF protection, abuse rate limiting and input validation; encryption for sensitive data with key-rotation tooling; upload scanning, audit logs, log retention and disposal policies; an SBOM and a dependency policy. Authentication, session, cryptography, data protection, logging, upload and API authorisation policies are each documented separately.
Data and operations
Versioned migrations, a runtime schema inventory, rollback drills and a backup/restore procedure. In the CRM, the database and uploaded files are backed up together, consistently.
Testing and quality
A persistent test environment that never touches live data, with all four roles available from one address. Audit, role-flow, access-matrix, migration-contract, UI, WhatsApp and accounting-bridge tests. Every completed task is recorded with an ID, date, source version, test results and an evidence file.
Engineering decisions
- Why separate bridge services? Browser automation and messaging have different lifetimes and failure modes from the main application. Separate processes stop a bridge failure from affecting the platform and narrow what each component can do.
- Why a self-hosted routing service? So distance and route calculations do not depend on an external service and reports stay reproducible.
- Why reversible status transitions? Mistakes in the field are inevitable; correcting them without corrupting the record protects data integrity.
Maintainability
The layered structure lets a new workflow be added without breaking existing rules. Policy documents, migrations and an evidence-based completion log aim to keep knowledge in the system even if the people working on it change.