an event-driven ride-hailing simulation built with java, spring boot, and kafka.
- request: a rider creates a trip via the trips-service.
- events: a
TripRequestedevent is pushed to kafka. - pricing: the pricing-service calculates zone demand in real-time.
- analytics: the analytics-service aggregates demand metrics into 1-hour windows and saves them to postgres.
- java 21 & spring boot 3.5
- kafka & kafka streams
- postgres for olatp and analytics
- docker compose for local infra
trips-service: rest api for trip lifecycle (create, complete, retrieve).pricing-service: calculates demand multipliers based on active trips.analytics-service: computes hourly zone metrics using kafka streams.
build the jars:
./mvnw clean package -DskipTests -f common/pom.xml
./mvnw clean package -DskipTests -f services/trips-service/pom.xml
./mvnw clean package -DskipTests -f services/pricing-service/pom.xml
./mvnw clean package -DskipTests -f services/analytics-service/pom.xmlspin up the infrastructure:
cd infra && docker compose up -d --buildverify status:
curl http://localhost:8080/actuator/health
curl http://localhost:8081/actuator/health
curl http://localhost:8082/actuator/healthcreate a trip:
curl -X POST http://localhost:8080/trips \
-H "Content-Type: application/json" \
-d '{"riderID": "rider-123", "pickupZone": "Z12", "dropoffZone": "Z05"}'check status:
curl http://localhost:8080/trips/{trip-id}complete trip:
curl -X POST http://localhost:8080/trips/{trip-id}/completeget pricing for a zone:
curl http://localhost:8081/pricing/zone/Z12view aggregated analytics:
docker exec -it postgres psql -U user -d rides_db \
-c "SELECT * FROM analytics_zone_hourly ORDER BY hour_bucket DESC LIMIT 10;"- ensure ports 8080-8082, 5432, 9092 are free.
- logs:
docker compose logs -f <service-name> - restart:
docker compose restart <service-name>