Architecture
Monorepo structure, packages, and infrastructure.
Overview
otto is a Bun workspace monorepo with 7 apps, 7 packages, and SST infrastructure.
- CLI binary starts a local HTTP server (Hono) and launches the interactive TUI by default
- Server manages sessions, persists messages to SQLite, and streams AI responses via SSE
- SDK handles provider resolution, tool execution, agent prompts, and authentication
- Web UI, desktop app, and TUI app are clients that talk to the local server API
The CLI binary is self-contained — built with bun build --compile, it bundles everything into a single executable.
Project Structure
otto/
├── apps/
│ ├── cli/ # CLI binary (Commander, bun build --compile)
│ ├── tui/ # Interactive terminal UI client (OpenTUI + React)
│ ├── web/ # Web UI (React + Vite + TanStack)
│ ├── desktop/ # Desktop app (Tauri v2)
│ ├── setu/ # AI provider proxy (Solana payments)
│ ├── preview-api/ # Session sharing API
│ └── preview-web/ # Public session viewer (Astro)
├── packages/
│ ├── sdk/ # Core SDK: tools, agents, auth, config
│ ├── server/ # HTTP API server (Hono)
│ ├── database/ # SQLite + Drizzle ORM
│ ├── api/ # Type-safe API client
│ ├── web-sdk/ # React components, hooks, stores
│ ├── web-ui/ # Pre-built static web UI assets
│ └── install/ # npm installer package
├── infra/ # SST infrastructure (AWS + Cloudflare)
├── tests/ # bun:test suites
└── scripts/ # Build and utility scriptsApps
apps/cli
Main CLI application. Compiles to a self-contained binary (~61MB) via bun build --compile.
- Framework: Commander for argument parsing
- Dependencies: @ottocode/sdk, @ottocode/server, @ottocode/database
apps/tui
Interactive terminal UI client built with OpenTUI + React. Uses @ottocode/api as the typed interface to server routes.
- Command:
bun run --filter @ottocode/tui dev - Rule: Prefer SDK methods from
@ottocode/apiover directfetchcalls
apps/web
Web UI client for the otto server.
- Stack: React 19, Vite, TanStack Router + Query, Tailwind CSS, Zustand
- Features: Real-time chat via SSE, session management, syntax highlighting
apps/desktop
Desktop application via Tauri v2. Embeds CLI binary and web UI.
- Platforms: macOS (dmg), Linux (deb), Windows (msi)
Packages
@ottocode/sdk
Core SDK. Tree-shakable.
agent/— Agent type definitionsauth/— OAuth flows, wallet auth, API key managementconfig/— Configuration loading, path resolutioncore/— Built-in tools (15+), streaming, terminal managementprompts/— System prompts for agents and providersproviders/— Provider catalog, client factories, model resolution
@ottocode/server
HTTP API server built on Hono.
- Routes: ask (SSE), sessions, messages, files, auth, git, terminals, config
- Exports:
createApp,createEmbeddedApp,createStandaloneApp
@ottocode/database
SQLite persistence with Drizzle ORM.
- Schema: sessions, messages, messageParts, artifacts
- Features: Auto-migrations on startup
@ottocode/api
Type-safe API client generated from OpenAPI spec via @hey-api/openapi-ts.
API update workflow: implement route methods, update packages/server/src/openapi/spec.ts, then run bun run --filter @ottocode/api generate.
@ottocode/web-sdk
Reusable React components, hooks, and Zustand stores for building otto web interfaces.
Dependency Graph
Level 0 (no deps) install, api, web-ui
Level 1 sdk (auth, config, providers, tools)
Level 2 database (depends on sdk)
Level 3 server (depends on sdk, database)
Level 4 web-sdk (depends on api, sdk)
Level 5 cli (depends on sdk, server, database)Infrastructure (SST)
All infra defined as code using SST with AWS and Cloudflare providers.
| Resource | Platform | Domain |
|---|---|---|
| Setu | Cloudflare Worker | setu.ottocode.io |
| Preview API | Cloudflare Worker + D1 | api.share.ottocode.io |
| Preview Web | AWS (Astro SSR) | share.ottocode.io |
| Install Script | Cloudflare Worker | install.ottocode.io |
Tech Stack
| Layer | Technology |
|---|---|
| Runtime | Bun |
| AI | AI SDK v6 |
| Server | Hono |
| Database | SQLite + Drizzle ORM |
| Web UI | React 19, Vite, TanStack, Tailwind CSS, Zustand |
| Desktop | Tauri v2 |
| Infrastructure | SST (AWS + Cloudflare) |
| Linting | Biome |
| Testing | bun:test |