§ 07 — Architecture
A pnpm monorepo with one source of truth for the math.
Next.js on Vercel, Fastify on Railway, Postgres and Redis behind it, Solana underneath. Types, schemas, PDAs and every protocol number live in @sealed/shared so web, API and program cannot drift.
§ 7.1System map
Browser · Vercel
apps/web
Next.js 15 App Router, Tailwind, framer-motion
Wallet Adapter
SIWS sign-in; deposit transfer with memo
Bid vault
AES-GCM salts in IndexedDB
API · Railway
Fastify REST + /ws
/api/*, /llms.txt, event hub
Ledger engine
auctions, pool, drips, fee splits, rewards (double-entry)
Postgres · Redis
ledger of record; memory fallback in demo
Solana
Company wallet
holds deposits; pays withdrawals
Helius
RPC, deposit detection, Privacy Rings
sealed_launchpad
Anchor program · onchain mode (roadmap)
§ 7.2Monorepo
packages/shared @sealed/shared — types, Zod schemas, PDAs, clearing / fee / commitment math,
custody contract (custody.ts), demo world, REST + WS contract
packages/defi @sealed/defi — Anchor client, Jupiter v6, Raydium adapter (optional),
internal-CPMM quotes, encrypted bid vault, Privacy Ring clients
programs/sealed-launchpad Anchor program sealed_launchpad (onchain mode, roadmap) + tests + devnet init
apps/api @sealed/api — Fastify REST + /ws, Prisma/Postgres, Redis, workers, /llms.txt
src/offchain/ custodial ledger engine, SIWS, deposits, withdrawals (in development)
apps/web @sealed/web — Next.js 15 App Router, Tailwind, framer-motion, these docs
tests @sealed/e2e — invariant/property tests, black-box API e2e, web smoke
scripts deploy-devnet.sh · deploy-api.sh · deploy-web.sh · verify.sh@sealed/web ──▶ @sealed/defi ──▶ @sealed/shared
│ ▲
└────────────────────────────────┤
@sealed/api ──────────────────────────┘ (the API deliberately does not depend on @sealed/defi)
sealed_launchpad (Rust) mirrors constants.ts and clearing/fees/commitment integer-for-integer§ 7.3Data flow
Offchain custodial (default)
- The browser signs a SIWS message; the API issues a bearer token.
- The user transfers SOL/SPL to the company wallet with memo
sealed:<depositRef>; the deposit watcher sees it through Helius RPC and credits the ledger after finality. - Commits, reveals, swaps, claims and stakes are API calls that post double-entry ledger transactions.
- Schedulers clear auctions, graduate, run drips and split fees on the ledger; events stream over
/ws. - Withdrawals are paid from the company wallet by the payout worker, or queued for manual approval.
Onchain (roadmap)
- The browser builds and signs program transactions with Wallet Adapter (
@sealed/deficlient). - The indexer polls
getProgramAccountsevery 20 s (and ononLogs, debounced 1.5 s), decodes accounts with the IDL and upserts launches. - Diffs become WS events; the API serves the store over REST.
§ 7.4Workers
| Worker | File | Cadence | Runs when | Status |
|---|---|---|---|---|
| Indexer | workers/indexer.ts | 20 s poll + onLogs | not demo, RPC + IDL present | Onchain mode |
| Auto-reveal relayer | workers/revealRelayer.ts | 2 s | always; demo marks bids revealed | Live in demo |
| Buyback keeper | workers/buybackKeeper.ts | 10 s | not demo, KEEPER_SECRET_KEY set | Account wiring gap |
| Demo world ticker | @sealed/shared demo.ts | DEMO_TICK_MS (1 s) | DEMO_MODE | Live in demo |
| Ledger engine, deposit watcher, payouts | src/offchain/** | — | EXECUTION_MODE=offchain | In development |
Workers run in-process with the HTTP server (WORKERS_ENABLED=true) and are stopped on shutdown. The relayer retries a reveal up to 8 times and treats AlreadyRevealed as success.
§ 7.5Storage and cache
- Postgres (Prisma)
- Models: Launch, Bid, RevealPayload, Trade, BuybackEvent, CreditLedger, HolderReward, ProtocolStats (
apps/api/prisma/schema.prisma). The custodial ledger tables are added by the offchain workstream.prisma db pushruns on container boot whenDATABASE_URLis set. - Memory store
- Used when DATABASE_URL is unset (demo). Not durable; a custodial deployment must use Postgres.
- Redis
- Response cache (1–2 s TTLs on lists, stats, revenue) and the keeper job queue. Falls back to an in-process map when
REDIS_URLis unset. - Browser
- Encrypted bid salts in IndexedDB; a client-side demo world takes over if the API is unreachable.