Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data β all from the browser, and deployed in milliseconds.
A full bus ticketing platform for Kenya β search routes, pick seats, enter passenger details, pay with M-Pesa, and receive an e-ticket with QR code.
Live site: https://weruuweruy--84cb9d9e812211f191c21607ee4eb77e.web.val.run
Rendering mermaid diagram...
| File | Purpose |
|---|---|
main.ts | HTTP server β API routes + serves the frontend |
frontend/index.html | Single-page app shell (home, results, seat map, checkout, ticket, lookup) |
frontend/style.css | Navy + gold luxury theme, mobile-first |
frontend/app.js | Client logic β search, seat selection, hold timer, booking |
cron/release-seats.ts | Releases expired seat holds (every 15 min; holds also self-expire via held_until checks on every read) |
seed_seats.ts | Utility β generates seat rows for new trips |
GET /api/locationsβ town list for autocompleteGET /api/search?from=&to=&date=β trips with live seats-left countsGET /api/trips/:id/seatsβ seat map with statusesPOST /api/holdβ atomically hold seats for 8 minutes (concurrency-safe)POST /api/bookβ validate hold β create booking, payment, ticketGET /api/booking/:refβ ticket lookup by booking or ticket ref
routes, pickup_points, buses (with seat layout 2-2 / 2-1), trips, seats (per-trip, with held_until for concurrency), bookings, payments, tickets, promo_codes, users, company_settings.
Checkout currently records payments in demo mode (booking confirms instantly, no money moves). To take real M-Pesa payments, integrate Safaricom Daraja or an aggregator (Pesapal/Flutterwave) and store keys as environment variables β the /api/book handler has a marked section to swap in the STK push + webhook confirmation.
- Admin panel (routes, buses, trips, bookings, settings)
- Conductor QR check-in view
- Real M-Pesa STK push + payment webhook
- SMS/WhatsApp ticket delivery