Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SmartPark

"SmartPark" is a technology company developing an intelligent parking management system for urban areas. The company is aiming to optimize the use of parking spaces and facilitate easy navigation for drivers.


Getting Started

Follow these instructions to set up, build, and run the SmartPark application on your local machine.

Prerequisites

Ensure you have the following installed on your system:

  • JDK 21: This project requires Java 21 (LTS). You can verify your installation by running java -version in your terminal. Set the project's SDK to Java 21. In IntelliJ go to: File > Project Structure > Project Settings > Project > SDK.

  • Postman installed for API testing.

Environment Variable

Move the provided .env file on the root directory


Building the Project

To compile the application and run the tests, navigate to the root directory of the project in your terminal and execute:

./mvnw clean install

Running the Application

You can start the application directly from your IDE or via the command line.

Via IDE (Recommended for Development):

  1. Open the project in your preferred IDE (e.g., IntelliJ IDEA, Eclipse, or VS Code).
  2. Navigate to the main entry point: src/main/java/com/sethdev/smartpark/SmartparkApplication.java
  3. Right-click the file and select Run 'SmartparkApplication'.

Via Command Line:

If you prefer running the application through the command line, use the following command from the project root:

./mvnw spring-boot:run

Running Tests

All service-layer tests are located in src/test/java/com/sethdev/smartpark/service.

Via IDE

  1. Navigate to src/test/java/com/sethdev/smartpark/service
  2. Right click then select Run 'tests' in 'service'

Via Command Line

You can execute the tests using the Maven wrapper included in the project root. To run all tests:

./mvnw test

Initial Data

On app startup, default data are created

User

You can use this for signing in

{
    "username": "admin",
    "password": "@Passw0rd"
}

Vehicle

{
    "id": 1,
    "licensePlate": "ABC123",
    "vehicleType": "CAR",
    "vehicleStatus": "EXITED",
    "owner": "Admin"
}

Parking Lot

{
    "id": 1,
    "lotId": "PK-......",
    "location": "Bldg #1 Alfonso Cavite",
    "capacity": 10,
    "occupiedSpaces": 0,
    "availableSpaces": 10,
    "costPerMinute": 1.0,
    "full": false
}

Postman Setup

A Postman collection is provided for easier testing.

Import collection

  1. Open Postman and go to File > Import...
  2. Select the SmartPark.postman_collection.json located at the root directory of this project.

API Documentation

Authentication

Includes user registration, login, and logout.

Register a user to the system

Endpoint: /api/v1/auth/signup

Method: POST

Content Type: application/json

Body:

{
    "username": "juanD",
    "password": "@Del4CruZ",
    "fullName": "Juan Dela Cruz"
}

All these fields are required

  • username: Must only contain letters, numbers, spaces, underscores, and dots (3-30 characters)

  • password: Must contain at least one uppercase letter, one lowercase letter, one number, and one special character (8-50 characters)

  • fullName: Must contain only letters and spaces (1-100 characters)

Response:
201 Created

{"message":"User registered successfully!"}

400 Bad Request

{
    "status": 400,
    "message": "Validation failed",
    "errors": [
        {
            "field": "username",
            "message": "Username must be 3-30 characters"
        }
    ]
}

Login to the system

Endpoint: /api/v1/auth/signin

Method: POST

Content Type: application/json

Body:

{
    "username": "juanD",
    "password": "@Del4CruZ"
}

Response:

200 OK

{
    "id": 2,
    "username": "juanD",
    "fullName": "Juan Dela Cruz",
    "role": "USER"
}

401 Unauthorized

{
    "message": "Bad credentials"
}

Logout from the system

Endpoint: /api/v1/auth/signout

Method: POST

Body: None

Response:

200 OK

{
    "message": "You've been signed out!"
}

Vehicle

Register and view vehicle details

Register a vehicle

Endpoint: /api/v1/auth/vehicles

Method: POST

Content Type: application/json

Body:

{
    "licensePlate": "XYZ123",
    "vehicleType": "CAR"
}

