Case study 04Community, commerce and realtime platform

Zone 32-19

A community, commerce and lifestyle platform I build alone, from the Next.js client through an Express and PostgreSQL core to realtime calls, payments and an internal employee portal.

Status: Active developmentRunning in a development environment; public launch pending
Role
Founder-engineer and sole developer across every repository
Timeline
Feb 2025 to present
Context
Own product, private repositories
Layers
Web · Backend · Realtime
Links

01 Overview

Zone 32-19 is a hybrid of community platform, online store and lifestyle brand, organised around eight identity niches such as gaming, cars, bikes, fitness and anime. Members get profiles, messaging, calls and events; the business side gets commerce, subscriptions, digital products and an internal portal for staff.

Why it exists. It is my own product and the system where I learned to own everything: schema, API, realtime layer, payments, security, deployment and interface. There is no team behind it. Every repository in the platform is written and maintained by me.

What it shows. Not a landing page with a checkout. The backend alone has 39 domain modules, two database schemas and a finance ledger, and it is designed to run as several replicas on Railway.

Specification

Frontend
Next.js 16 App Router, React 19, strict TypeScript, Tailwind v4
Backend
Node.js and Express, 39 domain modules, raw parameterised SQL
Database
PostgreSQL, two schemas, ~438 tables, 126 versioned migrations
Realtime
Socket.IO with Redis adapter, WebRTC 1:1 audio and video
Payments
Stripe PaymentIntents, subscriptions, idempotent webhooks
Jobs
BullMQ for finance jobs; cron runs in one dedicated service instance
Security
HttpOnly JWT sessions, TOTP, Google OAuth, CSRF, audit log
Hosting
Railway; Caddy + Coraza WAF built for the edge
  • Two identities in one database. Public users and employees live in separate schemas with separate sessions, MFA and audit trails.
  • Stripe webhook events resolve to exactly one effect, even under retries and multiple replicas.
  • Designed to run as several web replicas. Redis carries sockets, presence and rate limits; scheduled jobs run only where an environment gate allows.
  • The browser only ever talks to its own origin, so the session cookie stays first-party and HttpOnly.

02 Architecture

A modular monolith today. One Express API holds 39 domain modules behind a single middleware pipeline, PostgreSQL holds two isolated schemas, and Redis is the shared state that lets the web tier run as several replicas.

Fig. 04.1

Platform topology on Railway

Edge

  • ClientBrowser

    Next.js 16 app, Socket.IO client, WebRTC peer media

  • GatewayNext.js BFF

    /api/proxy on the same origin; forwards cookies and XFF chain

  • Built, not liveWAF gateway (planned or optional)

    Caddy, Coraza, OWASP CRS

Application

  • ServiceExpress API

    39 domain modules behind one pipeline: rate limits, CSRF, mutation audit

  • ServiceSocket.IO server

    presence, typing, notifications, call signals

    • connects to Redispub/sub
  • Separate serviceScheduled jobs

    node-cron singleton, CRON_ENABLED gate

State

  • StorePostgreSQL

    public + employee_portal, 126 SQL migrations

  • StoreRedis

    adapter, presence, rate limits, nonces

  • QueueBullMQ finance jobs

    manual syncs, payout webhooks; retries

External

  • ExternalStripe

    payments, subscriptions

  • ExternalRevolut, Yapily

    bank data ingestion

Live path: browser to the Next.js BFF, then to the Express API over Railway private networking. Sockets authenticate with the same HttpOnly session cookie. Redis is the shared state that lets web replicas scale horizontally. The Caddy + Coraza WAF is built and deployable but not yet in the live path. Google OAuth, Claude (opt-in screening of activity posts), Cloudinary, Resend and Sentry are called from the API and omitted here for clarity.
Fig. 04.2

Payment correctness: one webhook, one effect

Before the transaction

  • ExternalStripe event

    retried until acknowledged

  • ServiceSignature check

    raw body, reject unsigned or altered

One database transaction

  • StoreDedup insert

    UNIQUE event id, ON CONFLICT DO NOTHING

  • ServiceSide effects

    orders, subscriptions, intent upserts

  • ServiceJournal posting

    double-entry lines, once per payment

  • StageAlready seen

    no-op, acknowledged

Signature verification runs on the raw body. The event id is inserted under a UNIQUE constraint inside the same transaction as the side effects, so Stripe retries and concurrent replicas resolve to exactly one effect, including a single double-entry journal entry per successful payment.

