Moai platform deployment

From modu-ai/moai-adk · View interactive version

Moai platform deployment is an AI agent skill from the GitHub repository modu-ai/moai-adk. Deployment and hosting platform specialist covering Vercel, Railway, and Convex. Use when deploying applications, configuring edge functions, setting up continuous deployment, or managing serverless infrastructure.

How to use this skill

Skill file

Deployment Platform Specialist

Comprehensive deployment platform guide covering Vercel (edge-first), Railway (container-first), and Convex (real-time backend).


Quick Platform Selection

When to Use Each Platform

Vercel - Edge-First Deployment:

Railway - Container-First Deployment:

Convex - Real-Time Backend:


Decision Guide

By Application Type

Web Applications (Frontend + API):

Mobile Backends:

Full-Stack Monoliths:

By Infrastructure Needs

Compute Requirements:

Storage Requirements:

Networking Requirements:


Common Deployment Patterns

Pattern 1: Next.js with Database

Stack: Vercel + Vercel Postgres/KV

Setup:

  1. Deploy Next.js app to Vercel
  2. Provision Vercel Postgres for database
  3. Use Vercel KV for session/cache
  4. Configure environment variables
  5. Enable ISR for dynamic content

Best For: Web apps with standard database needs, e-commerce, content sites

Pattern 2: Containerized Multi-Service

Stack: Railway + Docker

Setup:

  1. Create multi-stage Dockerfile
  2. Configure railway.toml for services
  3. Set up private networking
  4. Configure persistent volumes
  5. Enable auto-scaling

Best For: Microservices, complex backends, custom tech stacks

Pattern 3: Real-Time Collaborative App

Stack: Convex + Vercel/Railway (frontend)

Setup:

  1. Initialize Convex backend
  2. Define schema and server functions
  3. Deploy frontend to Vercel/Railway
  4. Configure Convex provider
  5. Implement optimistic updates

Best For: Collaborative tools, live dashboards, chat applications

Pattern 4: Hybrid Edge + Container

Stack: Vercel (frontend/edge) + Railway (backend services)

Setup:

  1. Deploy Next.js frontend to Vercel
  2. Deploy backend services to Railway
  3. Configure CORS and API endpoints
  4. Set up edge middleware for routing
  5. Use private networking for Railway

Best For: High-performance apps, global distribution with complex backends

Pattern 5: Serverless Full-Stack

Stack: Vercel (frontend + API routes) + Convex (backend)

Setup:

  1. Build Next.js app with API routes
  2. Initialize Convex for data layer
  3. Configure authentication (Clerk/Auth0)
  4. Deploy frontend to Vercel
  5. Connect Convex client

Best For: Rapid prototyping, startups, real-time web apps


Essential Configuration

Vercel Quick Start

vercel.json:

{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "framework": "nextjs",
  "regions": ["iad1", "sfo1", "fra1"],
  "functions": {
    "app/api/**/*.ts": {
      "memory": 1024,
      "maxDuration": 10
    }
  }
}

Edge Function:

export const runtime = "edge"
export const preferredRegion = ["iad1", "sfo1"]

export async function GET(request: Request) {
  const country = request.geo?.country || "Unknown"
  return Response.json({ country })
}

Railway Quick Start

railway.toml:

[build]
builder = "DOCKERFILE"
dockerfilePath = "Dockerfile"

[deploy]
healthcheckPath = "/health"
healthcheckTimeout = 100
restartPolicyType = "ON_FAILURE"
numReplicas = 2

[deploy.resources]
memory = "2GB"
cpu = "2.0"

Multi-Stage Dockerfile:

# Builder stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Runner stage
FROM node:20-alpine
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup -g 1001 -S nodejs && adduser -S appuser -u 1001
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
USER appuser
EXPOSE 3000
CMD ["node", "dist/main.js"]

Convex Quick Start

convex/schema.ts:

import { defineSchema, defineTable } from "convex/server"
import { v } from "convex/values"

export default defineSchema({
  messages: defineTable({
    text: v.string(),
    userId: v.id("users"),
    timestamp: v.number(),
  })
    .index("by_timestamp", ["timestamp"])
    .searchIndex("search_text", {
      searchField: "text",
      filterFields: ["userId"],
    }),
})

React Integration:

import { useQuery, useMutation } from "convex/react"
import { api } from "../convex/_generated/api"

export function Messages() {
  const messages = useQuery(api.messages.list)
  const sendMessage = useMutation(api.messages.send)

  if (!messages) return <div>Loading...</div>

  return (
    <div>
      {messages.map((msg) => (
        <div key={msg._id}>{msg.text}</div>
      ))}
    </div>
  )
}

CI/CD Integration

GitHub Actions - Vercel

name: Deploy to Vercel
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: amondnet/vercel-action@v25
        with:
          vercel-token: ${{ secrets.VERCEL_TOKEN }}
          vercel-org-id: ${{ secrets.ORG_ID }}
          vercel-project-id: ${{ secrets.PROJECT_ID }}

GitHub Actions - Railway

name: Deploy to Railway
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: npm install -g @railway/cli
      - run: railway up --detach
        env:
          RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}

GitHub Actions - Convex

name: Deploy to Convex
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
      - run: npm ci
      - run: npx convex deploy
        env:
          CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }}

Advanced Patterns

Blue-Green Deployment (Vercel)

Deploy new version, test on preview URL, then switch production alias using Vercel SDK for zero-downtime releases.

Multi-Region (Railway)

Configure deployment regions in railway.toml:

[deploy.regions]
name = "us-west"
replicas = 2

[[deploy.regions]]
name = "eu-central"
replicas = 1

Optimistic Updates (Convex)

const sendMessage = useMutation(api.messages.send)

const handleSend = (text: string) => {
  sendMessage({ text })
    .then(() => console.log("Sent"))
    .catch(() => console.log("Failed, rolled back"))
}

Platform-Specific Details

For detailed platform-specific patterns, configuration options, and advanced use cases, see:


Works Well With


Status: Production Ready

Version: 2.0.0

Updated: 2026-02-09

Platforms: Vercel, Railway, Convex

<!-- moai:evolvable-start id="rationalizations" -->

Common Rationalizations

| Rationalization | Reality |

|---|---|

| "I will configure the deployment platform after development is complete" | Deployment configuration affects build output, environment variables, and runtime behavior. Configure early. |

| "Preview deployments are optional" | Preview deployments catch deployment-specific bugs before production. They cost little and save a lot. |

| "Environment variables are the same across all environments" | Production, staging, and development need different database URLs, API keys, and feature flags. One set of env vars is a security risk. |

| "Serverless cold starts are negligible" | Cold starts add 200-2000ms latency on first request. For user-facing APIs, this matters. Measure and mitigate. |

| "I do not need a rollback strategy, I can just redeploy" | Redeployment takes minutes. Rollback takes seconds. When production is down, seconds matter. |

<!-- moai:evolvable-end -->

<!-- moai:evolvable-start id="red-flags" -->

Red Flags

<!-- moai:evolvable-end -->

<!-- moai:evolvable-start id="verification" -->

Verification

<!-- moai:evolvable-end -->

Refactor Notes

R4 audit verdict (2026-04-23): REFACTOR — shrink triplet to Vercel-only primary; Railway/Convex as documentation-only

SPEC: SPEC-V3R2-WF-001 §6.2 line 271

Refactor scope (deferred to future sub-SPEC):

This skill is retained in v3.0 but its body will be restructured in a follow-up SPEC.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.