A comprehensive parking management system built with Spring Boot, featuring microservices architecture, Redis caching, Kafka event streaming, and JWT authentication.
The system is designed as a modular monolith that can be easily split into microservices:
- Auth Module: User management and JWT authentication
- Lot Module: Parking lot, level, and slot management
- Ticket Module: Entry/exit flow and slot allocation
- Billing Module: Tariff calculation and invoice generation
- Common Module: Shared DTOs, events, and utilities
- Infra Module: Redis, Kafka, and database configurations
- Backend: Spring Boot 3.2.0, Java 17
- Database: MySQL 8
- Cache: Redis 7
- Message Queue: Apache Kafka with Zookeeper
- Security: Spring Security with JWT
- Build Tool: Maven
- Java 17
- Docker Desktop
- IntelliJ IDEA (recommended)
docker-compose up -dThis will start:
- MySQL on port 3306
- Redis on port 6379
- Kafka on port 9092
- Zookeeper on port 2181
mvn spring-boot:runThe application will start on port 8080.
The system initializes with these default users:
- Admin:
admin/admin123 - Attendant:
attendant1/attendant123 - User:
user1/user123
# Login
POST /api/auth/login
{
"username": "admin",
"password": "admin123"
}
# Register new user
POST /api/auth/register
{
"username": "newuser",
"password": "password123"
}# Create parking lot
POST /api/lots
{
"name": "Mall Parking",
"address": "456 Shopping Ave"
}
# Get all lots
GET /api/lots
# Get specific lot
GET /api/lots/{id}
# Create level
POST /api/lots/{id}/levels
{
"levelNo": 1
}
# Create slots
POST /api/levels/{id}/slots
{
"type": "CAR",
"codes": ["A1", "A2", "A3"]
}
# Check availability
GET /api/lots/{id}/availability?type=CAR# Vehicle entry
POST /api/entry
{
"lotId": 1,
"plateNo": "ABC123",
"vehicleType": "CAR"
}
# Vehicle exit
POST /api/exit
{
"identifier": "ABC123" // or ticket ID
}# Get invoices for ticket
GET /api/invoices/{ticketId}
# Process payment
POST /api/pay/{invoiceId}curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}'Save the JWT token from the response.
curl -X GET "http://localhost:8080/api/lots/1/availability?type=CAR" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"curl -X POST http://localhost:8080/api/entry \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"lotId":1,"plateNo":"XYZ789","vehicleType":"CAR"}'curl -X POST http://localhost:8080/api/exit \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"identifier":"XYZ789"}'curl -X GET http://localhost:8080/api/invoices/{ticketId} \
-H "Authorization: Bearer YOUR_JWT_TOKEN"- Redis-First Approach: Checks Redis cache for free slots
- Database Fallback: Queries MySQL if Redis cache is empty
- Atomic Operations: Uses transactions to ensure consistency
- Real-time Counters: Maintains free slot counts in Redis
The system publishes events for:
parking.entry: Vehicle enteredparking.exit: Vehicle exitedslot.updated: Slot status changedbilling.invoice.created: Invoice generatedpayment.completed: Payment processed
Default pricing structure:
- Base: $5.00 for first 60 minutes
- Additional: $2.00 per 30-minute increment
- EV Surcharge: $1.00 additional for electric vehicles
- JWT-based authentication
- Role-based access control (ADMIN, ATTENDANT, USER)
- Password encryption with BCrypt
slot:{slotId} → HASH {status, type, levelId, lotId}
lot:{lotId}:free:{type} → INTEGER counter
lot:{lotId}:freeSlots:{type} → SET of slot IDs
vehicle:openTicket:{plate} → ticketId
ticket:summary:{ticketId} → HASH {slotId, lotId, entryTime, plate}
parking.entryparking.exitslot.updatedbilling.invoice.createdpayment.completed
parking_lots: Parking lot informationlevels: Parking levels within lotsslots: Individual parking slotsvehicles: Vehicle informationtickets: Parking ticketsinvoices: Billing invoicesusers: System userstariff_rules: Pricing configuration
- Microservices Split: Separate into Auth, Parking, and Billing services
- API Gateway: Add Zuul or Spring Cloud Gateway
- Monitoring: Integrate with Prometheus and Grafana
- Notifications: Add SMS/email notifications
- Mobile App: React Native mobile application
- Analytics: Parking usage analytics and reporting
- Port Conflicts: Ensure ports 3306, 6379, 9092, 2181 are available
- Docker Issues: Run
docker-compose downanddocker-compose up -dto restart - Database Connection: Wait for MySQL to fully start before running the application
- Kafka Topics: Topics are auto-created, but you can manually create them if needed
Check application logs for detailed error messages:
tail -f logs/application.logsrc/main/java/com/park/
├── auth/ # Authentication and security
├── lot/ # Parking lot management
├── ticket/ # Entry/exit operations
├── billing/ # Billing and invoicing
├── vehicle/ # Vehicle management
├── common/ # Shared DTOs and events
└── infra/ # Infrastructure configuration
- Create entity classes in appropriate module
- Add repository interfaces
- Implement service layer
- Create REST controllers
- Add security configuration if needed
- Update data initialization if required
This project is for educational purposes. Feel free to use and modify as needed.