Mersi

Environment Variables

Complete reference for all environment variables used by backend/, frontend/, and scraping/.

backend/ (Bun + Hono)

Copy backend/.env.example to backend/.env and fill in the required values before starting the server.

Required

These variables must be set. The backend/ server will refuse to start if any are missing.

Prop

Type

Core Configuration

VariableDefaultDescription
PORT3000HTTP server port
NODE_ENVdevelopmentdevelopment | production | test. Controls dev routes and log format.
LOG_LEVELinfotrace | debug | info | warn | error | fatal
RATE_LIMIT_RPM30Max requests per minute per authenticated user

Database

VariableDefaultDescription
DATABASE_URLPostgreSQL pooler URL (required)
DATABASE_URL_DIRECTDATABASE_URLDirect connection URL bypassing PgBouncer. Required for migrations on Neon.
REDIS_URLredis://localhost:6379Redis connection string

Crossmint

VariableDefaultDescription
CROSSMINT_SERVER_API_KEYServer-side API key (required)
CROSSMINT_API_URLhttps://staging.crossmint.comCrossmint API base URL. Change to https://www.crossmint.com for production.
CROSSMINT_EVM_CHAIN_TYPEbase-sepoliaEVM chain for payments. E.g. base, ethereum-sepolia, polygon.
CROSSMINT_WEBHOOK_SECRET""Svix signing secret from Crossmint dashboard. Required to receive webhooks.

LLM

VariableDefaultDescription
OPENROUTER_API_KEYOpenRouter API key (required)
LLM_MODELopenai/gpt-4oModel string passed to OpenRouter. E.g. anthropic/claude-3-5-sonnet, openai/gpt-4o-mini.

Service Selection

VariableDefaultOptionsDescription
PRODUCT_SERVICEmockmock | scrapingProduct data source
CART_SERVICEdbdb | onchainCart backend

When PRODUCT_SERVICE=scraping

VariableDefaultDescription
SCRAPING_SERVICE_URL""Base URL of the scraping/ microservice
SCRAPING_SERVICE_API_KEY""API key for the scraping/ service

When CART_SERVICE=onchain

All three are required when onchain mode is active:

VariableDescription
SUI_CONTRACT_ADDRESSDeployed Move package ID (0x...)
SUI_CART_REGISTRY_IDShared CartRegistry object ID created by init()
SUI_RELAYER_PRIVATE_KEYBech32 Sui private key for the relayer wallet (suiprivkey1...)

Sui Blockchain

VariableDefaultDescription
SUI_RPC_URLhttps://fullnode.testnet.sui.io:443Sui RPC endpoint
WALLET_ENCRYPTION_KEY""32-byte hex key for AES encryption of user Sui private keys

Logging

VariableDefaultDescription
BETTERSTACK_SOURCE_TOKEN""BetterStack source token. If empty, logs go to stdout only.
BETTERSTACK_INGESTING_HOST""BetterStack ingesting hostname (e.g. s2380734.eu-fsn-3.betterstackdata.com)

AI Memory (Optional)

MemWal provides verifiable AI memory. All three must be set to enable memory.

VariableDefaultDescription
MEMWAL_SERVER_URLhttps://relayer.memwal.aiMemWal relayer URL
MEMWAL_DELEGATE_KEY""Delegate key from app.memwal.com
MEMWAL_ACCOUNT_ID""Account ID from app.memwal.com

frontend/ (Next.js)

Set these in frontend/.env.local.

Prop

Type

The Next.js rewrite in next.config.ts forwards all /api/:path* requests to BACKEND_URL (or NEXT_PUBLIC_API_URL).


scraping/ (NestJS)

Copy scraping/.env.example to scraping/.env and fill in the values.

Core

VariableDefaultDescription
NODE_ENVdevelopmentRuntime environment
PORT3000HTTP port the NestJS app listens on

Database (PostgreSQL)

VariableDefaultDescription
DB_URL""Full PostgreSQL connection string. Takes precedence over individual DB_* vars.
DB_DATABASEamazon_shopping_agentDatabase name (used when DB_URL is not set)
DB_SYNCHRONIZEfalseAuto-sync TypeORM schema. Set to false in production — use migrations instead.
DB_MIGRATIONS_RUNfalseRun pending migrations on startup

Redis

VariableDefaultDescription
REDIS_HOSTlocalhostRedis hostname
REDIS_PORT6379Redis port
REDIS_PASSWORDRedis AUTH password (optional)

Apify (Scraping)

VariableDefaultDescription
APIFY_API_TOKEN""Apify personal API token. Required for GET /api/search/realtime.

Sui

VariableDefaultDescription
SUI_NETWORKtestnetSui network name passed to SuiGrpcClient
SUI_RPC_URLhttps://fullnode.testnet.sui.io:443Sui gRPC full-node URL
SUI_MERCHANT_ADDRESS""Sui address that receives payments. Required — omitting disables the Sui guard.
SUI_PAYMENT_AMOUNT_MIST1000000000 (1 SUI)Minimum accepted payment in MIST
SUI_COIN_TYPE0x2::sui::SUIMove coin type accepted for payments
SUI_REGISTRY_NAMEPayment Kit registry name for nonce-based record lookup

backend/ Webhook

VariableDefaultDescription
COMAGENT_BASE_URLhttp://localhost:3001Base URL of the backend/ service. Used for forwarding Sui deposit confirmations.
DEPOSIT_WEBHOOK_SECRET""Shared secret sent in X-Webhook-Secret header on deposit webhook calls.

Development

VariableDefaultDescription
TEST_SUI_PRIVATE_KEYSui private key for local test scripts (e.g. scripts/test-sui-payment.ts). Never set in production.

How is this guide?

On this page