All projects
2026Solo project

DaiGo

Commute sharing with relay matching, built for students and office-goers

Live · backend complete, frontend routes nearly done

Next.jsTypeScriptPostgreSQL + PostGISPrismaUpstash RedisQStashWebSocketsRedux ToolkitMapLibreAWS S3

Video walkthrough coming soon

DaiGo is a commute-sharing platform for students and office-goers, closer to BlaBlaCar than Uber. A rider posts where they are going; the app pushes the request to people who already drive that way, by bike, car, auto or cab. The price is shown before the ride with a plain breakdown, and when no single driver covers the whole trip, DaiGo chains two drivers into a relay with one handover. It is live at daigo.dipsharma.me, built for three mapped regions, with affordability as the main goal.

The project started as an answer to one question: what makes a system hard to build, rather than just full of features? Most student projects follow the same shapes, a CRUD app with auth or a chat app. DaiGo is a two-sided marketplace with cold-start dynamics, adversarial trust behavior, pricing correctness constraints, geospatial matching and safety-critical design, so every piece maps to a real systems-design problem.

Cold start was the first hard problem. A marketplace with no drivers has no value for riders, and the reverse is just as true. The answer was circles: college and office email domains get matched to each other first, before the platform opens to the public. A notify-me waitlist catches requests that expire unmatched, and a referral system tied to a coin economy encourages organic growth.

Matching is geospatial. Route overlap within a detour limit, plus a suggested meeting point, runs as raw PostGIS queries because Prisma can't express them. When no single driver fits, a second PostGIS query searches a 3 km radius around the midpoint to chain two drivers through a walkable transfer point. The trip only commits when both drivers accept, in a single transaction, and the price is the same as a direct match.

Concurrency was the second hard problem. When a request reaches several drivers, the first to accept wins, with a 75-second window enforced on the server and the countdown shown per second on the client. Simultaneous accepts are serialized inside database transactions, so they can't race. Events travel through Redis pub/sub to WebSocket clients, with a polling fallback so the app still works if the connection drops. Once a driver is matched, a 5-minute offer window lets driver and rider settle the price before the trip locks.

The pricing engine has a correctness constraint most systems miss. Base rates run from 7 to 40 rupees per km by vehicle type, then pick up a per-zone multiplier (about 100 grid zones), time-of-day bands, weather input and a demand multiplier with a high/low threshold instead of a fixed ratio. Two hard caps apply, a per-km ceiling and an absolute ceiling. Calculations use raw float precision, but the final price is rounded to a whole rupee, and the caps are checked against the rounded value so a rounded price can never land just over a cap.

The backend was designed for failure, not just the happy path. Risky POST routes go through an idempotency wrapper, so a retry after a dropped connection replays the first successful response instead of creating a duplicate transaction. Cancellations release seats atomically, refresh tokens rotate with revocation, and JWTs are revocable so a suspended user can't keep using a token until it expires. Uploads go directly to S3 through presigned URLs, and QStash runs exports and alerts in the background instead of blocking requests.

Trust and safety were treated as first-class features. A trust score is cached on the user row and recalculated asynchronously, ratings run both ways, and five warnings lead to suspension with an appeal flow. An emergency contact is required at signup, the emergency button alerts admins live, and names, photos and phone numbers only appear as a trip gets close.

To let a reviewer see all of this without clicking through the app, there is a demo console for moderators. One trigger runs a 1,000-request simulation or fires 100 parallel accepts at exactly one trip and shows the numbers. The interface is localized in English, Nepali and Hindi and built without a heavy component library, including a custom slide-to-confirm booking control, six-box OTP inputs and a lazy-loaded MapLibre map that follows the system theme.

The backend is complete and the frontend routes are nearly done. Payments are still a mock gateway, licence checks are demo-level, and the map covers three regions, all listed under known limits. The value of the project isn't the feature list, it's that every piece required reasoning about a real systems-design problem.

Key features

Push-based matching

Requests go to people already travelling the route, with a detour limit and a suggested meeting point from raw PostGIS queries

Relay matching

No single driver covers the trip? Two drivers are chained through a walkable transfer point, and the trip only commits when both accept, in one transaction

First-accept-wins

A 75-second accept window enforced on the server, with concurrent accepts serialized inside database transactions so two drivers can never both win

Idempotent writes

A wrapper on risky POST routes replays the first successful response on a retry, so a flaky network can't double-charge or double-complete a trip

Transparent pricing

Zone, time-of-day, weather and demand multipliers, two hard caps checked against the rounded rupee value, and the full breakdown shown before the ride

Cold-start circles

College and office email domains get matched first, backed by a notify-me waitlist and a coin-based referral system

Safety layer

A mandatory emergency contact, a one-tap alert that reaches admins live, and distance-gated visibility of names, photos and phone numbers

Demo console

One trigger runs a 1,000-request simulation or 100 parallel accepts on a single trip, so the backend can be inspected without clicking through it

Architecture

  • Four strict layers: thin Next.js route handlers, centralized Zod validation with human-readable error messages, a service layer for business logic and transactions, and a repository layer that holds every Prisma and SQL call
  • PostgreSQL with PostGIS through Prisma: 28 tables, UUID ids generated by pgcrypto, strict enums, and soft deletes for users and trips so audit data survives without breaking foreign keys
  • Geo queries are raw SQL through $queryRaw because Prisma has no PostGIS support, and the extension is declared first so the template defaults can't conflict with it
  • Upstash Redis handles rate limits, live events and chat (cleared once the trip is rated), while QStash runs heavy exports and alerts in the background
  • Licence, RC and profile photos go straight to AWS S3 through short-lived presigned URLs, so large files never touch backend memory
  • Redux Toolkit with RTK Query handles client state, caching and optimistic updates, and next-intl serves English, Nepali and Hindi

Engineering problems solved

  • Race conditions: simultaneous driver accepts are serialized inside database transactions, with the 75-second expiry enforced server-side
  • Duplicate transactions: an idempotency wrapper replays the first successful response when a client retries, and driver auto-accept uses the same keys to prevent double booking
  • Payment integrity: online payments auto-mark paid (mock gateway for now), cash needs the driver's completion photo, and any mismatch lands in an admin complaint queue
  • Webhook verification on the Razorpay mock gateway, so the payment flow already has the shape of the real integration
  • Atomic cancellation: the seat is released back to the route and the request resets to pending so it can be matched again
  • Real-time resilience: events flow through Redis pub/sub to WebSocket clients, and if the socket drops, the client falls back to polling
  • Cold start: circles match college and office email domains first, before the platform opens to the public

Safety and trust

  • One mandatory emergency contact at signup; the emergency button grabs a one-time location, emails the contact through Brevo and pushes a live alert to the admin dashboard with the phone number hidden for rescue
  • Drivers see only a rider's first name until they're within 10 km, the driver's photo appears within 3 km, and phone numbers stay hidden until close
  • Vulnerable-rider requests get top priority with top-rated drivers, and unaccompanied minors need a guardian booking, live tracking and high-trust drivers only
  • A trust score cached on the user row and recalculated asynchronously, two-way ratings, and 5 warnings leading to suspension with an appeal flow
  • Roles for super admin, admin, moderator, rider and driver, with extra email verification for the super admin on every login

Known limits

  • Payments run on a mock gateway for now, with Razorpay planned
  • Licence and RC checks are demo-level, not real government ID verification
  • Location sharing is manual, and the 15-hour driver fatigue cap can't be enforced in practice
  • Trust-farming only has a rate cap on score gains, documented as a known limitation
  • WebSockets aren't supported on Vercel yet, so polling is the fallback for now
  • Mapped for three regions only