← All work
Client engagement · 2025

Dual-Format REST API (JSON + Protobuf) on Fastify & PostgreSQL

An events / badge-management platform

Overview

A high-performance REST API for an events / badge-management platform, built on Fastify and PostgreSQL, that serves either JSON or Protocol Buffers based on the request’s Accept header, letting bandwidth-sensitive clients opt into compact binary payloads.

The Challenge

Event and badge systems involve high-volume reads from constrained or numerous edge devices. The platform needed an API that stays human-friendly (JSON) for typical clients while offering efficient binary (Protobuf) responses where throughput and payload size matter.

What We Built

A Fastify service with a fastify-postgres data layer exposing resource endpoints (e.g. user management) that perform content negotiation: the same routes return JSON or serialized Protocol Buffers depending on Accept. The build includes @fastify/compress for response compression, @fastify/swagger + Swagger UI for live OpenAPI docs, a protobufjs schema/serialization layer, Firebase Functions/Admin packaging for deployment, an example client, and Docker Compose for local Postgres.

Technologies & Approach

Fastify for low-overhead HTTP; PostgreSQL via the official plugin; protobufjs for binary encoding; Swagger for self-documenting endpoints; Firebase Functions as a deployment target. Content negotiation keeps a single API surface serving both developer-friendly and high-efficiency formats.

Outcome / Impact

Delivered a documented, performance-conscious data API that flexibly serves JSON or Protobuf from one codebase, reducing payload size for demanding clients without sacrificing JSON ergonomics for everyone else.

Capabilities Demonstrated

  • High-performance Fastify + PostgreSQL REST APIs
  • HTTP content negotiation with dual JSON/Protobuf responses
  • Protocol Buffers schema design and serialization
  • Self-documenting APIs via OpenAPI/Swagger
More work See all →