Message flow
The complete path of a message from your phone to your agent and back:Serverless-first design
The web app runs entirely on Vercel as serverless functions. There is no always-on server process on the cloud side:- Telegram webhook — Vercel function wakes on each incoming message, processes it, publishes to Redis, and exits.
- Output forwarder — a separate Vercel function subscribes to the output Redis channel for the duration of a session and forwards chunks to Telegram.
- Cron jobs — Vercel cron invocations for trial reminder notifications.
The agent on your machine
The agent is a Node.js process that:- Subscribes to
agent:{agentId}on Redis at startup. - On receiving a
commandevent, calls the configured AI runner with the prompt. - Streams output chunks back to
output:{sessionId}as the runner produces them. - Sends a
doneevent when the runner finishes. - On receiving an
abortevent, kills the runner process and publishes adoneevent.
Why Redis pub/sub?
Redis pub/sub provides:- Low latency — typically under 10ms for a message to travel from publisher to subscriber.
- Streaming-friendly — publish individual chunks as they are produced, subscribe and forward immediately.
- Stateless relay — the Redis server does not need to store messages; subscribers receive them in real time or miss them. No database required for the relay layer.
- Serverless compatible — Vercel functions can subscribe to a Redis channel for the duration of a request without holding a persistent connection from a dedicated server.
Database
PostgreSQL (via Neon) stores persistent state:users— Telegram user ID, plan, subscription statusagents— agent metadata, token hash, online/offline statussessions— session records with prompt preview and statuspairing_codes— short-lived codes with TTL and single-use enforcement