Architecture

Emperatriz is the control plane. Providers are replaceable adapters behind a narrow interface.

01
UI
React dashboard & workspace

Executive / Workspace modes. Holds only non-secret config.

02
App API
Server functions

Validates input, reads secrets server-side, writes audit events.

03
Policy & routing engine
src/lib/routing/engine.ts

Pure, vendor-agnostic. Enforces privacy class, budget and fallback; refuses disconnected providers.

04
Adapters
ProviderAdapter interface

Gateway adapters (OrcaRouter, OpenRouter), local inference adapter (Ollama), direct & custom OpenAI-compatible, mock.

05
Model
Qwen · Claude · GPT · DeepSeek · local

Model identity is independent of the adapter serving it.

Secrets

Credentials live in server-side environment secrets. The UI stores only the variable name. The connection test reads an allow-listed variable on the server and binds known keys to their vendor host.

Durable store Planned

MVP persists demo config in browser storage. Next: PostgreSQL via Lovable Cloud for policies, agents, audit and usage, with row-level access by role.

Telemetry & audit

Every configuration change, simulation and approval decision appends an audit event. Usage records will be written by adapters after real calls.

Adapter contract

interface ProviderAdapter {
  id: string
  testConnection(): Promise<{ ok: boolean; message: string }>
  complete(req: { model; messages; maxTokens? }): Promise<{ text; latencyMs; simulated }>
}