Mara Keller
Studio lead
Owner · full access
Mara Keller
Studio lead
Owner · full access
How it is really built
This page describes the real system the demo was rebuilt from. The real system is built and tested but not trading yet: payments stay in test mode and mail is rendered, not sent. The numbers were measured on its repository at the last commit. The demo itself runs none of it, and the last section lists the main changes.
The map
This is the real hosting setup. Not all of it runs yet. This demo runs none of it.
The staff box says choose a profile because that is this demo's way in. The real one asks for a shared password, stored as a scrypt hash, and only then for a profile.
Pick a box for its role, provider and screens.
| From | To | What goes over it |
|---|---|---|
| Customers | DNS | shop pages |
| Staff | DNS | admin, password |
| DNS | App host | points the domain at the app |
| App host | Database | secret key, server only |
| App host | File storage | presigned links |
| Staff | File storage | upload / download with a presigned link |
| App host | Payments | creates the checkout session |
| Customers | Payments | pays on the hosted page |
| Payments | App host | signed webhook |
| App host | Mail sender | send API |
| Mail sender | Customers | order and shipping emails |
| Code + CI | App host | deploys on push to main |
| Code + CI | Database | hourly checks (switched off): health + read-only SQL |
| Code + CI | File storage | nightly database dump (switched off) |
| Inbox task | Mailbox | reads new mail |
| Inbox task | Database | sorts into the inbox (RPC) |
Architecture
One app, one database One Next.js app on one host talks to one Postgres. There are no other services between them to keep in step.
Pricing has one authority SQL prices everything that is charged. A pure TypeScript copy serves the interface, and a test runs random carts through both and requires equality.
Money path
A declined card changes nothing.
This is a tested promise: orders, customers, stock, movements, discount usage and email all stay as they were. Only the temporary hold existed, and it is released.
If a payment arrives after the hold ran out, the order is created and flagged as a stock conflict. Stock never goes below zero and nothing is refunded automatically.
Security
The gate canonicalises every path and denies by prefix before anything else runs. Each row is a test in a table.
| Request | What the gate does first | Result |
|---|---|---|
/ADMIN | Lower-cases it | Gate |
//admin | Collapses the slashes | Gate |
/%61dmin | Percent-decodes it | Gate |
/%2561dmin | Decodes a second time | Gate |
/admin.rsc | Strips the framework suffix | Gate |
/admin;x | Drops the path parameter | Gate |
/admin%E0%A4%A | Cannot decode it, so refuses | 400 |
/ADMINLower-cases itGate//adminCollapses the slashesGate/%61dminPercent-decodes itGate/%2561dminDecodes a second timeGate/admin.rscStrips the framework suffixGate/admin;xDrops the path parameterGate/admin%E0%A4%ACannot decode it, so refuses400Testing
A read-only watchdog stores one row per run. The reasons it prints are fixed strings, so no free text from the database or a provider reaches the report. A thrown exception counts as a failure, never as a skip. The hourly schedule and the nightly backup are written but switched off on this test version, so the checks run on demand.
env.schemaEvery variable needed so far is set and well formed.site.reachableThe health address answers, and answers quickly.site.deploymentTest mode, dev email, origin and environment are as expected.admin.sweepsecurityUnauthenticated requests never reach admin content.admin.cookiesecurityForged, unsigned and expired sessions are refused.supabase.reachableThe database answers, and answers quickly.supabase.auth_signupNew sign-ups and anonymous sign-ins stay off.supabase.migrationsEvery migration file is applied.rls.anon_probessecurityThe publishable key reads nothing it should not.db.invariantsThe 25 data invariants all hold.stock.reservations_staleNo reservation is held past its expiry.stripe.modesecurityThe payment provider is in test mode, on the expected account.stripe.webhook_endpointThe webhook destination is on, with the right events.webhook.route_alivesecurityA bogus signature gets a 400.stripe.fulfilment_gapEvery paid session has its order.email.providerThe mail provider is the safe one, here and on the target.email.outbox_coverageEvery paid order has its confirmation, and nothing is stuck.inbox.ingest_freshThe inbox task has run recently.inbox.unsorted_staleNo real mail waits too long to be sorted.inbox.rlsThe publishable key cannot read the inbox.inbox.prompt_syncThe task's prompt matches the classifier contract.headers.securitysecuritySecurity headers are present on public and admin pages.headers.noindexsecurityTest deployments ask not to be indexed.exposure.pathssecuritySensitive paths, source maps included, serve nothing.exposure.bundlesecurityPublic chunks hold no secret and no secret's name.tls.certificateThe certificate is valid for long enough.npm.auditNo high or critical advisories in production dependencies.Timeline
This demo
Same data model and rules, a new design, none of the wiring. Everything lives in your browser's memory and resets when you reload.
| Part | The real system | This demo |
|---|---|---|
| Database | Postgres with 64 tables and 87 functions | No database. A seeded store in memory |
| Payment | Hosted checkout, signed webhook, test mode | No payment. Four buttons pick how an order ends |
| An outbox and rendered templates. The mail provider is written but not switched on | No email. It is rendered, never sent | |
| Storage | A private bucket for files, with room for dumps | No storage. A file record keeps a name and a size |
| Paid APIs | A scheduled task sorts support mail | No paid API. 16 sample mails, 15 of them already sorted |
| Sign-in | A scrypt-hashed password and a lock after 5 tries | A profile choice, with no password field |
| People and carrier | A real team and a real carrier | An invented team of four and an invented carrier |
| Store and data | A real store and real test data | The fictional store Aerlo. All data is invented |
| Staff home | A different start page | A new Dashboard, computed from the real metrics |
| Product images | Photos and uploads | Drawn product art, picked from a list |
| Hardware and drag | Camera scanning, scan sounds, drag and drop | Typed input and buttons |
| Jump box | Not in the original | Added as a demo aid: Ctrl K jumps to any screen |
| Road to the books | Not in the original. One book entry per payout | Added as a demo aid: a per-order view of the payout rule, with an invented fee |
| Try a month | Not in the original | Added as a demo aid: moves every usage slider at once |