Back to Portfolio

Car Park Booking API

A Laravel 12 REST API for managing car park bookings with seasonal pricing and token-based authentication

01. Project Overview

Purpose

The Car Park Booking API is a comprehensive REST API built with Laravel 12 that enables efficient management of car park bookings. It provides a flexible pricing system with seasonal variations, secure authentication, and complete booking lifecycle management.

Challenge

Design and implement a scalable API that handles complex pricing rules (summer/winter rates, weekday/weekend variations), manages capacity constraints, and provides secure user authentication while maintaining clean, testable code architecture.

Solution

Built a RESTful API using Laravel 12 with PHP 8.2, implementing Laravel Sanctum for token-based authentication. Created a flexible pricing engine that handles seasonal variations, developed comprehensive CRUD operations for bookings, and included public endpoints for price calculations and availability checks.

02. Key Features

Seasonal Pricing Engine

Configurable pricing rules supporting summer/winter rates and weekday/weekend variations. Prices stored in pence internally for precision.

Token-Based Authentication

Secure authentication using Laravel Sanctum with user registration, login, logout, and profile management.

Booking Management

Full CRUD operations for bookings including list, create, update, and delete. Automatic availability checking and capacity management.

Public API Endpoints

Public endpoints for price calculation and availability checking, allowing integration without authentication.

Comprehensive Test Suite

Built with Pest testing framework for robust quality assurance across all API endpoints and business logic.

Flexible Database Support

SQLite for development with seamless support for MySQL, PostgreSQL in production environments.

03. Technology Stack

Backend & Framework

  • Laravel 12

    Modern PHP framework for robust APIs

  • PHP 8.2

    Latest PHP for type safety and performance

  • Laravel Sanctum

    Token-based API authentication

Database & Testing

  • SQLite / MySQL / PostgreSQL

    Flexible database support

  • Pest

    Modern testing framework

  • Eloquent ORM

    Database abstraction layer

04. API Endpoints

Public Endpoints

  • GET /api/price

    Calculate booking price for specified dates

  • GET /api/availability

    Check availability for specified dates

Authentication Endpoints

  • POST /api/register

    Create new user account

  • POST /api/login

    Authenticate and receive token

  • POST /api/logout

    Invalidate authentication token

Booking Endpoints (Protected)

  • GET /api/bookings

    List all bookings for authenticated user

  • POST /api/bookings

    Create new booking

  • PUT /api/bookings/{id}

    Update existing booking

  • DELETE /api/bookings/{id}

    Delete booking

Back to Portfolio