Deploy Jerai backend with all 3 sponsor technologies (Cerebras, Llama, Docker MCP Gateway) to Railway for hackathon judging.
- Backend runs locally:
docker-compose up - MySQL accessible at
localhost:3306 - Backend API responds at
http://localhost:8000 - Frontend connects to backend successfully
- Have
CEREBRAS_API_KEYready
mkdir -p mcp_gatewayFile: mcp_gateway/gateway.py
from flask import Flask, request, jsonify
import requests
import os
app = Flask(__name__)
MCP_AGENT_URL = os.getenv('MCP_AGENT_URL', 'http://mcp_agent:9000')
@app.route('/health', methods=['GET'])
def health():
return jsonify({"status": "healthy", "service": "mcp-gateway"})
@app.route('/generate-patch', methods=['POST'])
def generate_patch():
"""Proxy request to MCP Agent running Llama"""
try:
data = request.json
print(f"Gateway received request: {data.get('title', 'N/A')}")
response = requests.post(
f"{MCP_AGENT_URL}/generate-patch",
json=data,
timeout=120
)
return jsonify(response.json()), response.status_code
except Exception as e:
return jsonify({"error": str(e)}), 500
if __name__ == '__main__':
app.run(host='0.0.0.0', port=3000)File: mcp_gateway/requirements.txt
flask==3.0.3
requests==2.32.3
File: mcp_gateway/Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY gateway.py .
EXPOSE 3000
CMD ["python", "gateway.py"]Replace the mcp-gateway service section:
OLD:
mcp-gateway:
image: mcp/gateway:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sockNEW:
mcp-gateway:
build: ./mcp_gateway
environment:
- MCP_AGENT_URL=http://mcp_agent:9000
ports:
- "3000:3000"
depends_on:
- mcp_agentFile: backend/app.py
Add this endpoint:
@app.route('/health', methods=['GET'])
def health():
return jsonify({"status": "healthy", "service": "backend"})File: .env.production.example
# MySQL (Railway will auto-provide these)
MYSQL_HOST=mysql.railway.internal
MYSQL_PORT=3306
MYSQL_DATABASE=railway
MYSQL_USER=root
MYSQL_PASSWORD=<auto-generated>
# Backend
FLASK_ENV=production
SECRET_KEY=<generate-random-string>
DATABASE_URL=mysql+pymysql://${MYSQL_USER}:${MYSQL_PASSWORD}@${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}
# Cerebras API (YOU MUST ADD THIS)
CEREBRAS_API_KEY=your_cerebras_key_here
CEREBRAS_API_URL=https://api.cerebras.ai/v1/chat/completions
# MCP Gateway
MCP_GATEWAY_URL=http://mcp-gateway:3000- Visit: https://cloud.cerebras.ai/
- Sign up / Login
- Go to API Keys section
- Generate new key
- Copy key (save for later)
npm install -g @railway/cliVerify installation:
railway --versionrailway login(Opens browser, authenticate with GitHub)
# In your project root directory
railway init- Choose: "Empty Project"
- Name: "jerai-hackathon"
railway add- Select: "MySQL"
- Railway provisions managed MySQL instance
railway link- Select your
jerai-hackathonproject
# Set Cerebras API key
railway variables set CEREBRAS_API_KEY=your_actual_key_here
# Set other required variables
railway variables set FLASK_ENV=production
railway variables set MCP_GATEWAY_URL=http://mcp-gateway:3000
railway variables set CEREBRAS_API_URL=https://api.cerebras.ai/v1/chat/completions# Deploy backend
railway up --service backendRailway will:
- Upload your code
- Build Docker image from
backend/Dockerfile - Start the container
- Assign a public URL
# Deploy MCP Gateway
railway up --service mcp-gateway# Deploy MCP Agent
railway up --service mcp_agent# Connect to backend service and run init scripts
railway run --service backend bash
# Inside the Railway shell:
mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < db/init/01_schema.sql
mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < db/init/02_seed.sql
exitrailway statusCopy your backend URL (e.g., https://jerai-backend-production.up.railway.app)
# Test backend health
curl https://your-backend-url.railway.app/health
# Expected response:
{"status": "healthy", "service": "backend"}# List issues
curl https://your-backend-url.railway.app/api/issues
# Expected: JSON array of issues# View backend logs
railway logs --service backend
# View MCP Gateway logs
railway logs --service mcp-gateway
# View MCP Agent logs
railway logs --service mcp_agentFile: frontend/.env.production
VITE_API_BASE=https://your-backend-url.railway.appcd frontend
npm install
npm run build# Install Vercel CLI (if not installed)
npm install -g vercel
# Deploy
vercel --prodFollow prompts:
- Set up and deploy? Y
- Which scope? Your account
- Link to existing project? N
- Project name? jerai-hackathon
- Directory? ./dist
- Override settings? N
Copy the deployment URL (e.g., https://jerai-hackathon.vercel.app)
- Open frontend:
https://jerai-hackathon.vercel.app - See seeded bug in "New" column
- Click "Activate" button
- Bug moves to "Active" column
- Click "AI Fix" button
- Wait for processing (~10-30 seconds)
- Bug moves to "Resolved" column
- Click on bug card
- View Event Trail
- Verify events appear:
- IssueCreated
- StateChanged (New → Active)
- AIFixRequested
- AnalysisComplete (from Cerebras)
- PatchProposed (from Llama via MCP Gateway)
- StateChanged (Active → Resolved)
Check logs to confirm all 3 sponsors were used:
# Check Cerebras API call
railway logs --service backend | grep cerebras
# Check MCP Gateway routing
railway logs --service mcp-gateway | grep generate-patch
# Check Llama execution
railway logs --service mcp_agent | grep llamaFile: DEPLOYMENT.md
# Deployed Demo
**Live Application**: https://jerai-hackathon.vercel.app
**Backend API**: https://jerai-backend-production.up.railway.app
**GitHub Repository**: https://github.com/yourusername/jerai
## Sponsor Technologies Used
1. **Cerebras API**: Fast bug analysis (< 1 second)
- See: `backend/services/ai_service.py:15`
2. **Meta Llama 3.1**: Code patch generation
- See: `mcp_agent/agent.py:30`
3. **Docker MCP Gateway**: Container orchestration
- See: `mcp_gateway/gateway.py` + `docker-compose.yml`
## Architecture
- Frontend: Vercel (React + TypeScript)
- Backend: Railway (Flask + Docker)
- Database: Railway MySQL
- MCP Services: Railway Docker containers
## Test Credentials
Demo bug pre-loaded: "Cart total calculation incorrect"Record 2-minute video showing:
- Opening the app
- Activating a bug
- Triggering AI fix
- Showing the generated patch in Event Trail
- Explaining the 3 sponsor technologies
Upload to: YouTube (unlisted) or Loom
- Frontend deployed and accessible
- Backend deployed and API working
- All 3 sponsor technologies confirmed in code
- GitHub repo public with README
- Demo video uploaded
-
DEPLOYMENT.mdwith live URLs -
.env.examplefiles for reproducibility
Solution: Check railway logs for errors
railway logs --service backendSolution: Verify DATABASE_URL variable
railway variablesSolution: Check internal networking
# Verify MCP_AGENT_URL is set
railway run --service mcp-gateway env | grep MCP_AGENT_URLSolution: Check backend CORS settings in backend/app.py
CORS(app, resources={r"/*": {"origins": ["https://jerai-hackathon.vercel.app"]}})Solution: Verify API key
railway variables | grep CEREBRAS_API_KEY- Railway: $5 free credit (enough for demo)
- Vercel: Free tier (unlimited)
- Cerebras: Free tier (50 requests/day)
Total: $0 for hackathon demo
If deployment fails:
# Destroy Railway deployment
railway down
# Start over from Phase 4✅ Frontend loads without errors ✅ Can create new issues ✅ Can transition issue states ✅ AI Fix completes successfully ✅ Event Trail shows all 3 sponsor outputs ✅ All services healthy in Railway dashboard ✅ Demo video under 2 minutes ✅ GitHub repo public and documented
- Submit hackathon entry with live URLs
- Share demo video
- Monitor Railway dashboard for errors
- Keep services running until judging complete
- Add deployment link to GitHub README
Estimated Total Time: 45-60 minutes Current Phase: Phase 1 (MCP Gateway Creation)