{"id":19723959,"url":"https://github.com/vs4vijay/parkinglotapi","last_synced_at":"2025-04-29T22:31:11.015Z","repository":{"id":37026147,"uuid":"294732580","full_name":"vs4vijay/ParkingLotAPI","owner":"vs4vijay","description":"A RESTful API Microservice for a Parking Lot Management System","archived":false,"fork":false,"pushed_at":"2025-04-27T04:07:58.000Z","size":145,"stargazers_count":4,"open_issues_count":63,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-04-27T05:18:48.855Z","etag":null,"topics":["api","javascript","microservice","mongodb","nodejs","parking-lot","restful-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vs4vijay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-09-11T15:29:15.000Z","updated_at":"2025-03-29T16:11:43.000Z","dependencies_parsed_at":"2023-02-04T16:16:09.103Z","dependency_job_id":"604b27d1-ae6d-4b81-a766-818d89602077","html_url":"https://github.com/vs4vijay/ParkingLotAPI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vs4vijay%2FParkingLotAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vs4vijay%2FParkingLotAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vs4vijay%2FParkingLotAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vs4vijay%2FParkingLotAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vs4vijay","download_url":"https://codeload.github.com/vs4vijay/ParkingLotAPI/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251593007,"owners_count":21614455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","javascript","microservice","mongodb","nodejs","parking-lot","restful-api"],"created_at":"2024-11-11T23:24:04.412Z","updated_at":"2025-04-29T22:31:10.680Z","avatar_url":"https://github.com/vs4vijay.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parking Lot API\n\nA RESTful API Implementation for a Parking Lot Management System\n\n## Data Models\n\n- ParkingSpace\n  - parking_lot_name: \"default\"\n  - spot_no\n  - is_reserved\n  - registraion_no\n- Vehicle\n  - owner_id\n  - registraion_no\n- User\n  - name\n  - can_use_reserved_space\n  - reason_for_reserve\n- Booking\n  - booked_at\n  - registraion_no\n\n### Relationships and Embedding\n\n- ParkingSpace\n- User:\n  - embeds Vehicles\n  - embeds Bookings\n\n---\n\n## Notes\n\n- Used ES6 Wherever possible\n\n---\n\n## APIs\n\n- `/api/v1/parking_lots/init`              - For Initialing System (creates a parking lot with default name)\n- `/api/v1/parking_spaces/search`          - Generic Search API for getting all and occupied parking spaces\n- `/api/v1/users`                          - Returns list of registered Users\n- `/api/v1/users/book`                     - Books a Parking Space\n- `/api/v1/parking_spaces/park`            - Park a Vehicle\n- `/api/v1/parking_spaces/leave`           - Unpark a Vehicle\n\n---\n\n## Assumptions\n- Name of user is unique in a parking lot system\n- Booking is not necessary to park the vehicle, if booking is found then logic works\n\n\n## Features\n- APIs the RESTful in nature, I tried to follow RESTful design as much as possible\n- Accommodated if user has multiple vehicles\n- Have stored metadata like created_at and updated_at\n\n\n## Future Enhancements\n- Can create OpenAPI Specs (or Swagger API Specs)\n- Can use Depedency Injection / IoC\n- We can have a scheduler for cleanup for old bookings\n- API result should be paginated\n- Input Validations\n- Can use TypeScript\n- Handle CORS Headers\n- Use denormalized form to store vehicles inside user document, but we could have separate vehicles decuments as well\n- Can have a generic Exception (`ParkingLotException`) which accomodates all types of failures\n\n---\n\n## Pre-requisites\n\n- NodeJS\n- MongoDB\n\n## Installation\n\n```shell\n# Using npm\nnpm install\n\n# Using yarn\nyarn add\n```\n\n---\n\n## Running\n\n```shell\n# For Local Development\nnpm run dev\n\n# On Production, Use pm2 or docker container\npm2 start src/app.js\n\n# OR\n\nnode src/app.js\n```\n\n---\n\n## Functionality Testing\n\n```shell\n\n# Initialize the Parking Lot System\ncurl localhost:9000/api/v1/parking_lots/init -X POST\n\n# Get All Parking Spaces\ncurl localhost:9000/api/v1/parking_spaces\n\n# Get Occupied Parking Spaces\ncurl localhost:9000/api/v1/parking_spaces\\?filter_by=occupied \n\n# Get All Registered Users\ncurl localhost:9000/api/v1/users\n\n# Create a booking\ncurl localhost:9000/api/v1/users/book -H 'Content-Type: application/json' -d '{\"name\": \"Vijay\", \"registration_no\": \"123\"}'\n\n# Park a Vehicle\ncurl localhost:9000/api/v1/users/park -H 'Content-Type: application/json' -d '{\"name\": \"Vijay\",  \"registration_no\": \"123\"}'\n\n# Unpark a Vehicle\ncurl localhost:9000/api/v1/users/unpark -H 'Content-Type: application/json' -d '{\"registration_no\": \"123\"}'\n\n```\n\n---\n\n### Development Notes\n\n```shell\n\n- ParkingLot\n  - name\n  - capacity\n  - address\n\n\ndb.parking_spaces.update({ '_id': ObjectId('5f579e688d8deb218866c219')}, {'vehicle_id': ObjectId('5f579e688d8deb218866c219')})\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvs4vijay%2Fparkinglotapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvs4vijay%2Fparkinglotapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvs4vijay%2Fparkinglotapi/lists"}