Deploying Claire to Railway
A worked example of deploying the Claire API and its dependencies to a managed host.
Railway is the simplest managed path for the Claire API. It suits direct mode well; a full Matrix stack is usually better placed on a VPS beside it.
Prerequisites#
- A Railway account
- A Supabase project for database and auth
- An OpenAI API key, if you want AI features
Quick start#
Install the CLI and sign in
npm install -g @railway/cli railway loginCreate the project
railway initAdd Redis
In the dashboard: + New → Database → Redis. Railway sets
REDIS_URLon the service automatically.Configure environment variables
Variable Value SUPABASE_URLYour Supabase project URL SUPABASE_ANON_KEYSupabase anon key SUPABASE_SERVICE_KEYSupabase service-role key DATABASE_URLSupabase connection string JWT_SECRETRandom 32+ character string ENCRYPTION_KEYRandom 32 hex characters OPENAI_API_KEYYour OpenAI key PLATFORM_MODEMust be set explicitly — the server refuses to guess openssl rand -hex 32 # JWT_SECRET openssl rand -hex 16 # ENCRYPTION_KEYDeploy
railway upOr connect the GitHub repository for automatic deployments on push.
Architecture options#
Direct mode#
Cheaper and simpler, at the cost of maintaining platform integration code and reconnecting WhatsApp after restarts.
Matrix mode#
Matrix needs more services than a single managed service comfortably holds. Two workable shapes:
- Run the Claire server on Railway and the Matrix stack on a VPS, pointing
MATRIX_HOMESERVER_URLat the VPS. - Self-host everything with
docker-compose.prod.yml --profile matrix.
Resource sizing#
| Tier | Resources | Suitable for |
|---|---|---|
| Hobby (~$5/mo) | 512 MB RAM, shared CPU | Testing |
| Pro (~$20/mo) | 2 GB RAM, dedicated CPU | Production, one or two users |
| Team ($50+/mo) | 4 GB+ RAM, multiple replicas | Multiple users |
WhatsApp session persistence#
WhatsApp sessions must survive a redeploy. Either:
- Use a volume. Volumes persist across deploys; configure one in
railway.tomlor the dashboard. - Store sessions in Supabase. Serialize the session data and restore it on startup.
Monitoring#
railway logs
railway status
railway volume listThe health endpoint is /health, and it reports the effective platform mode along with Matrix and schema readiness.
Troubleshooting#
| Symptom | Cause and fix |
|---|---|
| “Cannot find module” | The build did not run bun install. Check the Dockerfile. |
| WhatsApp disconnects after a deploy | Sessions are not on a persistent volume. |
| Memory exhaustion | Puppeteer needs ~1 GB. Upgrade, or switch to Matrix mode. |
| Telegram bot silent | Check TELEGRAM_BOT_TOKEN, and that no second instance is running — Telegram allows only one. |
Rough cost#
| Component | Monthly |
|---|---|
| Railway Pro | $20 |
| Railway Redis | $5 |
| Supabase free tier | $0 |
| OpenAI (estimate) | $10–50 |
| Total | $35–75 |
A Hetzner CAX21 (4 GB ARM, around €7/month) running docker-compose.prod.yml is the cheaper self-hosted alternative, and is the only realistic option for the full Matrix stack.