Architecture
Stack
Next.js 16 (App Router, webpack build), React 19, TypeScript, CSS Modules plus a few global stylesheets, Drizzle ORM on PostgreSQL, Redis, BullMQ for background jobs, Reown AppKit for Solana wallets, Meteora Dynamic Bonding Curve and DAMM v2 SDKs, Jupiter for token metadata and prices. Local services run in Docker (Postgres on port 54329, Redis on 56379).
The Next.js version here has breaking changes from older releases. Read node_modules/next/dist/docs/ before changing framework-level code.
Layout
src/
app/ Pages (App Router), API routes under app/api, global styles
components/ Shared UI: header, footer, pickers, panels, wallet provider
domain/ Pure rules with no I/O: fees, quote assets, mutation phases, launch constants
services/ Server logic: database access, chain calls, external APIs
jobs/ BullMQ queue, worker and processor
db/ Drizzle schema and migrations runner
lib/ Validation, errors, HTTP helpers, API client
config/ Environment parsing and validation
drizzle/ SQL migrations
test/ Vitest suites
docs/ This documentation
programs/ The mutate-binding Anchor program
Rule of thumb: domain/ stays pure and is unit tested; services/ owns side effects; routes in app/api stay thin (origin check, auth, rate limit, parse, call a service).
Key services
| Service | Responsibility |
|---|---|
launch-intake.ts | The one-signature launch: begin (draft + prepared transaction) and confirm (verify on chain, publish, create session) |
launchpad.ts | Creating tokens, listing indexed tokens, building the token view |
onchain-launch.ts | Preparing and reconciling launch, migration and trade transactions against Meteora |
meteora-config.ts | Builds the bonding-curve config, including the fee package |
quote-assets.ts | The curated quote asset catalog, launchability, cache and on-chain checks |
quote-launch-guard.ts | Re-reads the quote mint on chain before a launch |
mutation-gate.ts | Indexing rule, graduation and fee checks, and starting the first round |
mutation-activation.ts | The one-time mutation fee burn: quote, prepare, reconcile |
mutation.ts | Rounds, proposals, support, votes, settlement |
token-economics.ts | $MUTATE status and the shared burn pipeline |
mutation-forge.ts | Forge service catalogue and USD-priced $MUTATE quotes |
upgrades.ts | Governed metadata upgrades |
treasury.ts | Revenue, expenses, allocations and buybacks |
auth.ts | Wallet sign-in challenge, sessions and the cookie |
archive.ts | The public archive read model |
trade-indexer.ts | Reads new swaps from each live pool (bonding curve, then the DAMM v2 pool after graduation) and stores them in trades. Runs inside the worker every TRADE_INDEX_INTERVAL_SECONDS (default 20) |
object-storage.ts | Reads and writes image bytes: local disk in development, a private Vercel Blob store in production |
Data model highlights
tokens: one row per token.statusisdraftuntil the launch confirms.creator_fee_bpsandcreator_fee_recipienthold the fee package. The ticker unique index excludes drafts.onchain_launches: one row per launch attempt with its mint, config, pool and state (prepared,submitted,live,graduating,graduated,failed).chain_transactions: every prepared transaction (launch, migration, trade, metadata upgrade) with its message hash and state.rounds,proposals,supports,votes: the mutation rounds.generations: append-only history of every generation. A database trigger blocks deleting or rewriting them.tradesandtrade_cursors: every buy and sell read from chain, and where the indexer stopped for each pool.native_token_burns: every $MUTATE burn, including mutation-fee burns (action_type = 'mutation-activation').uploads,sessions,auth_challenges,users: media and wallet identity.treasury_*: the public revenue and buyback ledger.
Background jobs
The worker (npm run worker) processes image generation, round freeze and settle, transaction reconciliation, timelocks, native burn reconciliation and treasury buybacks. Jobs have stable ids and recover on worker start. The first round's freeze and settle jobs are scheduled when a token unlocks, not when it is created.
Wallet identity
A session cookie ties a request to a wallet. It is created in two ways: signing the sign-in message in the header, or confirming a launch (the confirmed launch transaction proves ownership). Most write routes require a session, check the request origin and are rate limited in Redis.
Frontend structure
Pages under src/app use CSS Modules with the lab tokens described in the design system. The per-token page wraps the older shared panels in a scoped override sheet (src/app/token/[id]/token.module.css).