Architecture

May 26, 2026 · View on GitHub

OneQuery is a Bun and Turbo monorepo with four main runtime surfaces:

┌─────────────────┐   ┌────────────────────┐
│   CLI (Rust)    │   │   Web UI (React)   │
└────────┬────────┘   └────────┬───────────┘
         │                     │
         ▼                     ▼
┌─────────────────────────────────────────┐
│          API Server (Hono)              │
│  auth · orgs · data-sources · queries  │
└──────────────────┬──────────────────────┘

         ┌─────────┴─────────┐
         ▼                   ▼
┌────────────────┐  ┌────────────────────┐
│ Postgres /     │  │  Connector Agent   │
│ PGlite (ORM)   │  │  (customer infra)  │
└────────────────┘  └────────────────────┘

Runtime surfaces

  • CLI: a Rust binary (onequery) that authenticates via OAuth2 device flow and sends queries to the API. CLI workflows are modeled as reducer-driven state machines.
  • Server: a Hono HTTP API with Zod-validated routes, Better Auth sessions, and Drizzle ORM for Postgres or PGlite.
  • Web UI: a React 19 SPA with TanStack Router, TanStack Query, and XState for complex state.
  • Connector: a lightweight Bun agent deployed on customer infrastructure. It registers with OneQuery, polls for query jobs, executes them locally, and returns results without moving credentials into the hosted control plane.

Result handling

Cross-package query, credential, tester, and runtime boundaries use better-result so success, failure, timeout, and retry paths stay explicit at the state-machine boundary instead of relying on thrown exceptions.

Monorepo setup

For contributor workflow, see CONTRIBUTING.md.