A comprehensive delivery management system for small produce delivery businesses with support for SMS order intake, route optimization, billing, and Cantonese voice input.
All 5 core test scenarios PASSED:
- ✓ Scenario 1: Product and customer setup with pricing overrides
- ✓ Scenario 2: SMS order processing with Cantonese/English parsing
- ✓ Scenario 3: Order creation with custom pricing
- ✓ Scenario 4: Delivery adjustments
- ✓ Scenario 5: Billing statement generation and payment tracking
- ✅ Customer management with addresses and billing cycles
- ✅ Product catalog with cost/price tracking
- ✅ Customer-specific pricing overrides
- ✅ SMS/voicemail message parsing (Cantonese + English)
- ✅ Order management with line items
- ✅ Delivery route planning and optimization
- ✅ Billing statement generation
- ✅ Payment tracking (cash, cheque, e-transfer)
- ✅ Reporting (daily summary, period summary, top customers, product performance)
- ✅ Price history tracking
GET /api/customers- List all customersGET /api/customers/:id- Get customer by IDGET /api/customers/phone/:phone- Get customer by phonePOST /api/customers- Create new customerPUT /api/customers/:id- Update customerDELETE /api/customers/:id- Delete customerGET /api/customers/:id/pricing- Get pricing overridesPOST /api/customers/:id/pricing- Set pricing override
GET /api/products- List all products (query: common_only=true)GET /api/products/:id- Get product by IDPOST /api/products- Create new productPUT /api/products/:id- Update productPOST /api/products/bulk-update-price- Bulk update pricesGET /api/products/:id/price-history- Get price historyGET /api/products/:id/cost-history- Get cost history
GET /api/orders- List orders (query: delivery_date, customer_id, status)GET /api/orders/:id- Get order by IDPOST /api/orders- Create new orderPUT /api/orders/line-items/:line_item_id- Update line item (delivery adjustments)POST /api/orders/:id/deliver- Mark order as deliveredDELETE /api/orders/:id- Delete order
GET /api/messages- List messages (query: status)POST /api/messages/receive-sms- Receive SMS webhookPOST /api/messages/:message_id/convert-to-order- Convert message to orderPUT /api/messages/:message_id/status- Update message status
GET /api/routes- List routes (query: delivery_date)GET /api/routes/workers- List delivery workersPOST /api/routes/workers- Create workerPOST /api/routes/optimize- Optimize routesGET /api/routes/:route_id- Get route detailsPUT /api/routes/:route_id/status- Update route status
GET /api/billing/statements- List statements (query: customer_id, payment_status)POST /api/billing/statements/generate- Generate statementGET /api/billing/statements/:statement_id- Get statement detailsPUT /api/billing/statements/:statement_id/send- Mark as sentPOST /api/billing/payments- Record paymentGET /api/billing/payments/customer/:customer_id- Get customer paymentsGET /api/billing/outstanding- Get outstanding balances
GET /api/reports/daily-summary- Daily sales summary (query: date)GET /api/reports/period-summary- Period summary (query: start_date, end_date)GET /api/reports/top-customers- Top customers (query: start_date, end_date, limit)GET /api/reports/product-performance- Product performance (query: start_date, end_date)
- Node.js (v16 or higher)
- npm
- Navigate to backend directory:
cd D:\StandardTrading\delivery-system\backend- Install dependencies:
npm install- Initialize database:
npm run init-db- Run tests to verify setup:
npm test- Start the server:
npm startThe API will be available at http://localhost:3000
Copy .env.example to .env and configure:
PORT=3000
NODE_ENV=development
# Twilio (for SMS integration - optional for now)
TWILIO_ACCOUNT_SID=your_account_sid
TWILIO_AUTH_TOKEN=your_auth_token
TWILIO_PHONE_NUMBER=your_phone_number
# Google Maps API (for route optimization - optional for now)
GOOGLE_MAPS_API_KEY=your_api_keyThe system uses SQLite with the following main tables:
customers- Customer information with addressesproducts- Product catalog with costs and pricescustomer_pricing- Customer-specific price overridesorders- Orders with delivery datesorder_line_items- Individual items in ordersdelivery_workers- Delivery personneldelivery_routes- Optimized delivery routesmessage_inbox- SMS/voicemail inboxbilling_statements- Billing statements per customerpayments- Payment records
curl -X POST http://localhost:3000/api/customers \
-H "Content-Type: application/json" \
-d '{
"name_english": "Mr. Chan",
"name_cantonese": "陳先生",
"phone_primary": "416-555-0001",
"address_street": "123 Main St",
"address_city": "Toronto",
"billing_cycle": "monthly"
}'curl -X POST http://localhost:3000/api/products \
-H "Content-Type: application/json" \
-d '{
"name_english": "Large Eggs",
"name_cantonese": "大雞蛋",
"category": "eggs",
"is_common_item": true,
"current_base_cost": 3.50,
"default_price": 5.00,
"unit": "dozen"
}'curl -X POST http://localhost:3000/api/customers/{customer_id}/pricing \
-H "Content-Type: application/json" \
-d '{
"product_id": "{product_id}",
"custom_price": 4.50,
"notes": "VIP discount"
}'curl -X POST http://localhost:3000/api/messages/receive-sms \
-H "Content-Type: application/json" \
-d '{
"from": "416-555-0001",
"body": "明天要兩打大雞蛋,一公斤大菇"
}'curl -X POST http://localhost:3000/api/orders \
-H "Content-Type: application/json" \
-d '{
"customer_id": "{customer_id}",
"delivery_date": "2026-01-14",
"order_source": "manual-entry",
"line_items": [
{
"product_id": "{product_id}",
"quantity": 2
}
]
}'curl http://localhost:3000/api/reports/daily-summary?date=2026-01-13The system includes a smart parser for Cantonese and English SMS messages:
Supported patterns:
- "明天要兩打大雞蛋,一公斤大菇" → 2 dozen Large Eggs, 1 kg Large Mushroom
- "tmr need 3 dozen 大雞蛋" → 3 dozen Large Eggs
- "要蛋" → Flagged for manual review (ambiguous)
Confidence scoring:
- High (>85%): Auto-creates order
- Medium (60-85%): Flags for quick review
- Low (<60%): Requires manual parsing
- React-based dashboard
- Mobile-responsive design
- Voice input using Web Speech API
- Customer/product management UI
- Order entry grid interface
- Route planning map view
- Billing statement generation UI
- Offline-capable delivery app
- GPS navigation integration
- Digital signature capture
- Real-time order adjustments
- Photo capture for notes
- Twilio SMS webhook (currently simulated)
- Google Maps API for route optimization
- Email service for billing statements
- Voicemail transcription service
- Multi-user authentication
- Role-based permissions
- Customer portal for self-ordering
- Automated SMS confirmations
- Inventory forecasting
- Excel export for reports
delivery-system/
├── backend/
│ ├── routes/
│ │ ├── customers.js # Customer management
│ │ ├── products.js # Product management
│ │ ├── orders.js # Order management
│ │ ├── messages.js # SMS/voicemail handling
│ │ ├── routes.js # Delivery route planning
│ │ ├── billing.js # Billing & payments
│ │ └── reports.js # Reporting endpoints
│ ├── utils/
│ │ └── message-parser.js # SMS parsing logic
│ ├── database.js # Database wrapper
│ ├── init-database.js # Schema initialization
│ ├── server.js # Express server
│ ├── test-scenarios.js # Automated tests
│ ├── package.json
│ └── .env.example
├── frontend/ # (To be implemented)
├── docs/
└── README.md
For issues or questions, contact the development team.
Proprietary - For internal use only