A realistic production-like application for testing AI on-call agents.
This is a test application that simulates a customer's real production environment. It's designed to help you build and validate AI agents that can monitor applications, detect incidents, and automatically remediate issues using official Vercel and Railway APIs.
The app consists of three services:
- API Service (Vercel): Handles event ingestion, metrics, and health checks
- Worker Service (Railway): Background processor that runs every 10 seconds
- Cron Service (Railway): Cleanup tasks that run every 60 seconds
- Database (MongoDB): Stores events, metrics, and system state
API Service (Next.js on Vercel):
/api/events- Receives analytics events from users/api/metrics- Returns aggregated analytics data/api/health- Health check endpoint (status, database connection)/api/trigger-incident- Manually trigger test incidents for agent testing- Dashboard at
/- UI to view metrics and trigger incidents
Worker Service (Node.js on Railway):
- Polls
events_rawcollection every 10 seconds - Processes up to 50 events per batch
- Aggregates metrics by user and action
- Moves processed events to
events_processedcollection - Logs:
WORKER_JOB_START,WORKER_JOB_DONE,WORKER_PARSE_ERROR,DB_CONNECTION_FAILED
Cron Service (Node.js on Railway):
- Runs every 60 seconds
- Deletes records older than 30 days from processed events
- Updates heartbeat in
cron_statuscollection - Logs:
CRON_HEARTBEAT,CRON_CLEANUP_DONE,CRON_DB_ERROR
Logging:
- All services emit structured JSON logs to stdout
- Vercel and Railway automatically capture these logs
- Your AI agent queries these logs using official platform APIs
Vercel hosts the Next.js API service and provides:
Deployment:
- Hosts the API endpoints at your production domain
- Automatically builds and deploys from Git
- Provides serverless function execution
Logs:
- Captures all console.log output from API routes
- Stores logs accessible via Vercel REST API
- Your agent queries:
GET https://api.vercel.com/v2/deployments/{id}/events
What Your Agent Can Do:
- Monitor: Query Vercel API for deployment logs and error rates
- Rollback: Use Vercel API to rollback to previous deployment if errors detected
- Example: High API error rate (>10 errors in 5 min) triggers rollback
Railway hosts the Worker and Cron services and provides:
Deployment:
- Runs Node.js services as containers
- Provides persistent processes (not serverless)
- Auto-restarts on crashes
Logs:
- Captures all console.log output from services
- Accessible via Railway CLI or GraphQL API
- Your agent queries:
railway logs --service worker
What Your Agent Can Do:
- Monitor: Query Railway logs for worker status, error patterns
- Restart: Use Railway GraphQL API to restart stuck or failing services
- Example: No
WORKER_JOB_DONElogs for 5+ minutes triggers restart
Option 1: Via Dashboard
- Open your deployed app:
https://your-app.vercel.app - Click one of the incident buttons
Option 2: Via API
curl -X POST https://your-app.vercel.app/api/trigger-incident \
-H "Content-Type: application/json" \
-d '{"incident": "stuck_worker"}'FIXABLE BY AGENT (Restart/Rollback):
1. Stuck Worker
- What it does: Creates 100 unprocessed events in MongoDB
- How to detect: No
WORKER_JOB_DONElogs in Railway for 5+ minutes - How to fix: Restart Railway worker service via GraphQL API
# Your agent should call:
POST https://backboard.railway.app/graphql/v2
mutation { serviceInstanceRedeploy(serviceId: "worker-id") }2. High Error Rate
- What it does: Generates 20+ error logs in worker
- How to detect: >10
WORKER_PARSE_ERRORlogs in 5 minutes - How to fix: Restart Railway worker service
# Same as above - restart the worker3. Bad Deployment
- What it does: Creates 15+ API errors in Vercel logs
- How to detect: >10 HTTP 500 errors in Vercel logs in 5 minutes
- How to fix: Rollback Vercel deployment to previous version
# Your agent should call Vercel API:
POST https://api.vercel.com/v2/deployments/{previous-id}/aliases
Body: {"alias": "your-app.vercel.app"}REQUIRES DEVELOPER INTERVENTION (Not Fixable by Restart):
4. DB Connection Loss
- What it does: Logs 5+ database connection failures
- How to detect:
DB_CONNECTION_FAILEDerrors in Railway logs - What agent should do: Attempt restart once, then escalate to developer
- Why not fixable: Database is down - restart won't help
5. Persistent Errors
- What it does: Creates 30 events that fail schema validation
- How to detect:
WORKER_PERSISTENT_ERRORwith retries=5 in logs - What agent should do: Detect errors persist after restart, escalate to developer
- Why not fixable: Code-level bug - requires code fix
npm run install:allcp config.sample.json config.json
# Edit config.json - add your MongoDB URInpm run devVisit http://localhost:3000
API to Vercel:
cd services/api
vercel --prodWorker to Railway:
cd services/worker
railway upCron to Railway:
cd services/cron
railway upGET /api/health- System health checkGET /api/metrics- Aggregated analyticsPOST /api/events- Send analytics eventPOST /api/trigger-incident- Trigger test incident
Edit config.json:
{
"MONGODB_URI": "mongodb+srv://...",
"VERCEL_TOKEN": "your-vercel-token",
"RAILWAY_TOKEN": "your-railway-token",
"API_FAILURE_MODE": "none", // none|db|random_500
"WORKER_FAILURE_MODE": "none", // none|crash|slow|bad_schema
"CRON_FAILURE_MODE": "none" // none|timeout|db_fail
}Worker Logs (Railway):
WORKER_JOB_START- Job startedWORKER_JOB_DONE- Job completed successfullyWORKER_PARSE_ERROR- Event parsing failedDB_CONNECTION_FAILED- Database errorWORKER_PERSISTENT_ERROR- Code-level bug
Cron Logs (Railway):
CRON_HEARTBEAT- Cron is aliveCRON_CLEANUP_DONE- Cleanup completedCRON_DB_ERROR- Database error
API Logs (Vercel):
EVENT_INSERTED- Event savedAPI_FAILURE_INJECTED- Test failure triggeredHEALTH_CHECK_FAILED- Health check failed
services/
├── api/ # Next.js API (Vercel)
│ ├── pages/api/
│ │ ├── events.js # Event ingestion
│ │ ├── metrics.js # Analytics
│ │ ├── health.js # Health check
│ │ └── trigger-incident.js
│ └── lib/
│ ├── mongo.js
│ └── logger.js
├── worker/ # Background worker (Railway)
│ ├── worker.js
│ └── lib/
└── cron/ # Scheduled jobs (Railway)
├── cron.js
└── lib/
config.json # Your secrets (DO NOT COMMIT!)
config.sample.json # Template
config.jsonis in.gitignore- NEVER commit it- Contains MongoDB URI, Vercel token, Railway token
- Each service reads from
config.jsonor environment variables
MIT