Skip to content

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

LayerRuns onWhat it does
Edge routingCloudflare Workers at api.bhaico.de, agent.bhaico.deAuth-aware routing, KV and D1 access, R2 storage
Agent daemonHostless (bhaicode-agent.hostless.app)Runs agent sessions for Cloud Studio
Control plane and metadataNorthflank, with PostgreSQL 16Projects, sessions, connectors, token vault
Ephemeral buildsModalIsolated build sandboxes with a spend cap
MicroVMsInstabox (Firecracker)Short-lived execution environments that auto-pause
Build cache@bhaicode/cache on D1 + R2Content-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.

FrameworkDeploys to
Golden stack (Vite + React + Hono)Cloudflare Pages + Workers
Next.js App RouterCloudflare Workers via OpenNext, or a container
AstroCloudflare Pages, static-first with islands
TanStack StartCloudflare Pages or Workers
Vue, Nuxt, SvelteKitCloudflare Pages or Workers adapter
Expo / React NativeThe Android build runner
Python, GoAn 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.

Next

Was this page helpful?