Architecture

Monorepo structure, packages, and infrastructure.

Overview

otto is a Bun workspace monorepo with 7 apps, 7 packages, and SST infrastructure.

  1. CLI binary starts a local HTTP server (Hono) and launches the interactive TUI by default
  2. Server manages sessions, persists messages to SQLite, and streams AI responses via SSE
  3. SDK handles provider resolution, tool execution, agent prompts, and authentication
  4. 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 scripts

Apps

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/api over direct fetch calls

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 definitions
  • auth/ — OAuth flows, wallet auth, API key management
  • config/ — Configuration loading, path resolution
  • core/ — Built-in tools (15+), streaming, terminal management
  • prompts/ — System prompts for agents and providers
  • providers/ — 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.

ResourcePlatformDomain
SetuCloudflare Workersetu.ottocode.io
Preview APICloudflare Worker + D1api.share.ottocode.io
Preview WebAWS (Astro SSR)share.ottocode.io
Install ScriptCloudflare Workerinstall.ottocode.io

Tech Stack

LayerTechnology
RuntimeBun
AIAI SDK v6
ServerHono
DatabaseSQLite + Drizzle ORM
Web UIReact 19, Vite, TanStack, Tailwind CSS, Zustand
DesktopTauri v2
InfrastructureSST (AWS + Cloudflare)
LintingBiome
Testingbun:test