High-performance geo-fence violation detection for scooter fleet management. Process thousands of GPS events per second with sub-millisecond response times.
A production-ready geo-fencing engine designed to detect when scooters enter restricted no-parking zones in real-time using advanced spatial algorithms and caching strategies.
Sub-millisecond violation detection with Redis caching and in-memory spatial queries using JTS.
Live GPS data streaming with STOMP protocol for real-time event processing and alerts.
Advanced geometric operations with PostgreSQL PostGIS extension and GiST indexes.
10-50x performance improvement using cache-aside pattern with automatic fallback.
Intelligent duplicate violation prevention with configurable time windows.
Docker Compose setup, health checks, metrics, and comprehensive test coverage.
docker-compose up -d postgres redis
mvn spring-boot:run
curl -X POST http://localhost:8080/api/geofencing/check \
-H "Content-Type: application/json" \
-d '{
"scooterId": "SC-001",
"latitude": 37.7800,
"longitude": -122.4150,
"timestamp": "2024-01-01T12:00:00Z"
}'
http://localhost:8080/swagger-ui.html
The API provides both REST and WebSocket endpoints for real-time geo-fence violation detection.
Check if a GPS coordinate violates any no-parking zones.
{
"scooterId": "SC-001",
"latitude": 37.7800,
"longitude": -122.4150,
"timestamp": "2024-01-01T12:00:00Z"
}
{
"status": "VIOLATION",
"message": "Zone violation detected!",
"scooterId": "SC-001",
"violations": [{
"violationId": "VIO-123",
"zoneName": "Downtown SF",
"severity": "HIGH",
"timestamp": "2024-01-01T12:00:00Z"
}]
}
Get all active no-parking zones.
Get Redis cache statistics and health metrics.
Get violation history for a specific scooter.
For complete API documentation with interactive testing, run the application locally and visit the Swagger UI at http://localhost:8080/swagger-ui.html
The system uses a cache-aside pattern with automatic fallback to ensure high performance and reliability:
Modern Java with records, text blocks, and pattern matching
REST API, WebSocket, JPA, and actuator metrics
Spatial database with GiST indexes for O(log n) queries
In-memory caching for 50x performance improvement
In-memory geometric operations and spatial analysis
Containerized development environment