Browser-based dashboard for Preet and Himmat. Opens on any device — desktop at the office, phone at the counter, tablet anywhere. Live map shows both trucks. Stops mark themselves green or red as deliveries complete or fail. Refresh every 15 seconds. Same backend as the bot and driver app — three apps, one Worker.
Top: tabs (Live · Exceptions · Report) and the auto-refresh status. Stats bar: today's totals at a glance. Main split: live map (left) + scrollable route lists per branch (right). Click any stop on either side to see customer, order, and call/navigate buttons in a slide-in drawer.
All three apps share the same Cloudflare Worker (~3,500 lines). Different audiences, different surfaces, same source of truth.
Customer DMs the FB page. Bot quotes a tire+rim package or a single part in 60 seconds. Stripe pay link. Dispatched to a driver's truck for delivery.
10" tablet mounted in each truck. PIN login. Today's route loads at 8am, works offline in dead zones, syncs deliveries when signal returns. Photo + signature optional.
Browser PWA. Live map of both trucks, stop status, exception inbox, end-of-day report with CSV export. 15-second auto-refresh. Same admin PINs as the driver app.
Drivers' tablets ping their GPS every 60 seconds while online. Each delivery completion writes a server event. The dashboard polls one aggregating endpoint every 15 seconds and gets all of it back as a single JSON payload.
Worker stays at one project. Drivers gain a role field ('driver' | 'admin'). Two new endpoints added to the existing router. Admin-only access to the dispatch view; admin PINs same flow as drivers.
Driver tablet sends GPS ping every 60s. Server writes to R2 at driver-locations/{date}/{driver_id}.json, overwriting each time. Most recent ping per branch is what dispatch sees.
Aggregates today's full state for both branches: routes joined to delivery events, latest driver locations, computed totals (revenue, completed/pending/exceptions), exception inbox cross-cut. One endpoint serves the entire dashboard.
async function buildBranchStatus(env, date, branch): Promise<BranchStatus> {
// Load route, delivery events (parallel), and latest location
const routeKey = `deliveries/${date}/${branch}.json`;
const routeObj = await env.CATALOG_BUCKET.get(routeKey);
const route = routeObj ? await routeObj.json() : { stops: [] };
const events = await Promise.all(
route.stops.map(async stop => {
const obj = await env.CATALOG_BUCKET.get(`delivery-events/${date}/${stop.order_id}.json`);
return obj ? await obj.json() : null;
}),
);
// Find latest location ping for this branch
const locList = await env.CATALOG_BUCKET.list({ prefix: `driver-locations/${date}/` });
let location = null;
for (const obj of locList.objects) {
const loc = await (await env.CATALOG_BUCKET.get(obj.key))?.json();
if (loc?.branch === branch && (!location || loc.received_at > location.received_at)) {
location = loc;
}
}
// Combine + compute totals
const stops = route.stops.map((stop, i) => ({
...stop,
status: events[i]?.status ?? 'pending',
event: events[i] ?? undefined,
}));
return {
branch, location, stops,
driver_id: location?.driver_id ?? null,
driver_name: location ? findDriverById(location.driver_id)?.name ?? null : null,
totals: computeTotals(stops),
};
}
After 30 turns in this thread, you have a complete operational system. Customer-facing bot books deliveries. Driver tablets execute them. Dispatch dashboard supervises in real-time. All three sit on top of one Cloudflare Worker that costs $0/mo on the free tier.
All endpoints · catalog generator · auth · 31 files
Offline-first · 5 screens · IndexedDB queue · location pings
Live map · 4 screens · 15s polling · CSV export
v2 spec · F-150 walkthrough · Worker code · catalog generator · test suite · driver app · this