Architecture & Core Concepts
Eluvix is architected as a modular, local-first monorepo that separates routing logic, proxy adapters, storage, and visual presentation into cleanly decoupled packages.
Monorepo Layout
The repository is managed using pnpm workspaces:
eluvix/
āāā packages/
ā āāā router-core/ # Core Switchyard engine, Privacy/Semantic guards, caching, and SQLite
āāā apps/
ā āāā nextjs/ # Visual flow editor, live playground, activity monitor, and API server
ā āāā desktop/ # Cross-platform Electron desktop client
ā āāā githubio/ # Documentation static site deployed via GitHub Pages
āāā docker/ # Dockerfiles and production container service definitions
āāā scripts/ # GPU hardware auto-detection and setup utilities
The Switchyard Routing Engine (@eluvix/router-core)
The core routing engine is completely decoupled from UI code, allowing it to run embedded in Node.js services, edge functions, or daemon processes.
Request Lifecycle (routeChatCompletion)
When an incoming ChatRequest enters Eluvix:
Client Request (POST /api/v1/chat/completions)
ā
ā¼
1. Budget & Rate Limiting Check āāāāŗ Sliding-window RPM & maxCostPerRequest
ā
ā¼
2. Semantic Response Caching āāāāāāāŗ In-memory TTL Cache (0ms HIT)
ā
ā¼
3. Privacy Guard Redaction āāāāāāāāāŗ PII Masking (token / asterisk / hash)
ā
ā¼
4. Semantic Guard Inspection āāāāāāāŗ Prompt Injection & Jailbreak Classifier
ā
ā¼
5. Complexity & Token Assessment āāāŗ Middle-Truncation (Anti-OOM)
ā
ā¼
6. Upstream Mesh Filtering āāāāāāāāāŗ Filters by capability tags (e.g. vision)
ā
ā¼
7. Latency Spillover Sorting āāāāāāāŗ Evaluates recent SQLite telemetry logs
ā
ā¼
8. Resilient Execution & Fallback āāŗ Tiers: Local -> Spillover -> Cloud Gateway
- Rate Limiting & Budgeting: Sliding-window RPM limits and financial cost caps (
maxCostPerRequest) are checked upfront. - Semantic Caching: Computes query fingerprints to serve recurring requests instantly with
X-Eluvix-Cache: HIT. - Privacy Guard: Intercepts requests to scrub PII (SSNs, API keys, IPs, emails) using named tokens, asterisks, or SHA-256 hashes.
- Semantic Guard: Scans prompt structures for adversarial instruction overrides and jailbreaks, returning early 400s or diverting to sinks.
- Anti-OOM Context Management: Automatically applies middle-truncation when prompt tokens exceed upstream context windows.
- Capability Tag Matching: Filters upstreams to match required capabilities (e.g., multimodal vision when an image payload is detected).
- Latency Spillover: De-prioritizes slow local nodes exceeding latency thresholds (default
3,000ms). - Fault-Tolerant Execution: Automatically retries and falls back across tiers if a node fails or times out.
Multi-Target Compiler (compiler.ts)
Eluvix compiles visual graph topologies into 10 unified configuration artifacts simultaneously:
Visual Canvas State (React Flow)
ā
ā¼
[ compileGraph() ]
ā
āāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāā
ā¼ ā¼ ā¼ ā¼ ā¼
eluvix.json bifrost.yaml agent-router.json semantic-router privacy-guard
ā ā ā ā ā
ā¼ ā¼ ā¼ ā¼ ā¼
agent-gateway observability antigravity.yaml codex.json claudecode.json
Each artifact is specialized for its target runtime while sharing unified policy definitions across security, routing, and credentials.
Storage & Database Layer
Eluvix uses node:sqlite (or better-sqlite3) for zero-overhead, ultra-low latency local persistence without external database servers.
Storage paths adhere to the XDG Base Directory Specification:
- Configuration:
~/.config/eluvix/(auth.json, local TLS certs) - Data & History:
~/.local/share/eluvix/or./data/eluvix.db
Core SQLite Tables
request_logs: Stores timestamps, upstream IDs, models, latency in milliseconds, token throughput, and status codes. Powers live dashboard analytics and dynamic latency spillover calculations.chat_history: Persists conversation sessions from the Trace Playground, enabling inspection, auditing, and one-click JSONL dataset export for model fine-tuning.layouts: Stores user-authored canvas topologies, custom nodes, and example presets.
Architectural Boundaries: L7 Proxy vs Host Runtimes
Eluvix maintains a clean separation between dynamic Layer 7 routing and underlying host infrastructure:
- Configurable at Runtime (Canvas / API):
- Routing strategies, token complexity thresholds, and code escalation.
- Upstream network timeouts and retry counts.
- Semantic response caching TTL and similarity thresholds.
- Rate limits (RPM/TPM) and financial spending caps.
- PII masking styles and prompt injection sensitivity thresholds.
- Bound at Host Boot (Docker / Container / systemd):
- GPU hardware device allocation (
CUDA_VISIBLE_DEVICES). - Container host port bindings (e.g.
0.0.0.0:8080). - Model weights, KV-cache precision (FP16 vs INT4), and memory cgroup ceilings.
- GPU hardware device allocation (