Skip to content

anoopcodehack/Smart-Parking-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ…ΏοΈ Smart Parking Lot API A scalable RESTful backend system for managing parking lots with automated slot allocation, real-time availability tracking, vehicle lifecycle management, and complete parking history. Built with clean architecture and production-ready practices.

πŸš€ Tech Stack LayerTechnologyRuntimeNode.jsFrameworkExpress.jsDatabaseMongoDBODMMongooseEnvironment ConfigdotenvDevelopmentnodemon

smart-parking/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ server.js β”‚ β”œβ”€β”€ app.js β”‚ β”œβ”€β”€ config/ β”‚ β”‚ └── db.js β”‚ β”œβ”€β”€ models/ β”‚ β”œβ”€β”€ controllers/ β”‚ β”œβ”€β”€ routes/ β”‚ β”œβ”€β”€ middleware/ β”‚ └── utils/ β”œβ”€β”€ .env β”œβ”€β”€ .env.example β”œβ”€β”€ package.json └── README.md

βš™οΈ Setup

  1. Clone the repository bashgit clone https://github.com/your-username/smart-parking-api.git cd smart-parking-api
  2. Install dependencies bashnpm install
  3. Configure environment bashcp .env.example .env Edit .env with your values: envPORT=3000 MONGODB_URI=mongodb://localhost:27017/smart_parking NODE_ENV=development
  4. Run the server bashnpm run dev # Development (with nodemon) npm start # Production

πŸ“‘ API Overview Base URL: http://localhost:3000/api πŸ”² Slots MethodEndpointDescriptionPOST/slots/initializeInitialize the parking lotGET/slotsView all slots (with filters)DELETE/slots/resetReset the entire system πŸš— Vehicles MethodEndpointDescriptionPOST/vehicles/entryVehicle entry β€” auto slot assignmentPOST/vehicles/exitVehicle exit β€” duration calculationGET/vehiclesView all currently parked vehiclesGET/vehicles/search?plate=Search by number plate πŸ“‹ History MethodEndpointDescriptionGET/historyFull parking historyGET/history?status=Filter by statusGET/history?plate=Filter by number plateGET/history?page=&limit=Paginated results

✨ Key Features

Smart Slot Allocation β€” Automatically assigns the nearest available slot Duplicate Prevention β€” Blocks re-entry of an already-parked vehicle Duration Tracking β€” Accurate parking time calculation on exit Advanced Filtering β€” Search and filter across slots, vehicles, and history Pagination β€” Efficient handling of large datasets Consistent Responses β€” Uniform API response structure throughout Indexed Queries β€” MongoDB indexes for high-performance lookups

πŸ“Š Data Models ParkingSlot js{ slotNumber: Number, isOccupied: Boolean, vehicleNumberPlate: String, entryTime: Date } ParkingHistory js{ vehicleNumberPlate: String, slotNumber: Number, entryTime: Date, exitTime: Date, durationMinutes: Number, status: "PARKED" | "EXITED" }

πŸ§ͺ Testing Flow

Initialize the parking lot with slots Park one or more vehicles Check currently occupied slots Exit a vehicle Verify the parking history

⚠️ Limitations

No authentication or authorization system No payment or billing logic No real-time updates (WebSocket/SSE) No frontend interface

πŸ“„ License MIT License β€” free to use, modify, and distribute.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors