MUTATE
// Documentation

Docs

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

ServiceResponsibility
launch-intake.tsThe one-signature launch: begin (draft + prepared transaction) and confirm (verify on chain, publish, create session)
launchpad.tsCreating tokens, listing indexed tokens, building the token view
onchain-launch.tsPreparing and reconciling launch, migration and trade transactions against Meteora
meteora-config.tsBuilds the bonding-curve config, including the fee package
quote-assets.tsThe curated quote asset catalog, launchability, cache and on-chain checks
quote-launch-guard.tsRe-reads the quote mint on chain before a launch
mutation-gate.tsIndexing rule, graduation and fee checks, and starting the first round
mutation-activation.tsThe one-time mutation fee burn: quote, prepare, reconcile
mutation.tsRounds, proposals, support, votes, settlement
token-economics.ts$MUTATE status and the shared burn pipeline
mutation-forge.tsForge service catalogue and USD-priced $MUTATE quotes
upgrades.tsGoverned metadata upgrades
treasury.tsRevenue, expenses, allocations and buybacks
auth.tsWallet sign-in challenge, sessions and the cookie
archive.tsThe public archive read model
trade-indexer.tsReads 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.tsReads and writes image bytes: local disk in development, a private Vercel Blob store in production

Data model highlights

  • tokens: one row per token. status is draft until the launch confirms. creator_fee_bps and creator_fee_recipient hold 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.
  • trades and trade_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).