Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Multi-Frontend Strategy

Kairos supports multiple frontends — CLI and Web App (React) — all powered by a single API backend.

Why a Unified API?

All clients go through one HTTP API — no exceptions:

graph TD
    CLI["kairos-cli\n(clap)"]
    Web["Web App\n(React)"]

    Client["kairos-client\n(shared HTTP client)"]

    API["kairos-api\n(axum server)"]

    CLI --> Client
    Web -->|HTTP/WS| API
    Client -->|HTTP/WS| API

    API --> Core["kairos-core"]
    API --> Platform["kairos-platform"]
    API --> LLM["kairos-llm"]
    API --> DB["kairos-db"]

Benefits

BenefitExplanation
Single source of truthBusiness logic lives in one place — the API layer
Behavioral consistencyAll frontends produce identical results
Easier maintenanceFix a bug once, all clients benefit
Auth in one placeAPI handles authentication; clients just pass tokens
TestableAPI endpoints can be tested independently of any frontend

Trade-offs

ConcernMitigation
CLI needs a running serverCLI can auto-spawn a local server if not running
Network overheadLocalhost HTTP adds < 1ms; LLM/scraping calls are seconds

Prior Art

This is a well-established pattern:

  • Docker CLI → Docker daemon REST API
  • GitHub CLI (gh) → GitHub REST/GraphQL API
  • Kubernetes kubectl → kube-apiserver
  • Terraform CLI → Terraform Cloud API

Shared Client Library

The CLI uses kairos-client — a Rust HTTP client library wrapping all API calls:

#![allow(unused)]
fn main() {
// kairos-client provides typed API access
let client = KairosClient::new("http://localhost:3001");
let jobs = client.jobs().search(criteria).await?;
let analysis = client.jobs().analyze(job_id).await?;
}

The Web App (React) calls the same API endpoints directly via fetch / WebSocket.

Frontend Summary

FrontendTechnologyConnectionTimeline
CLIclap + kairos-clientHTTP to APIShort term
Web AppReactHTTP/WS to APILong term