3 min read

Booking API

Booking API is a small RESTful service for managing reservation data. It covers the core booking workflow: creating a reservation, listing bookings, viewing a single booking, updating booking details, and deleting a booking.

The project was built as a practical backend exercise with a focus on clear API structure, typed code, database persistence, and simple documentation that can be tested with tools like Postman or Bruno.

Overview

The API exposes a booking resource under /api/bookings. Each booking stores customer contact information, reservation date and time, and the number of people included in the reservation.

This project is intentionally lightweight. Instead of using a large backend framework, it uses Hono on top of Bun to keep the server fast, compact, and easy to understand.

Problem

Many small booking workflows need the same basic backend foundation: a way to store reservations, retrieve them, update incorrect details, and remove cancelled bookings.

The goal of this project was to build that foundation as a simple API that can be used as a starting point for restaurant reservations, appointment systems, or internal booking tools.

Role

I designed and implemented the API structure, database connection, booking routes, TypeScript types, and migration script.

The project also includes setup documentation so the API can be installed, configured with a local MySQL database, migrated, and tested without extra context.

Stack

  • Bun for the JavaScript runtime
  • Hono for the HTTP API framework
  • TypeScript for static typing
  • MySQL for relational data storage
  • dotenv for environment configuration

Features

  • Create a new booking
  • View all bookings
  • View booking details by ID
  • Update an existing booking
  • Delete a booking
  • Run a migration script to create the bookings table and seed dummy data

API Design

The API follows a simple resource-based structure:

MethodEndpointPurpose
GET/api/bookingsRetrieve all bookings
POST/api/bookingsCreate a new booking
GET/api/bookings/:idRetrieve booking details by ID
PUT/api/bookings/:idUpdate a booking by ID
DELETE/api/bookings/:idDelete a booking by ID

Each response includes a status, message, and relevant booking data. The response shape was kept predictable so the API is easy to consume from a frontend or test through an API client.

Data Model

A booking contains:

  • id
  • name
  • phone
  • date
  • time
  • people

This keeps the schema focused on the minimum data required for a reservation flow while still being easy to extend later with fields like notes, status, table number, or payment state.

Implementation Notes

The source is separated into a small set of files:

  • src/index.ts as the main server entry
  • src/db.ts for MySQL connection setup
  • src/migrate.ts for database migration and seed data
  • src/routes/bookings.ts for booking endpoints
  • src/types.ts for TypeScript definitions

This structure keeps the project approachable while still separating routing, database access, migration logic, and shared types.

Outcome

The result is a compact booking API that demonstrates CRUD implementation, Bun runtime usage, Hono routing, MySQL persistence, and TypeScript-based backend structure.

It can be used as a learning project, an API starter, or a base for a more complete booking system with authentication, validation, availability checks, and deployment configuration.