Parking Lot Server

In this project, we’ll build a server that will help a parking attendant admit a new car into the lot if slots are available, mark a slot as empty when a car exits the lot, and search all cars currently admitted to the lot by different attributes—such as model name, color of body, and license plate number—to assist law enforcement if required.

The parking lot has a maximum capacity of 20 slots.
Sample input car JSON:

{
"model": "Chevrolet camaro",
"colour": "red",
"license_number": "XYZ123"
}

Advised stages of writing the project:

  • Start building a very basic server. Reuse some of the code from the course, but it is recommended to write it out from scratch. This will help reinforce the lessons and build muscle memory in the initial learning stages.

  • Once the server is ready to listen and serve, make sure to keep running and testing the code! We already know how to use the curl commands, so make sure to leverage them fully. For the time being, add a simple route that returns “Hello world!” to test that the server is running as expected.

  • Now, focus on setting up the appropriate structs/interfaces and methods to be able to store information regarding a car and the parking lot. All data will be stored in simple in-memory objects. Make sure to add all relevant CRUD functionality, such as creating a new car object, adding a car to the parking lot, removing a car from the parking lot, etc. Please feel free to test the functionality by calling these functions directly in the main function.

  • With the core data structures in place, start building the APIs we would need to provide the desired functionalities.

Required functionalities detailed:

  • Admit a new car into the lot if slots are available. Capture and store all relevant information regarding the car (model, color, and license plate number). If no slots are available, simply deny entry by returning with a 400 status code.

  • Mark a slot as empty when a car exits the lot.

  • Search all cars currently admitted to the lot by the following attributes to assist law enforcement if required:

    • The model name

    • The color of the car

    • The license plate number

The parking lot has a maximum capacity of 20 slots.

Expected responses

  • Expected API response when admitting a car: Status: 200, Body: { "slot": 2 }.

  • Expected API response when rejecting a car because the lot is full: Status: 400, Body: empty.

  • Expected API response when a car being searched for is found: Status: 200, Body: [ { "slot": 2, "model": "Camaro", "color": "red", "license": "ABC123" }, {...} ].

  • Expected API response when no car matches passed search parameters: Status: 404, Body: empty.