03 Media

The Zone 32-19 logo, a bone-white Z with a small purple triangle, above the words ZONE 32-19 on a near-black background.
The Zone 32-19 mark.
Eight dark, cinematic stills, one per Zone niche world, including a gaming headset, a motorcycle on a desert road, a barbell under a light shaft and a low car in a blue garage.
The eight niche worlds from the redesigned landing. Brand renders produced with AI image tools for the art direction; the product itself is code.

04 Hard problems

  • Making a stateful realtime monolith scale horizontally

    Problem

    Sockets, presence, rate-limit counters, scheduled jobs and database notifications all assumed a single process. A second replica would split users across sockets, duplicate events and run every cron job twice.

    What I did

    Redis became the shared state (Socket.IO adapter, presence, limiter stores). LISTEN/NOTIFY bridges emit only to local sockets, cron runs only where an environment gate allows it, and graceful shutdown drains HTTP, sockets, queues and pools for rolling deploys.

  • Trusting the client IP through a proxy chain

    Problem

    Rate limits keyed on the left-most X-Forwarded-For entry could be bypassed, because that entry is supplied by the client.

    What I did

    I traced the real proxy chain through Railway's edge and the BFF, set an explicit trust-proxy depth and keyed the rate limiters on the derived client address instead of a raw header.

  • Payment correctness under retries

    Problem

    Stripe retries webhooks, and with more than one replica the same event can arrive twice at the same moment.

    What I did

    The event id is recorded under a UNIQUE constraint inside the transaction that performs the side effects, and payment intents are upserted.

  • Getting a real WAF to run on a PaaS

    Problem

    The Coraza plugin's convenience loader pulled in conflicting rule sets and failed on duplicate rule ids, and the build environment blocked git over HTTPS.

    What I did

    I pinned Caddy and the plugin to compatible versions, fetched the OWASP Core Rule Set as a tarball and wrote route-level exclusions so uploads and payments keep working. Its health check once stayed green while every proxied request failed, so CI now runs the container and pushes real requests and WebSocket upgrades through it before a deploy. Built and validated in development; not yet in the live path.

  • Signed webhooks behind a blanket API gate

    Problem

    Payment-provider callbacks carry no browser origin, so a generic access gate in front of the API rejected them before their signatures were ever checked.

    What I did

    Exactly the signed callback endpoints are exempt from the gate, the signature itself becomes the access control, and a provider without a configured secret fails closed. A security test pins the behaviour.

05 Decisions

A modular monolith first.
One deployable with strong module boundaries was the cheapest way for a solo engineer to build and change the platform, and it is what runs today. Horizontal scaling comes from stateless web replicas plus Redis.
Extract services one at a time, money last.
Each backend domain moves to its own repository and deployment behind a gateway, least coupled first. Orders, payments and the ledger go last because they rely on one database transaction per operation.
Raw parameterised SQL, no ORM.
Explicit transactions and row locks where money moves, and schema changes that live in reviewed, numbered migrations.
A separate schema and identity for employees.
Staff access, RBAC and audit stay isolated from public accounts, and a compromised user session cannot reach internal tools.
BullMQ for queue-shaped work, in-process cron for the rest.
Manual syncs, payout webhooks and inbound bank transactions need retries and backoff, so they run as BullMQ jobs. Scheduled work stays in process behind an environment gate, because moving it did not justify a migration.
Rate limiters fail open when Redis is down.
A cache outage should mean requests are temporarily unlimited, never that every login is blocked.

06 What I built

Identity and security

  • JWT sessions in HttpOnly cookies, checked against a sessions table on every request so they can be revoked server-side.
  • TOTP two-factor authentication, emailed codes, trusted devices, step-up for money-moving routes, and Google sign-in.
  • A separate employee portal identity with its own cookie, double-submit CSRF tokens and 44 permission keys.
  • Helmet CSP and HSTS, a CORS allow-list, Redis-backed rate limits keyed on a trusted client IP, and a mutation audit log with secrets scrubbed.

