Skip to main content

Design a Ride-Sharing Service

Design a ride-sharing platform with real-time matching, dynamic pricing, GPS tracking, ETA calculations, and driver-rider communication.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
You are a systems architect designing a ride-sharing service similar to Uber operating in 200 cities.

Step 1: Define the core user flows: rider requests a ride (pickup location, destination, ride type), system matches with nearby driver, driver accepts and navigates to pickup, trip tracking with live GPS, payment processing on trip completion, and mutual rating. Non-functional requirements: match a driver within 15 seconds, support 1 million concurrent rides, and GPS update frequency of every 3 seconds.

Step 2: Design the geospatial matching service. Partition each city into 1km x 1km grid cells using S2 geometry or geohash. Maintain a real-time index of available drivers per cell in Redis with geospatial indexes. When a ride request arrives, search the rider's cell and adjacent cells for available drivers. Rank candidates by distance, estimated pickup time, driver rating, and vehicle type. Send the request to the top match with a 15 seconds acceptance timeout before cascading to the next.

Step 3: Implement the dynamic pricing engine (surge pricing). Monitor supply (available drivers per zone) and demand (ride requests per zone) in real-time. When the demand-to-supply ratio exceeds 1.5x, apply a surge multiplier. Cap the maximum surge at 3.0x. Calculate the fare estimate using: base fare + (per-mile rate x distance) + (per-minute rate x duration) x surge multiplier. Show the fare estimate to the rider before confirmation.

Step 4: Design the trip tracking service that ingests GPS coordinates from driver devices at every 3 seconds. Store the trip polyline in Cassandra for post-trip analysis. Broadcast the driver location to the rider client via WebSockets. Calculate and update the ETA using real-time traffic data from Google Maps Platform. Detect trip anomalies (unexpected stops, route deviations) and trigger safety alerts.

Step 5: Architect the payment and settlement system. Pre-authorize the estimated fare on the rider's payment method at trip start. On trip completion, calculate the final fare based on actual distance and duration, charge the rider, and hold the driver's earnings. Run a daily settlement batch that pays drivers minus the 25% platform commission. Handle split fares, promo codes, and cancellation fees.

Step 6: Design for reliability and safety. Implement a trip-sharing feature that lets riders share live trip status with contacts. Build an emergency SOS button that alerts the safety team with trip details and live location. Design the system to handle 500,000 driver location updates per second without data loss, using Apache Kafka for ingestion buffering.

What this prompt does

This prompt makes the AI a systems architect designing a ride-sharing service similar to [reference_platform] operating in [city_count] cities. It covers core flows, a geospatial matching service, a dynamic surge-pricing engine, trip tracking, payment and settlement, and reliability and safety. The matching step partitions each city into [grid_size] cells using S2 or geohash, indexes available drivers in [location_store], and cascades a request to the next driver after an [accept_timeout].

The structure works because real-time matching is a geospatial-plus-queue problem where small early decisions compound. Getting the grid partitioning and the acceptance-timeout cascade right prevents a painful rewrite once concurrency climbs toward [concurrent_rides]. Surge pricing keys off a live demand-to-supply ratio, applying a multiplier above [surge_threshold] and capping at [max_surge], with the fare estimate shown before the rider confirms. Trip tracking ingests GPS at [gps_frequency] through [message_queue] so [driver_count] location updates per second don't get dropped, stores the polyline in [trip_database] for later analysis, and flags anomalies like unexpected stops or route deviations for safety alerts.

When to use it

  • You're scoping a real-time location and matching system before committing infrastructure
  • You need geospatial partitioning and a driver-acceptance cascade designed correctly up front
  • You want a dynamic pricing engine grounded in live supply and demand
  • You're handling high-frequency GPS ingestion without data loss
  • You need ETA calculation from [maps_provider] and trip-anomaly detection wired into tracking
  • You want settlement, commissions, and safety features designed alongside matching
  • You need to match a driver within [match_time] across [city_count] cities

Example output

Expect an architecture document: the rider-to-driver flow, a geospatial matching design with [grid_size] partitioning and ranked candidate selection by distance, pickup time, and rating, a surge-pricing engine with the base-plus-distance-plus-duration fare formula and multiplier caps, a trip-tracking service streaming GPS through [realtime_protocol] with live ETA updates from [maps_provider], a payment and settlement flow with fare pre-authorization, final reconciliation, and the [commission_rate] cut, and a safety section covering trip sharing and an emergency SOS button. It's a reasoned design, not code.

Pro tips

  • Tune [grid_size] to city density; cells too large bloat candidate searches, too small and you miss nearby drivers across boundaries
  • Keep [accept_timeout] short enough that riders aren't left waiting but long enough for drivers to react
  • Set [surge_threshold] and [max_surge] deliberately — uncapped surge is both a UX and a regulatory problem
  • Buffer GPS through [message_queue] before storage; writing [driver_count] updates per second straight to a database will not hold
  • Match [gps_frequency] to your accuracy needs; more frequent updates mean smoother tracking but heavier ingestion
  • Always search adjacent cells, not just the rider's cell, or you'll miss the closest driver sitting one boundary over

Frequently Asked Questions

How does the geospatial matching actually find nearby drivers?
Each city is partitioned into `[grid_size]` cells using S2 geometry or geohash, with available drivers indexed per cell in `[location_store]`. When a request arrives, the system searches the rider's cell and adjacent cells, then ranks candidates by distance, pickup time, rating, and vehicle type before dispatching to the best match.
What happens if the matched driver doesn't accept the ride?
Each offer carries an `[accept_timeout]`. If the top-ranked driver doesn't accept within that window, the request cascades to the next candidate, and so on. This keeps match times near the target instead of stalling on an unresponsive driver.
How is surge pricing calculated in this design?
The engine monitors the demand-to-supply ratio per zone in real time. When that ratio exceeds `[surge_threshold]` it applies a multiplier, capped at `[max_surge]`, to the base fare plus per-mile and per-minute charges. The estimate is shown to the rider before they confirm the trip.
Can the system handle the GPS volume from all active drivers?
It's designed to. Driver devices emit coordinates at `[gps_frequency]`, and those updates are buffered through `[message_queue]` before storage so spikes don't cause data loss. The trip polyline lands in `[trip_database]` for later analysis while live location streams to the rider.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in System Design Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support