LOOPandaLOOPanda
ENTRY 02 / 05FULL-STACKTYPE: INTERNAL BUILD

Atlas

A multi-tenant SaaS core — auth, billing, tenancy — built once, hardened, and reused on every product since.

STACK — Next.js · TypeScript · PostgreSQL · Prisma · Stripe · Redis

SYSTEM.LAYERSCLIENTAPIDATASSRRESTSQLEDGE → ORIGIN → REPLICA

FIG. 02.0 — SYSTEM COMPOSITION, DRAWN IN CODE

SEC. 01BRIEF

THE PROBLEM, PLAINLY

Every SaaS project begins with the same six weeks: authentication, organizations, roles, billing, emails, background jobs. Atlas was built to make those six weeks a checkbox — a production-grade core we harden continuously and fork per product.

The discipline was to build it like it already had paying tenants: rate limits, row-level tenancy checks in one place, idempotent webhooks, and load numbers measured rather than assumed.

SEC. 02APPROACH
01

Tenancy as a single choke point

Every query passes a tenant resolver — one module owns isolation, so a leak requires beating one review, not thirty. Postgres row-level security backs it up at the database.

02

Billing that survives retries

Stripe webhooks are idempotent and event-sourced: every billing state transition replays cleanly, and a dropped webhook heals on the next sync pass.

03

Server components by default

Pages render on the server; interactivity ships as islands. First Load JS stays under 100 kB on every route — measured in CI, failed if exceeded.

04

Load-tested before launch-tested

k6 smoke and soak runs are part of the pipeline. The p95 number on this page comes from the soak report, not from a quiet afternoon.

SEC. 03ARCHITECTURE
EDGE · CDNNEXT.JS · SSR / ISRREDIS · CACHE + JOBSAUTH · SESSIONSAPI · ROUTE HANDLERSPOSTGRES · PRISMA + RLSTENANT RESOLVERSTRIPE · WEBHOOKS
FIG. — Edge cache in front of Next.js SSR, one API layer with a tenant resolver choke point, Postgres + Redis behind it, Stripe at arm’s length.
SEC. 04ARTIFACTS
>_ BUILD + SOAK
$ next build
Route (app) Size First Load JS
┌ ○ / 4.1 kB 93 kB
├ ○ /dashboard 8.7 kB 99 kB
├ ƒ /api/v1/* — —
└ ○ /settings/billing 6.2 kB 97 kB
 
$ k6 run soak.js --vus 200 --duration 30m
http_req_duration p50=61ms p95=182ms p99=290ms
http_req_failed 0.00%
checks 100.00% (18,442 passed)
§ TENANCY MODES
Pooled
Shared schema, RLS-enforced — default for small tenants
Siloed schema
Per-tenant schema for regulated data
Read replica
Analytics traffic isolated from the primary
Session model
HttpOnly, rotating, device-scoped revocation

ENGINEERING NOTE

The core insight is negative space: Atlas is defined by what product teams never have to think about again. Every hour it absorbs is an hour a product bet gets back.

SEC. 05OUTCOME

0ms

P95 UNDER 200-VUS SOAK

0

LIGHTHOUSE PERFORMANCE

0kB

FIRST-LOAD JS CEILING, ENFORCED IN CI

00

CROSS-TENANT READS IN AUDIT

NEXT ON THE LEDGER — ENTRY 03 / 05This Site