All these fields are required

  • licensePlate : Can only contain letters, numbers, and dashes

  • vehicleType: Must be one of the following: CAR, MOTORCYCLE, TRUCK

Response:

201 Created

{
    "id": 2,
    "licensePlate": "XYZ123",
    "vehicleType": "CAR",
    "vehicleStatus": "EXITED",
    "owner": "Juan Dela Cruz"
}

400 Bad Request

{
    "status": 400,
    "message": "Validation failed",
    "errors": [
        {
            "field": "licensePlate",
            "message": "License plate can only contain letters, numbers, and dashes"
        }
    ]
}

Retrieve vehicle details

Endpoint: /api/v1/auth/vehicles/{id}

Method: GET

Path Variable:

  • id: ID of the vehicle

Response:

200 OK

{
    "id": 2,
    "licensePlate": "XYZ123",
    "vehicleType": "CAR",
    "vehicleStatus": "EXITED",
    "owner": "Juan Dela Cruz"
}

422

{
    "message": "Vehicle not Found"
}

Parking Lot

Register and view parking lot details which includes capacity and availability

Register a parking lot

Endpoint: /api/v1/parking-lots

Method: POST

Content Type: application/json

Body:

{
    "location": "Alfonso Adventure Park",
    "capacity": 15,
    "costPerMinute": 1.5
}

All these fields are required

  • location: The address (1-100 characters)

  • capacity: Number of parking spots (Minimum 1)

  • costPerMinute: Decimal. Can be 0.

Response:

201 Created

{
    "id": 2,
    "lotId": "PK-498E09-1780654212111",
    "location": "Alfonso Adventure Park",
    "capacity": 15,
    "occupiedSpaces": 0,
    "availableSpaces": 15,
    "costPerMinute": 1.5,
    "full": false
}

400 Bad Request

{
    "status": 400,
    "message": "Validation failed",
    "errors": [
        {
            "field": "capacity",
            "message": "Capacity is required"
        },
        {
            "field": "location",
            "message": "Location is required"
        },
        {
            "field": "costPerMinute",
            "message": "Cost per minute is required"
        }
    ]
}

Retrieve parking lot details

Endpoint: /api/v1/parking-lots/{id}

Method: GET

Path Variable:

  • id: ID of the parking lot

Response:

200 OK

{
    "id": 2,
    "lotId": "PK-498E09-1780654212111",
    "location": "Alfonso Adventure Park",
    "capacity": 15,
    "occupiedSpaces": 0,
    "availableSpaces": 15,
    "costPerMinute": 1.5,
    "full": false
}

422

{
    "message": "Parking lot not found"
}

Parking Operations

Check-in/out from a parking lot and view vehicles parked.

Check in a vehicle to a parking lot

Endpoint: /api/v1/parking/check-in

Method: POST

Content Type: application/json

Body:

{
    "parkingLotId": 2,
    "licensePlate": "XYZ123"
}

All these fields are required

  • parkingLotId: ID of the parking lot

  • licensePlate: License plate of the vehicle

Response:

200 OK

{
    "ticketNumber": "TN-20260605-13F68F",
    "licensePlate": "XYZ123",
    "lotId": "PK-498E09-1780654212111",
    "checkInAt": "2026-06-05 18:13:16",
    "checkOutAt": null,
    "cost": null
}

400

{
    "message": "Vehicle is already parked"
}

Check out a vehicle from a parking lot

Endpoint: /api/v1/parking/check-out

Method: POST

Content Type: application/json

Body:

{
    "ticketNumber": "TN-20260605-DDD7E5"
}
  • ticketNumber: The ticket number generated after checking in

Response:

200 OK

{
    "ticketNumber": "TN-20260605-DDD7E5",
    "licensePlate": "XYZ123",
    "lotId": "PK-2418B2-1780654982739",
    "checkInAt": "2026-06-05 18:23:11",
    "checkOutAt": "2026-06-05 18:25:16",
    "cost": 3.0
}

409

{
    "message": "Vehicle has already checked out"
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages