How thusinh1969/brighto_router works
BrighTO-Router is a self-hosted Rust LLM gateway and model load balancer. Its main workflow accepts a client request, authenticates and applies policy, selects a configured backend, proxies the request, and records usage. The graph also includes the admin portal, protocol translation, and configuration/observability layers. Some endpoint families and integrations are documented in the README but their detailed implementations were not sampled; those are represented at the shared handler boundary.
Main entry points: handlers.rs HTTP handlers · proxy/mod.rs Backend proxy · admin/mod.rs Admin API and portal · config/mod.rs Config loader
Components 16
Request traffic
- HTTP handlers
src/handlers.rs - Backend proxy
src/proxy/mod.rs - Router process
src/main.rs
Routing and protocols
- Route selection
src/route/mod.rs - Anthropic bridge
src/bridge/mod.rs - DeepSeek compatibility
src/compat/mod.rs - API endpoint families
src/contract.rs
Access and operations
- Key authentication
src/auth.rs - Budgets and limits
src/budget/mod.rs - Admin API and portal
src/admin/mod.rs
Configuration and records
- Config loader
src/config/mod.rs - PostgreSQL
- Usage ledger
src/ledger/mod.rs - Metrics
src/metrics.rs
Other components
- API client
- Model providers
Connections 16
- API client → HTTP handlers: sends requests
README.md - HTTP handlers → Key authentication: authenticates with
src/handlers.rs - HTTP handlers → Budgets and limits: checks limits
src/handlers.rs - HTTP handlers → Route selection: selects route
src/handlers.rs - HTTP handlers → Backend proxy: forwards through
src/handlers.rs - Backend proxy → Model providers: proxies requests
src/proxy/mod.rs - HTTP handlers → Anthropic bridge: translates opted-in traffic
src/handlers.rs - Backend proxy → DeepSeek compatibility: applies compatibility shim
src/proxy/mod.rs - API client → API endpoint families: uses supported APIs
README.md - Admin API and portal → Config loader: manages configuration
src/admin/mod.rs - Admin API and portal → PostgreSQL: reads and writes admin data
- Config loader → PostgreSQL: loads configuration
src/config/mod.rs - Backend proxy → Usage ledger: reports usage
src/proxy/mod.rs - Usage ledger → PostgreSQL: writes usage records
src/ledger/mod.rs - Backend proxy → Metrics: updates metrics
src/proxy/mod.rs - Router process → HTTP handlers: serves API