Skip to content
{ JT }Jonathan Gamez Tomoyosi
Back to projects
In testing

Yma — E-commerce

Storefront with a resilient backend: circuit breaker, rate limiting and sanitisation

Online store with separate front and backend. The technical interest is in the backend: a Fastify service treated as a system that will fail, rather than one that hopes not to.

Technologies

  • React
  • TypeScript
  • Vite
  • TanStack Query
  • Fastify
  • Prisma
  • PostgreSQL
  • Zod
  • Opossum
  • Pino
  • Vitest

Context

A store depends on services it does not own — payment, media, delivery. Each one is a point where the whole store can stop because of somebody else’s outage.

Challenge

  • External service failure or slowness propagating all the way to the end customer.
  • User input reaching the database and the HTML untreated.
  • The need to diagnose production problems without structured logging.

Solution

  • A circuit breaker per external dependency, its open state cutting the timeout cascade.
  • Schema validation at the boundary and sanitisation before persistence.
  • Per-route rate limiting and globally applied security headers.
  • Structured logging, making request and failure correlatable.

Outcome

  • Third-party downtime no longer means store downtime.
  • Backend with automated test coverage.

Highlights

  • Circuit breaker on outbound calls, isolating third-party failure so it cannot take the store down.
  • Rate limiting, security headers and HTML sanitisation on input.
  • Retry with backoff in the HTTP client, so transient network failure never reaches the user as an error.
  • CPF/CNPJ validation, structured logging and scheduled jobs.
  • Test suite with coverage on the backend and component tests on the front.