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

Tech Stack Decisions (DEPRECATED - API-First Architecture)

Note: This document describes the original API-first architecture with a REST backend. The project has shifted to a TUI-first, dual-target architecture (native terminal + WASM web). This document is kept for reference but the current approach does not use a web framework like Axum.

Summary

After evaluating the options, here are the recommended technologies for robit:

Core Framework

ComponentChoiceRationale
Web FrameworkAxumTokio-native, excellent middleware, type-safe
NoteN/ANot needed for TUI architecture - see revised stack
Async RuntimeTokioIndustry standard, comprehensive ecosystem
SerializationSerdeStandard, zero-cost abstractions
Error Handlingthiserror + anyhowStructured errors where needed, ergonomic elsewhere

Data Layer

ComponentChoiceRationale
DatabasePostgreSQLRobust, ACID, JSON support
Database ClientSQLxCompile-time checked, async-native
CacheRedisFast, pub/sub, rate limiting
Redis Clientredis (with tokio-comp features)Native async
Migrationssqlx-cliIntegrated with SQLx

LLM Integration

ComponentChoiceRationale
LLM Trait SystemCustomMulti-provider support, unified interface
HTTP ClientreqwestBuilt on hyper, async-native, widely used
Streamingfutures + tokio-streamAsync stream handling
JSON SchemaschemarsGenerate schemas from types
ValidationvalidatorInput validation with derives

Security & Sandboxing

ComponentChoiceRationale
Primary SandboxWasmtimeFast, capability-based, safe
Secondary SandboxgVisorStrong isolation for complex code
Authenticationjsonwebtoken + custom API keyFlexible auth strategies
Hashingargon2Modern, secure password hashing
SecretsHashiCorp Vault clientProduction secret management

Observability

ComponentChoiceRationale
LoggingtracingStructured, async-aware
Log Outputtracing-subscriberFlexible formatting
Metricsmetrics + metrics-exporter-prometheusStandard observability
Distributed Tracingtracing-opentelemetryJaeger/Zipkin compatible

Development Tools

ComponentChoiceRationale
ConfigurationconfigLayered config (file, env, CLI)
CLI Parsingclap v4Derive macros, comprehensive
EnvironmentdotenvyDevelopment environment variables
Testing HTTPwiremockMock HTTP servers
Testing DBtestcontainersReal database in tests
Property TestsproptestFuzzing and edge cases
LintingclippyRust best practices
FormattingrustfmtConsistent style

Deployment & Operations

ComponentChoiceRationale
ContainerDistroless or AlpineMinimal attack surface
OrchestrationKubernetesIndustry standard
Service MeshLinkerd or Istio (optional)mTLS, observability
TLSrustlsPure Rust, audited

Cargo.toml Skeleton

[package]
name = "robit"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"

[dependencies]
# Core async runtime
tokio = { version = "1", features = ["full"] }
tokio-stream = "0.1"

# Web framework
axum = { version = "0.7", features = ["ws"] }
tower = "0.4"
tower-http = { version = "0.5", features = ["trace", "cors", "limit"] }

# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

# Database
sqlx = { version = "0.7", features = ["runtime-tokio", "tls-rustls", "postgres", "uuid", "chrono"] }
redis = { version = "0.24", features = ["tokio-comp", "connection-manager"] }

# HTTP client
reqwest = { version = "0.11", features = ["json", "stream", "rustls-tls"] }

# Validation
validator = { version = "0.16", features = ["derive"] }
schemars = "0.8"

# Security
jsonwebtoken = "9"
argon2 = "0.5"

# Sandboxing
wasmtime = "16"
wasmtime-wasi = "16"

# Observability
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
metrics = "0.22"
metrics-exporter-prometheus = "0.13"

# Error handling
thiserror = "1.0"
anyhow = "1.0"

# Utilities
config = "0.14"
clap = { version = "4.5", features = ["derive", "env"] }
uuid = { version = "1.6", features = ["v4", "serde"] }
chrono = { version = "0.4", features = ["serde"] }
once_cell = "1.19"

[dev-dependencies]
tokio-test = "0.4"
wiremock = "0.6"
testcontainers = "0.15"
proptest = "1.4"

Project Structure

robit/
├── Cargo.toml
├── README.md
├── docs/                    # mdbook documentation
│   ├── book.toml
│   └── src/
├── crates/                  # Workspace members
│   ├── robit-core/        # Core engine
│   ├── robit-api/         # HTTP API server
│   ├── robit-cli/         # Command-line tool
│   ├── robit-sandbox/     # Sandboxing implementations
│   ├── robit-llm/         # LLM provider abstractions
│   └── robit-types/       # Shared types
├── migrations/              # SQLx migrations
├── scripts/                 # Development scripts
├── docker/                  # Container configurations
└── tests/                   # Integration tests

Next Steps

  1. Initialize Cargo workspace
  2. Set up development environment
  3. Create core types crate
  4. Implement LLM trait system
  5. Build basic API server scaffold
  6. Add first sandbox implementation (WASM)
  7. Implement conversation management
  8. Add authentication layer
  9. Create CLI tool
  10. Write integration tests

See Phase 1: Foundation for detailed implementation plan.