This guide provides step-by-step instructions to verify every major feature of the platform.
Goal: Verify that all services (API, DB, OSRM, Nginx, Frontend) are running in harmony.
-
Start the Stack:
docker-compose up --build -d
-
Update Schema (POD Support):
uv run python -m scripts.update_db_pod -
Seed the Fleet (10 Drivers & 50 Singapore Orders):
uv run python -m scripts.seed_data uv run python -m scripts.setup_auth
-
Run the API server
uv run uvicorn api.main:app_with_sio --reload -
Verify Accessibility:
- Dashboard: Open
http://localhost:8000/dashboard/in your browser. (Map should center on Singapore). - Driver App: Open
http://localhost:8000/driverin your browser.
Usernames: john, jane, or bob Password: password123
- API Health: Check
http://localhost:8000/api/(should return "Delivery Optimizer API is running").
- Dashboard: Open
- Run the Optimizer: Click the "⚡ Run Optimizer" button in the top header. You should see the grey "Pending" dots turn into colored routes once the optimization finishes.
- Simulate Drivers: Open a new terminal and run:
- uv run python -m scripts.simulate_drivers
-
the script simulates Real-time GPS movement for all drivers currently assigned to routes.
-
Specifically, it performs the following steps:
-
Authentication: It automatically logs in as each driver using their credentials (defaulting to password123) to obtain JWT security tokens.
-
Route Loading: It fetches today's optimized routes from the database for every driver. Path Interpolation: It calculates a path starting from a "Depot" point (central Singapore) and moving smoothly through each assigned stop in the correct sequence. Location Pulse (The Event): Every ~0.2 seconds, it sends a PATCH request to the API updating the driver's coordinates.
-
WebSocket Broadcast: The API catches these updates and broadcasts a location_update event via Socket.io. Dashboard Reaction: Your dashboard (on port 8000) listens for these events and moves the truck icons (🚚) on the map in real-time without you needing to refresh the page.
- View Assignments: Go to the Fleet view. You will now see that each driver has a Tied Vehicle assigned to them.
- Clock In: Click the "Check In" button for a driver. The status turns ONLINE (Green) and the dashboard acknowledges their assigned vehicle.
- Clock Out: Click "Check Out" to end the shift. The status turns OFFLINE (Grey).
APIs:
POST /drivers/<ID>/check-inPOST /drivers/<ID>/check-out
curl -XPOST http://localhost:8000/drivers/SGP-102Z/check-in
{"message":"Driver Charlie Lim checked in","online":true,"driver_id":"4075bff8-48aa-4a66-9988-2cecc15c79a5","vehicle":{"plate_number":"SGP-102Z","type":"BIKE"}}
curl -XPOST http://localhost:8000/drivers/SGP-102Z/check-out {"message":"Checked out successfully","online":false}
Goal: Verify that you can create and manage orders via the UI.
- Add Order: Click "+ Add Order" on the dashboard. Click anywhere on the map. Enter an address and save.
- Verify Persistence: Refresh the page; the new order marker should remain on the map as a grey (Pending) dot.
- Edit/Delete: Click an existing marker, change the address, or delete it using the panel.
Goal: Verify the OR-Tools engine respects vehicle capacities and driver breaks.
- Seed Drivers/Vehicles: Ensure drivers are active in the database.
- Generate Routes:
- Option A (UI): Click the "⚡ Run Optimizer" button on the dashboard header.
- Option B (Manual): Run the script directly:
python -m scripts.optimizer_prototype
- Verify Route Count & Assignment:
- Visual: Each colored polyline on the map represents one route (up to 10 for the 10 drivers).
- Schedule View: Click a driver card in the sidebar. If the "Schedule" tab populates with list of stops, the route was successfully generated for that driver.
- Verify Constraints:
- Observe that heavy orders (Weight > Vehicle Capacity) are split between multiple vehicles.
- Check the timeline for a "Break" window at 12:00 PM (the optimizer calculates travel times around this idle period).
Goal: Verify the "last-mile" completion process.
- Login: Go to
http://localhost/driver. Login withjohnorjaneoralice, etc. (username is the driver's first name in lowercase, password ispassword123). - Delivery:
- You will see a list of assigned stops for "John Doe".
- Click "Mark as Delivered" on a stop.
- Capture POD:
- Photo: Click "📸 Take Photo" (simulated via file upload).
- Signature: Draw a signature on the white canvas.
- Click "Complete Delivery".
- Verification: The stop should now show as green ("✓ DELIVERED") in the driver app and on the management dashboard map.
Goal: Verify the WebSocket connection and risk monitoring.
- Simulate Movement:
python -m scripts.simulate_drivers - Live Tracking: Observe the truck icons (🚚) moving on the dashboard map in real-time.
- Simulate Late Risk:
- In the database (or via script), set a pending stop's
estimated_arrival_timeto be 5 minutes from now. - Wait up to 60 seconds.
- A red alert toast should slide in from the top-right alert container on the dashboard.
- In the database (or via script), set a pending stop's
Goal: Verify data visualization and reporting.
- Seed History:
python -m scripts.seed_performance - Charts: Click "Analytics" in the sidebar. Verify that the line charts for volume, service time, and efficiency are populated.
- POD Audit:
- Go back to the Dashboard "Schedule" tab for the driver who completed the earlier delivery.
- Click "View Photo" and "View Signature" in the timeline item.
- CSV Report: Click "📥 Download Report" in the header. Open the CSV and verify it contains all stop details and links to the POD photos.
Goal: Verify the automated nightly learning cycle and the manual parameter updates.
- Check Scheduled Task:
- Upon starting the API (via
docker-compose logs -f optimizer_api), you should see a log entry:Data Model scheduled to run in XX.XX hours.confirming the nightly task is queued.
- Upon starting the API (via
- Manual Trigger:
- You can force the "Learning Phase" to run immediately without waiting for midnight using the admin endpoint:
Invoke-RestMethod -Method Post -Uri "http://localhost/api/admin/run-data-model"
- Verify Parameter Update:
- Check the
driverstable or the system logs. If historical performance was seeded in Step 6, the manual trigger will update themax_jobs_per_dayparameter for drivers based on their efficiency scores.
- Check the