Projects Archive
Booklnk
Multi-tenant appointment booking backend for barbershops, gyms and consultants, built from scratch on NestJS and PostgreSQL. I owned the schema, the service layer and the full API surface.
Category
Full-Stack
Year
2024
Duration
9 months
Team
3 engineers
Overview
- Built the backend from scratch for a multi-tenant booking platform on NestJS and PostgreSQL — supporting barbershops, gyms, and consultants from a single codebase. Owned the schema design, service architecture, and the full API layer.
- Integrated Kashier (Egyptian payment gateway) end-to-end: webhook ingestion, idempotent transaction validation, and reconciliation logic. Shipping payments is always messier than the docs make it look.
- Slot validation and concurrent-booking prevention was the hardest part. Optimistic locking with a version field eliminates double-bookings without killing throughput.
- Modelled multi-business-type scheduling with different slot rules, service durations, and staff availability — abstracted behind a polymorphic booking engine so adding a new business type is config, not code.
The problem
- Booking platforms for Egyptian SMBs were either too generic with no local payment support, or industry-specific and impossible to adapt. Barbershops, gyms, and consultants all have fundamentally different scheduling rules but no shared infrastructure.
- Concurrent booking was a real reliability problem — two customers hitting the same slot at the same millisecond was causing lost revenue for pilot businesses.
- No Egyptian payment gateway integration existed in the open-source ecosystem, forcing businesses to handle cash or use fragmented workarounds.
The solution
- Designed a multi-tenant schema where each business type extends a shared booking core. Table inheritance in PostgreSQL keeps queries fast and adding a new business type costs zero migration risk.
- Implemented optimistic locking on the slot reservation table — each row carries a version counter. Concurrent requests compare-and-swap; the loser retries. Eliminated 100% of double-bookings under load testing.
- Built a Kashier webhook pipeline with idempotency keys — every incoming event is deduplicated before processing, so network retries never create phantom transactions. Reconciliation runs nightly and flags mismatches.
- Exposed a clean REST API with role-based guards (business owner vs customer vs staff) using NestJS guards + JWT. Dockerised the full stack for reproducible deploys.
Outcomes
- Zero double-bookings since optimistic locking shipped across all pilot businesses||Kashier integration handles Egyptian card payments, Meeza, and Fawry with full webhook reliability||Multi-tenant architecture supports 3 business types from a single deployed instance||New environment spins up in under 2 minutes with Docker + CI||API documented end-to-end with Swagger — onboarded two frontend devs with no back-and-forth.
My role
Backend Engineer & Tech Lead
JavaScript, TypeScript, Node.js, NestJS, Docker, PostgreSQL
