Architecture
Three Cloudflare Workers, one Postgres database, one media bucket, and the paths a request takes through them.
AdStack is three Cloudflare Workers around one Postgres database.
Why three Workers
The split is not decorative. Each Worker exists because of a constraint:
- The app Worker serves requests. It must answer fast and cannot hold a connection open for a two-minute LLM generation or a five-minute video render.
- The agents Worker owns every LLM call. Centralizing them means one place holds the AI Gateway credentials, one place implements prompt caching, and one place streams. The app never talks to Anthropic directly.
- The pipeline Worker owns everything asynchronous. Image and video generation, offer scraping, cleanup crons. It consumes Cloudflare Queues, so work survives the request that started it.
The database is the exception
Everything runs on Cloudflare except the database, which is Railway Postgres reached through Hyperdrive for connection pooling.