A Cloudflare Workers gateway between the sushrutalgs.ai web and iOS apps and the AI backend, giving both clients one trusted entry point for authentication, usage limits and streaming responses.
The product has two clients, a web app and a native iOS app, that reach the same AI backend. Letting each call the backend directly would mean shipping credentials inside an app binary and writing sign-in and usage-limit rules twice, in two languages, where they drift. The gateway exists so there is exactly one place that knows who the user is and what they are allowed.
A lightweight edge service that authenticates both clients, enforces each user's plan limits correctly even when requests arrive at the same instant, and streams the AI backend's answers straight through without buffering. It fails closed: anything that could go wrong is resolved before the first byte of a response leaves, so a user is never charged twice or given an answer outside their plan.
It is live in staging and production, serving both clients with low single-digit-millisecond overhead at the edge, and held 200 concurrent requests with zero errors under load testing. Staging and production deploy separately, so a web change cannot take the shipped iOS app down with it.