Deployment
Production deployment checklist, startup sequence, health endpoints, and logging for all three services.
backend/ (Bun + Hono)
Pre-Deployment Checklist
Startup Sequence
On each server start, backend/ runs:
- Validates all environment variables (fails fast on missing required vars)
- Registers middleware and routes
- Starts the Bun HTTP server on
PORT(default 3000) - If
SUI_CONTRACT_ADDRESSis set: starts the on-chain event indexer
Health Endpoints
| Path | Purpose |
|---|---|
GET /health | Liveness probe — returns 200 if the process is alive |
Use /health for load balancer health checks and container liveness probes.
Logging
The backend uses structured JSON logging (Pino) with optional BetterStack forwarding.
Log format (production):
{
"level": 30,
"time": "2026-04-19T10:00:00.000Z",
"service": "mersi",
"method": "POST",
"path": "/api/chat",
"status": 200,
"ms": 1423,
"msg": "POST /api/chat 200 1423ms"
}BetterStack forwarding (optional):
BETTERSTACK_SOURCE_TOKEN=your-token
BETTERSTACK_INGESTING_HOST=s2380734.eu-fsn-3.betterstackdata.comDocker
FROM oven/bun:1-alpine
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
COPY . .
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s CMD wget -qO- http://localhost:3000/health || exit 1
CMD ["bun", "run", "start"]Idle Timeout
The Bun server is configured with a 120-second idle timeout:
Bun.serve({ idleTimeout: 120, ... })This accommodates LLM streaming responses (can run 10–30 seconds), scraping API calls, and Sui RPC round-trips. Ensure your load balancer or proxy allows at least 120 seconds before timing out.
frontend/ (Next.js)
Production Build
cd frontend && bun run build && bun run startEnvironment Variables
NEXT_PUBLIC_CROSSMINT_API_KEY=pk_production_...The Next.js app proxies /api/* to the backend. Ensure the proxy target URL in next.config.ts points to your production backend/ instance.
scraping/ (NestJS)
Production Start
cd scraping
npm run build
npm run start:prodEnvironment Variables
NODE_ENV=production
PORT=3001
APIFY_TOKEN=apify_api_...
REDIS_HOST=your-redis-host
REDIS_PORT=6379
SUI_NETWORK=mainnetSee Scraping Environment Reference for the full list.
Railway (Recommended)
- Connect your GitHub repository
- Create three services:
backend,frontend,scraping - Set all environment variables in each service's Railway dashboard
- Railway auto-detects Bun for
backend/and runsbun run start - Railway detects Node.js for
scraping/— set start command tonpm run start:prod
How is this guide?