Architecture
How the desktop app, Cloud Studio, the agent core, and the hosting layers fit together.
BhaiCode is one agent core with two front ends and a set of hosting services behind them. This page maps what runs where, so you know which surface a feature belongs to and what a failure actually means.
The two surfaces
Desktop Workspace is a native shell. The Rust core owns the filesystem bridge, the PTY process manager, and the OS keychain. The React front end owns the editor, the canvas, and the diff viewer. Agent edits land in your working tree, which is why the app can offer a git checkpoint rollback.
Cloud Studio is a browser workspace. Compilation happens in the browser, so preview updates do not wait on a remote container. Anything the browser cannot do — provisioning a database, running a deploy, storing a secret — goes through the BhaiCode services.
Hosting layers
| Layer | Runs on | What it does |
|---|---|---|
| Edge routing | Cloudflare Workers at api.bhaico.de, agent.bhaico.de | Auth-aware routing, KV and D1 access, R2 storage |
| Agent daemon | Hostless (bhaicode-agent.hostless.app) | Runs agent sessions for Cloud Studio |
| Control plane and metadata | Northflank, with PostgreSQL 16 | Projects, sessions, connectors, token vault |
| Ephemeral builds | Modal | Isolated build sandboxes with a spend cap |
| MicroVMs | Instabox (Firecracker) | Short-lived execution environments that auto-pause |
| Build cache | @bhaicode/cache on D1 + R2 | Content-addressed task and artifact caching |
The desktop app does not depend on these services for editing. With a local model through Ollama and no account, the whole loop — read, edit, run, review — stays on your machine.
The default stack
When a prompt does not name a framework, BhaiCode builds on its own golden stack: React 19 with Vite and Tailwind, a Hono worker at the edge, Cloudflare D1 through Drizzle, and Better Auth for sessions. The choice is Cloudflare-native because D1 has no cold start and the whole app deploys as Workers and Pages.
Name a different stack and BhaiCode follows you instead. bhaicode.config.json at the project root pins the framework and target; without it, the agent reads next.config.js, astro.config.mjs, vite.config.ts, or app.json to infer one.
| Framework | Deploys to |
|---|---|
| Golden stack (Vite + React + Hono) | Cloudflare Pages + Workers |
| Next.js App Router | Cloudflare Workers via OpenNext, or a container |
| Astro | Cloudflare Pages, static-first with islands |
| TanStack Start | Cloudflare Pages or Workers |
| Vue, Nuxt, SvelteKit | Cloudflare Pages or Workers adapter |
| Expo / React Native | The Android build runner |
| Python, Go | An ephemeral container |
Model routing today
The router package supports eight provider suites with zero-data-retention routing, failover, and cost-ordered selection. The deployed control plane does not fan across them: it pins a single free provider, and that pin is deliberate for the test phase.
The practical consequence: there is no automatic provider failover in the hosted service today. If that provider is unavailable, hosted inference fails until it recovers. Desktop BYOK and local Ollama are unaffected, because those requests never touch the control plane.