Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

🅿️ Smart Parking Slot Booking API

A production-style REST API backend for managing parking lots, slot booking, vehicle check-in/check-out, fare calculation, and revenue reporting.

Built with Java 17 + Spring Boot 3 + MySQL.


🛠️ Tech Stack

Layer Technology
Language Java 17
Framework Spring Boot 3.2
ORM Hibernate + Spring Data JPA
Database MySQL 8
Build Tool Maven
API Testing Postman

✨ Features

  • Create and manage parking lots and slots
  • Vehicle check-in with automatic slot assignment
  • Vehicle check-out with fare calculation (rounded up per hour)
  • Different rates for two-wheelers (₹20/hr) and four-wheelers (₹40/hr)
  • Payment recording (Cash / Card / UPI)
  • Real-time slot availability checking
  • Admin daily revenue report
  • Global exception handling with meaningful HTTP status codes
  • Full transactional integrity — slot and booking always in sync

🗄️ Database Schema

parking_lots    → lot details (name, location, capacity)
parking_slots   → individual slots per lot (type, status)
vehicles        → registered vehicles (number plate, type)
bookings        → check-in/check-out records with fare
payments        → payment per completed booking

🚀 Getting Started

Prerequisites

  • Java 17
  • MySQL 8
  • Maven

Setup

  1. Clone the repository
git clone https://github.com/YOUR_USERNAME/parking-management.git
cd parking-management
  1. Create the database
CREATE DATABASE parking_db;
  1. Update src/main/resources/application.properties
spring.datasource.username=root
spring.datasource.password=YOUR_PASSWORD
  1. Run the application
mvn spring-boot:run

API is available at http://localhost:8080


📡 API Endpoints

Parking Lots

Method Endpoint Description
POST /api/lots Create a parking lot
GET /api/lots Get all lots
GET /api/lots/{id} Get lot by ID

Parking Slots

Method Endpoint Description
POST /api/slots Add a slot to a lot
GET /api/slots/availability?lotId=&vehicleType= Check available slots

Bookings

Method Endpoint Description
POST /api/bookings/checkin Vehicle check-in
POST /api/bookings/checkout Vehicle check-out + payment

Admin

Method Endpoint Description
GET /api/admin/revenue?date= Daily revenue report

💡 Key Technical Decisions

@Transactional on check-in and check-out — slot status and booking record are always updated atomically. If anything fails, both roll back together.

Fare rounding — duration is rounded up to the next full hour using Math.ceil(). 1hr 10min = 2 hours billed. Matches real-world parking behavior.

DTO separation — entities are never exposed directly from controllers. Request and response shapes are fully decoupled from the database model.

Global exception handling — every known failure returns a structured JSON error with the correct HTTP status code (400, 404, 409) instead of a raw 500.


🔮 Future Enhancements

  • JWT authentication (admin vs user roles)
  • Monthly revenue reports
  • Pre-booking / slot reservation in advance
  • Docker containerization
  • Kafka event publishing on check-in/check-out
  • Redis caching for slot availability

👨‍💻 Author

Pranav — Third Year IT Student
GitHub | LinkedIn

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages