A real-time GraphQL API for tracking transit information, built with Spring Boot and Kafka.
- GraphQL API: Query for trips, vehicles, and stop times.
- Real-time Updates: Subscribe to live trip updates via GraphQL Subscriptions (WebSockets).
- Kafka Integration: Publishes and consumes GTFS Realtime data using Kafka.
- Automatic Polling: Fetches data from the GTFS Realtime feed every 30 seconds.
- Filtering: Filter trips by
routeIdandvehicleId.
- Java 21 or higher
- Docker & Docker Compose (for Kafka)
Start the Kafka and Zookeeper containers:
docker-compose up -d # If you do not want to see logs
docker-compose up # If you want to see logsStart the Spring Boot server:
./gradlew bootRunThe server will start on http://localhost:8080.
Open the custom GraphiQL interface in your browser:
http://localhost:8080/graphiql.html
Get all trips:
query {
trips {
tripId
routeId
vehicle {
id
label
}
}
}Filter trips by Route and Vehicle:
query {
trips(routeId: "301", vehicleId: "21501") {
tripId
routeId
vehicle {
label
}
}
}Subscribe to all updates:
subscription {
feedUpdates {
timestamp
trips {
tripId
stopTimeUpdates {
stopSequence
arrival {
delay
}
}
}
}
}Subscribe to updates for a specific route:
subscription {
feedUpdates(routeId: "301") {
timestamp
trips {
tripId
vehicle {
label
}
}
}
}To run with hot reloading (automatically restarts on file changes):
./gradlew bootRun --continuous