This project is a small Java backend service that simulates rider
tracking for a logistics platform.
It allows trips to be created, accepts rider location updates,
calculates total distance travelled, provides a simple ETA, and enforces
valid trip state transitions.
- Java 17+
- Maven
./mvnw spring-boot:runThe application runs on:
http://localhost:8080
POST /api/v1/trip
Response:
{
"tripId": "uuid"
}POST /api/v1/trip/{id}/location
Request body:
{
"latitude": 6.5244,
"longitude": 3.3792
}GET /api/v1/trip/{id}
Returns the current trip state and tracking information.
POST /api/v1/trip/{id}/complete
After completion, no further updates are allowed.
Trips follow a strict lifecycle:
CREATED → IN_PROGRESS → COMPLETED
- Location updates are only allowed while a trip is in progress
- Completed trips are immutable
All state rules are enforced at the domain level.
Distance is calculated incrementally using consecutive GPS coordinates.
Assumptions: - Straight-line distance between points - No road or traffic data - Accuracy is not the primary goal
ETA is estimated using average speed based on distance travelled over time.
Assumptions: - No traffic consideration - ETA is approximate, not exact
404 Not Foundfor unknown trips400 Bad Requestfor invalid trip actions
Errors are returned in a consistent JSON format.
Tests cover core behavior such as: - Trip creation - Distance updates - Trip completion - Invalid state transitions