A high-performance, scalable delivery route optimization system built with Java + Quarkus, implementing advanced algorithms for real-time driver assignment and route optimization.
- Order Management: Place, track, and manage delivery orders with pickup/delivery locations
- Driver Assignment: Intelligent driver-to-order matching using distance, capacity, and availability
- Route Optimization: Real-time route calculation using Dijkstra's and A* algorithms
- Live Tracking: WebSocket-based real-time location tracking for drivers and orders
- Priority Queue: Smart order prioritization based on urgency, time, and special requirements
- Graph-based Pathfinding: Efficient shortest path algorithms (Dijkstra, A*)
- Spatial Indexing: Geohash-based location indexing for fast proximity searches
- Load Balancing: Intelligent driver load distribution and capacity management
- Dynamic Re-routing: Real-time route recalculation for traffic and new orders
- Backend: Java 17 + Quarkus 3.6.3
- Database: PostgreSQL with spatial queries
- Cache: Redis for fast lookups and session management
- Real-time: WebSocket for live tracking
- Containerization: Docker + Docker Compose
- Monitoring: Prometheus + Grafana
traqroute-backend/
βββ src/
β βββ main/
β β βββ java/com/traqroute/
β β β βββ api/ # REST API Resources
β β β βββ domain/ # Business Models & Entities
β β β βββ service/ # CDI Services
β β β βββ persistence/ # JPA Repositories
β β β βββ algorithms/ # DSA: Graphs, Pathfinding
β β β βββ queue/ # Redis Queue Handlers
β β β βββ cache/ # In-Memory/Redis Cache
β β β βββ websocket/ # WebSocket Real-Time
β β β βββ utils/ # Utilities
β β βββ resources/
β β β βββ META-INF/
β β β β βββ persistence.xml # JPA Configuration
β β β βββ application.yaml # Quarkus Config
β β βββ Dockerfile # Backend Container
β βββ test/ # Unit & Integration Tests
βββ docker-compose.yaml # Local Development Setup
βββ README.md
βββ system-design.md # System Design Document
- Java 17 or higher
- Maven 3.8+
- Docker & Docker Compose
- Git
-
Clone the repository
git clone https://github.com/yourusername/traqroute-backend.git cd traqroute-backend -
Start the infrastructure
docker-compose up -d postgres redis
-
Run the application
# Development mode ./mvnw quarkus:dev # Or build and run ./mvnw clean package java -jar target/quarkus-app/quarkus-run.jar
-
Access the application
- API: http://localhost:8080
- OpenAPI Docs: http://localhost:8080/openapi
- Health Check: http://localhost:8080/health
# Start all services including monitoring tools
docker-compose --profile tools --profile monitoring up -d
# Access additional tools:
# - pgAdmin: http://localhost:5050 (admin@traqroute.com / admin123)
# - Redis Commander: http://localhost:8081
# - Prometheus: http://localhost:9090
# - Grafana: http://localhost:3000 (admin / admin123)POST /api/orders # Create new order
GET /api/orders # List all orders
GET /api/orders/{id} # Get order details
PUT /api/orders/{id}/status # Update order status
DELETE /api/orders/{id} # Cancel orderPOST /api/drivers # Register driver
GET /api/drivers # List all drivers
GET /api/drivers/{id} # Get driver details
PUT /api/drivers/{id}/location # Update driver location
PUT /api/drivers/{id}/status # Update driver statusPOST /api/routes # Create optimized route
GET /api/routes # List all routes
GET /api/routes/{id} # Get route details
PUT /api/routes/{id}/optimize # Re-optimize routeGET /api/tracking/orders/{id} # Get order tracking info
GET /api/tracking/drivers/{id} # Get driver tracking info
WS /ws/tracking # WebSocket for real-time updatescurl -X POST http://localhost:8080/api/orders \
-H "Content-Type: application/json" \
-d '{
"customerName": "John Doe",
"customerPhone": "+1234567890",
"pickupLocation": {
"latitude": 40.7128,
"longitude": -74.0060,
"address": "123 Main St, New York, NY"
},
"deliveryLocation": {
"latitude": 40.7589,
"longitude": -73.9851,
"address": "456 Broadway, New York, NY"
},
"priority": 2,
"specialInstructions": "Fragile items"
}'curl -X POST http://localhost:8080/api/drivers \
-H "Content-Type: application/json" \
-d '{
"name": "Alice Johnson",
"email": "alice@traqroute.com",
"phone": "+1987654321",
"vehicleType": "Van",
"licensePlate": "ABC123",
"currentLocation": {
"latitude": 40.7505,
"longitude": -73.9934,
"address": "789 5th Ave, New York, NY"
}
}'# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=traqroute
DB_USERNAME=traqroute
DB_PASSWORD=traqroute123
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
# Application
QUARKUS_PROFILE=dev
JAVA_OPTS=-Xmx1g -Xms512m# Unit tests
./mvnw test
# Integration tests
./mvnw verify
# Test coverage
./mvnw jacoco:report