Court booking backend with Google Calendar and Playtomic
- Result
- Working end to end: connect Google Calendar once, pick a date, get the club's free courts that fit your schedule.
- My role
- Fullstack Developer (personal project)
- Team
- Solo
- Platforms
- Backend, Web
A backend that answers one question, "when can I actually play?": it connects Google Calendar, pulls my squash club's availability from Playtomic and returns only the slots that fit my day. I built it in NestJS, with a separate file microservice over TCP and a React grid that draws the result.
The problem
Booking a court at my squash club took two tabs: the club's Playtomic page to see which courts are open, and my own calendar to see when I am free. I wanted it on one screen.
So I built it for myself, and used it to take NestJS microservices, OAuth and a third-party booking platform through a complete flow, from sign-in to a rendered timetable.
What I built
- A NestJS 11 backend with four modules — users, Google Calendar, Playtomic and slots — behind a global validation pipe, Swagger docs and CORS limited to the two front-end origins. Config comes from per-environment env files.
- Google sign-in with the auth-code flow. The React app asks for the read-only calendar scope in a popup and sends the one-time code to the backend, which exchanges it for tokens, reads the user's email and stores access and refresh tokens per user in PostgreSQL through Sequelize. No passwords to keep.
- Silent token refresh. A 401 from the Calendar API triggers a refresh with the stored refresh token, persists the new tokens and retries the request, so a user connects their calendar once.
- Playtomic availability without scraping. The first version drove a headless browser through the club's booking page and read the slot grid from the DOM, with a minute-long wait per request. I replaced it with the club's availability endpoint: one HTTP call, parsed into court, start and end times.
- The slot merger, which is the product. For a given day it takes my busy intervals from Google Calendar and the club's open slots from Playtomic, normalises both to minutes of the day using the calendar's own time-zone offset, and returns only the slots that do not overlap a busy interval:
GET /slots?date=&email=. - A file microservice as a separate NestJS app over TCP, using
@nestjs/microservices: upload and fetch as base64 payloads, called from the main API through aClientProxy. It served image uploads for the first iteration of the backend. - An earlier auth layer with email and password registration, bcrypt hashing, JWT and a guard, used by the first React shell. The court-booking version dropped it and made Google the only identity, since the calendar connection already proves who the user is.
- A React 19 booking UI: a "Connect Google Calendar" page and a court-by-hour grid, one row per court, 30-minute columns, with available, unavailable and "your booking" states, drawn from the merged slots. A Calendly widget was tried as an alternative booking path.
- Docker for both services: Dockerfiles on node:18-alpine, Compose with a PostgreSQL 12 container and env files per environment. The API and the first UI were put on a hosting platform and a static host for testing.
Result
- The whole flow works, from Google sign-in to a grid of the club's free courts for the day.
- Built and used as a personal tool, not a product for sale; the backend patterns (auth-code flow, silent refresh, TCP microservice, slot merging) carried over into client work.
Tech stack
- Backend
- NestJS 11
- TypeScript
- Sequelize + PostgreSQL
- class-validator / class-transformer
- Swagger / OpenAPI
- @nestjs/config
- date-fns
- Microservice
- NestJS microservices (TCP transport)
- ClientProxy
- Base64 file payloads
- Integrations
- Google OAuth 2.0 (auth-code flow)
- Google Calendar API v3
- Playtomic availability API
- Puppeteer (first version)
- Auth
- Google sign-in
- Stored access / refresh tokens
- JWT + bcrypt (first iteration)
- Frontend
- React 19
- TypeScript
- @react-oauth/google
- React Router 7
- React Bootstrap
- MUI 7
- Sass
- react-calendly
- Delivery & tests
- Docker
- Docker Compose
- PostgreSQL 12 container
- Jest
- Supertest
- SWC
Have a similar problem? Tell me about it.
Pick a 30-minute slot, or send a few sentences about the business problem by email.