OGuardAI
Architecture

Crate Dependency Graph

Visual dependency graph of all Rust crates in the OGuardAI workspace

The OGuardAI runtime is built from a workspace of focused Rust crates. Each crate has a single responsibility. This page shows how they depend on each other.


Full Dependency Graph


Crate Responsibilities

Foundation

CratePurpose
guardai-coreShared types, error definitions, entity model, runtime kernel. Most crates depend on this; a few self-contained utility crates (auth, large-text, streaming, prompt-security, document-ingest) do not.
guardai-api-typesRequest/response contracts (serde structs) for the HTTP API.

Detection

CratePurpose
guardai-detector-builtinsRust regex-based entity detectors (email, phone, SSN, IBAN, etc.).
guardai-detector-clientHTTP bridge to the Python NER detector service. Falls back to builtins.

Core Pipeline

CratePurpose
guardai-runtimeProtection kernel: composes tokenize, policy, transform, seal, and rehydrate into one transactional flow shared by the server and proxy.
guardai-tokenizerGenerates semantic tokens ({{type:id:cap}}) from detected entities.
guardai-transformerOrchestrates detect + tokenize + policy to produce safe text.
guardai-rehydrateRestores tokens in LLM output using session state and policy.
guardai-policyLoads and evaluates policy YAML (entity rules, output channels, restore modes).
guardai-sessionSession backends: sealed (encrypted client-side blob), memory (in-process), and Redis (encrypted at rest, wired via session.backend=redis for shared cross-replica sessions). Redis also backs the durable revocation and replay stores.

Safety and Robustness

CratePurpose
guardai-token-robustness3-stage token repair (strict, repair, fuzzy) for LLM-mangled tokens.
guardai-output-guardSecond-pass detection on LLM output to catch newly generated PII.
guardai-prompt-securityPrompt injection defense and system preamble generation.

Extensions

CratePurpose
guardai-large-textChunking, batching, and span management for large documents.
guardai-streamingSSE streaming for transform and rehydrate operations.
guardai-provider-strategyPer-LLM-provider context-verbosity profiles (how much entity_context metadata is sent).
guardai-document-ingestDocument ingestion pipeline for RAG workflows.
guardai-ocrOCR text extraction with entity detection.

Infrastructure

CratePurpose
guardai-authAuthentication middleware (API key, static JWT, and OIDC/JWKS).
guardai-observabilityShared PII-safe audit events and Prometheus metrics for the runtime and proxy.

Applications

CratePurpose
oguardai-serverAxum HTTP server. Depends on nearly all crates.
oguardai-cliCLI binary for transform, rehydrate, detect, config, and server management.
oguardai-proxyTransparent API proxy that auto-masks requests to LLM providers.

Dependency Rules

  1. guardai-core depends on nothing internal. It is the foundation.
  2. Pipeline crates depend on core and optionally on each other following the data flow: detect, tokenize, transform, rehydrate.
  3. Application crates (server, cli, proxy) are leaf nodes. They depend on library crates but no library crate depends on them.
  4. No circular dependencies. The graph is a DAG.
  5. New crates must declare their position in this graph before implementation.