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. Every other crate depends on this.
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-tokenizerGenerates semantic tokens ({{type:id}}) 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 blob), memory, Redis.

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 token format and repair profiles.
guardai-document-ingestDocument ingestion pipeline for RAG workflows.
guardai-ocrOCR text extraction with entity detection.

Infrastructure

CratePurpose
guardai-authAuthentication middleware (API key, JWT).

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.