Realtime and social

  • Socket.IO authenticated from the session cookie, WebSocket-only so no replica needs sticky sessions, with a Redis adapter so events reach users connected to any replica.
  • Presence, typing indicators, read receipts, reactions, edits, deletions and per-user notification rooms.
  • 1:1 audio and video calls over WebRTC, with Socket.IO signalling, invite timeouts and state that expires on its own.
  • PostgreSQL LISTEN/NOTIFY bridges that push moderation-queue and niche changes to connected clients without duplicate events.

Commerce and finance

  • Backend modules for the store, cart, orders, drops, gift cards, mystery boxes and digital products with single-use download tokens.
  • Stripe PaymentElement checkout against a server-priced PaymentIntent. The browser never decides the amount.
  • Signature-verified webhooks, deduplicated inside the same transaction as their side effects.
  • A finance hub with double-entry journal posting and reconciliation, scheduled ingestion from Stripe, Revolut and Yapily, and BullMQ jobs with retries for manual syncs and payout webhooks.

Frontend and operations

  • A Next.js 16 client with a same-origin BFF proxy, route groups for public, member and employee areas, and edge middleware gating.
  • A 55-page employee portal covering HR, leave, finance, legal policy versions, commerce configuration and sessions.
  • A GSAP-driven landing for eight niche worlds, with motion tiers that respect reduced-motion and save-data preferences.
  • Health probes that return 503 when dependencies degrade, graceful shutdown, Sentry, request IDs and CI checks for migrations and secrets.

07 Status

Today

  • Running on Railway in a development environment, with the Next.js BFF fronting the API over private networking. The public domain is not serving yet.
  • Messaging, calls, checkout, the employee portal and the backend commerce modules are implemented.
  • The redesigned interface wires cart, wishlist, orders and checkout; drops, gift cards and mystery boxes still show placeholder data there.
  • Backend tests have grown to 48 files (about 390 tests), including database-backed webhook and order-accounting tests on the real schema; the frontend and the WAF have their own CI.
  • November added an optimistic cart with rollback and undo, steadier loading on key pages, and money and chat that follow the language.
  • Structured JSON logs with request and correlation IDs now ship to a self-hosted Grafana Loki in the development environment, and health checks separate liveness, readiness and per-module state.
  • October added a product registry for KObait boats, with public QR identity pages and a staff-only admin behind MFA.
  • The public site is mid-way through a documented design reset.

Notes

AI coding agents are part of the workflow here as well, working under repository rules (CLAUDE.md, AGENTS.md) that I maintain. Every commit is authored and integrated by me.

08 What I learned

  • Scaling a stateful app is mostly about naming every piece of state and deciding where it lives.
  • Payment code should be written as if every message arrives twice.
  • Documenting what is not live yet keeps a solo project honest. Several plans in the repository were retired once the real topology was written down.

09 Stack

  • Next.js
  • React
  • TypeScript
  • Tailwind CSS
  • GSAP
  • Node.js
  • Express
  • JavaScript
  • PostgreSQL
  • Redis
  • BullMQ
  • Socket.IO
  • WebRTC
  • Stripe
  • Claude
  • Railway
  • Caddy + Coraza WAF
  • Docker
  • Sentry
  • GitHub Actions

Built with: credits and licenses

  • Next.js and Reactby Vercel; Meta

    The client and its same-origin BFF.

    UsedMIT

  • Express and node-postgresby OpenJS Foundation and contributors; Brian Carlson

    The modular monolith API and its raw parameterised SQL.

    UsedMIT

  • Socket.IO and its Redis adapterby Socket.IO contributors

    Messaging, presence and call signalling across replicas.

    UsedMIT

  • BullMQby Taskforce.sh

    Finance jobs with retries.

    UsedMIT

  • Stripe SDKsby Stripe

    PaymentIntents, the PaymentElement checkout and webhook verification.

    UsedMIT

  • Sentry SDKsby Sentry

    Error tracking in the API and the client.

    UsedMIT

  • Caddy, Coraza and the OWASP Core Rule Setby Caddy contributors; OWASP Coraza; OWASP CRS

    The web application firewall, built and validated in development.

    UsedApache-2.0

  • GSAPby GreenSock (Webflow)

    Motion on the landing page.

    UsedGSAP Standard No Charge License (not open source)

All credits and licenses
Now on repeatMemory RebootVØJ, NarventYouTubeOpen YouTube player
Electricity reactivity

YouTube changes the circuit through player state alone.

Synthwave selection

Memory Reboot

VØJ, Narvent

Opening the player connects to YouTube. Google’s privacy policy