# denesis0-0/booking-platform-api architecture

> Architecture diagram of the GitHub repository denesis0-0/booking-platform-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/denesis0-0/booking-platform-api
- Repository: https://github.com/denesis0-0/booking-platform-api

## Overview

This Go service exposes a REST API for managing bookable resources, their time slots, and confirmed or cancelled bookings. The main workflow is an API client request routed by the server to an HTTP handler, which validates input and invokes PostgreSQL-backed storage; available-slot queries exclude confirmed bookings, and the database’s partial unique index prevents duplicate active bookings. The README documents the API capabilities and schema. Edges reflect shown calls or documented behavior; unsampled migration details are limited to the README’s stated uniqueness guarantee.

Main entry points: [`cmd/api/main.go`](https://github.com/denesis0-0/booking-platform-api/blob/main/cmd/api/main.go) (HTTP server), [`internal/httpapi/handler.go`](https://github.com/denesis0-0/booking-platform-api/blob/main/internal/httpapi/handler.go) (Request handlers), [`internal/storage/slots.go`](https://github.com/denesis0-0/booking-platform-api/blob/main/internal/storage/slots.go) (Slot storage), [`internal/storage/bookings.go`](https://github.com/denesis0-0/booking-platform-api/blob/main/internal/storage/bookings.go) (Booking storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and configuration"]
  node_server["HTTP server<br/>[main.go]"]
  node_config["Runtime config<br/>[config.go]"]
end

subgraph group_api["HTTP API"]
  node_handlers["Request handlers<br/>[handler.go]"]
end

subgraph group_storage["Persistence"]
  node_pgpool["Postgres pool<br/>[postgres.go]"]
  node_resources["Resource storage<br/>[resources.go]"]
  node_slots["Slot storage<br/>[slots.go]"]
  node_bookings["Booking storage<br/>[bookings.go]"]
  node_schema["Booking schema"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -->|"sends requests"| node_server
node_server -->|"loads config"| node_config
node_server -->|"opens pool"| node_pgpool
node_server -->|"registers routes"| node_handlers
node_server -->|"serves responses"| node_client
node_handlers -->|"checks health"| node_pgpool
node_handlers -->|"manages resources"| node_resources
node_handlers -->|"manages slots"| node_slots
node_handlers -->|"manages bookings"| node_bookings
node_pgpool -->|"connects pool"| node_postgres
node_resources -->|"reads and writes"| node_postgres
node_slots -->|"queries slots"| node_postgres
node_bookings -->|"queries bookings"| node_postgres
node_schema -.->|"defines tables"| node_postgres
node_slots -->|"filters confirmed bookings"| node_postgres
node_bookings -->|"enforces unique active slot"| node_postgres

click node_server "https://github.com/denesis0-0/booking-platform-api/blob/main/cmd/api/main.go"
click node_config "https://github.com/denesis0-0/booking-platform-api/blob/main/internal/config/config.go"
click node_handlers "https://github.com/denesis0-0/booking-platform-api/blob/main/internal/httpapi/handler.go"
click node_pgpool "https://github.com/denesis0-0/booking-platform-api/blob/main/internal/storage/postgres.go"
click node_resources "https://github.com/denesis0-0/booking-platform-api/blob/main/internal/storage/resources.go"
click node_slots "https://github.com/denesis0-0/booking-platform-api/blob/main/internal/storage/slots.go"
click node_bookings "https://github.com/denesis0-0/booking-platform-api/blob/main/internal/storage/bookings.go"
click node_schema "https://github.com/denesis0-0/booking-platform-api/blob/main/migrations/001_create_tables.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_config,node_client toneBlue
class node_handlers,node_postgres toneAmber
class node_pgpool,node_resources,node_slots,node_bookings,node_schema toneMint
```

## Components

### Runtime and configuration

- [HTTP server](https://github.com/denesis0-0/booking-platform-api/blob/main/cmd/api/main.go): `cmd/api/main.go`
- [Runtime config](https://github.com/denesis0-0/booking-platform-api/blob/main/internal/config/config.go): `internal/config/config.go`

### HTTP API

- [Request handlers](https://github.com/denesis0-0/booking-platform-api/blob/main/internal/httpapi/handler.go): `internal/httpapi/handler.go`

### Persistence

- [Postgres pool](https://github.com/denesis0-0/booking-platform-api/blob/main/internal/storage/postgres.go): `internal/storage/postgres.go`
- [Resource storage](https://github.com/denesis0-0/booking-platform-api/blob/main/internal/storage/resources.go): `internal/storage/resources.go`
- [Slot storage](https://github.com/denesis0-0/booking-platform-api/blob/main/internal/storage/slots.go): `internal/storage/slots.go`
- [Booking storage](https://github.com/denesis0-0/booking-platform-api/blob/main/internal/storage/bookings.go): `internal/storage/bookings.go`
- [Booking schema](https://github.com/denesis0-0/booking-platform-api/blob/main/migrations/001_create_tables.sql): `migrations/001_create_tables.sql`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- API client → HTTP server: sends requests (evidence: `README.md`)
- HTTP server → Runtime config: loads config (evidence: `cmd/api/main.go`)
- HTTP server → Postgres pool: opens pool (evidence: `cmd/api/main.go`)
- HTTP server → Request handlers: registers routes (evidence: `cmd/api/main.go`)
- HTTP server → API client: serves responses (evidence: `cmd/api/main.go`)
- Request handlers → Postgres pool: checks health (evidence: `internal/httpapi/handler.go`)
- Request handlers → Resource storage: manages resources (evidence: `internal/httpapi/handler.go`)
- Request handlers → Slot storage: manages slots (evidence: `internal/httpapi/handler.go`)
- Request handlers → Booking storage: manages bookings (evidence: `internal/httpapi/handler.go`)
- Postgres pool → PostgreSQL: connects pool (evidence: `internal/storage/postgres.go`)
- Resource storage → PostgreSQL: reads and writes (evidence: `internal/storage/resources.go`)
- Slot storage → PostgreSQL: queries slots (evidence: `internal/storage/slots.go`)
- Booking storage → PostgreSQL: queries bookings (evidence: `internal/storage/bookings.go`)
- Booking schema → PostgreSQL: defines tables (evidence: `README.md`)
- Slot storage → PostgreSQL: filters confirmed bookings (evidence: `internal/storage/slots.go`)
- Booking storage → PostgreSQL: enforces unique active slot (evidence: `README.md`)
