Deployment Patterns
When to apply
Apply whenever touching Railway config, Vercel SSE routes, HTTP fetchers, Telegram notifications, or per-phase model selection.
Rules
- Railway terminates TLS and proxies all requests. Do NOT add
TrustedHostMiddlewarerestricting to127.0.0.1— it blocks all cloud traffic. UseALLOWED_ORIGINSfor CORS control instead. - Anthropic docs URLs (
docs.claude.com) redirect toplatform.claude.comandcode.claude.com. Anyhttpxfetcher that hits Anthropic docs must setfollow_redirects=Trueor requests will return 3xx and no content. - Telegram push from any sandboxed Python environment needs only
TELEGRAM_BOT_TOKEN+ achat_id. The fullpython-telegram-botpackage is NOT required —urllib+ a POST toapi.telegram.org/bot{token}/sendMessageis sufficient. Seescripts/send_telegram.py. - Vercel hard-limits SSE responses to 300 seconds. The analysis pipeline must abort in-flight SDK calls at 240 s and send a partial done event before the platform cuts the connection. Use
AbortController— a budget timer alone cannot stop a running SDK call. - Use per-phase model routing to stay within the 300 s Vercel SSE window:
haiku-3-5for inventory and summarisation phases (1, 2, 4) andsonnetfor intelligence phases (3, 5, 6, 7). This cuts total analysis runtime from ~350 s to ~200 s.