> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qwedai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture diagrams

> Reference diagrams for QWED system topology, request lifecycle, trust boundary, and consensus verification.

Use this page as a reference companion to [Architecture overview](/architecture).

<Tip>
  If you are new to QWED, start with the high-level architecture page first.\
  This page is optimized for implementation and operations teams.
</Tip>

## 1) System topology

**Use this when:** you need a full map of components and external dependencies.

```mermaid theme={null}
graph TB
    subgraph "Client Layer"
        SDK[SDKs: Python, TS, Go, Rust]
        APIClient[REST and middleware clients]
    end

    subgraph "Control Plane"
        Gateway[API Gateway]
        Auth[Auth and tenancy]
        Limits[Rate limiter]
        Router[Domain router]
    end

    subgraph "Verification Plane"
        Math[Math Engine]
        Logic[Logic Engine]
        Code[Code Engine]
        SQL[SQL Engine]
        Others[Other deterministic engines]
    end

    subgraph "Guard Plane"
        RAG[RAGGuard]
        Exfil[ExfiltrationGuard]
        MCP[MCPPoisonGuard]
        Policy[Sovereignty and policy guards]
    end

    subgraph "Evidence Plane"
        Attest[Attestation signer]
        Audit[Immutable audit log]
    end

    SDK --> APIClient
    APIClient --> Gateway
    Gateway --> Auth
    Gateway --> Limits
    Gateway --> Router
    Router --> Math
    Router --> Logic
    Router --> Code
    Router --> SQL
    Router --> Others
    Router --> RAG
    Router --> Exfil
    Router --> MCP
    Router --> Policy
    Math --> Attest
    Logic --> Attest
    Code --> Attest
    SQL --> Attest
    Others --> Attest
    Attest --> Audit
```

## 2) Request lifecycle

**Use this when:** you want to understand where decisions happen in the request path.

```mermaid theme={null}
sequenceDiagram
    participant User
    participant API as Gateway
    participant Detect as Domain Detector
    participant LLM as Translator
    participant Engine as Deterministic Engine
    participant Guard as Security Guards
    participant Attest as Attestation

    User->>API: Submit query or action
    API->>Detect: Infer domain and route
    Detect-->>API: Selected verification path
    API->>LLM: Optional translation request
    LLM-->>API: Untrusted structured claim
    API->>Engine: Deterministic verification
    Engine-->>API: VERIFIED / FAILED / BLOCKED
    API->>Guard: Tool/policy checks (if needed)
    Guard-->>API: Allow or deny execution
    API->>Attest: Optional signed evidence
    API-->>User: Result + proof metadata
```

## 3) Trust boundary

**Use this when:** you need to explain security posture to reviewers or compliance teams.

```mermaid theme={null}
flowchart LR
    subgraph Untrusted["Untrusted Zone"]
        NL[Natural language query]
        TR[LLM translation output]
    end

    subgraph Trusted["Trusted Zone"]
        PARSE[Parser and schema checks]
        VERIFY[Deterministic engines]
        GUARD[Security guard decisions]
        SIGN[Attestation signing]
    end

    NL --> TR
    TR --> PARSE
    PARSE --> VERIFY
    VERIFY --> GUARD
    GUARD --> SIGN
```

## 4) Consensus verification path

**Use this when:** you want resilience through multi-engine cross-checking.

```mermaid theme={null}
flowchart TD
    In[Verification request] --> P1[Engine A]
    In --> P2[Engine B]
    In --> P3[Engine C]

    P1 --> H{Health threshold met?}
    P2 --> H
    P3 --> H

    H -->|Yes| Vote[Weighted consensus]
    H -->|No| Degraded[Degraded mode policy]
    Degraded --> Vote
    Vote --> Out[Final deterministic verdict]
```

## Diagram usage guide

| Need                              | Diagram                     |
| --------------------------------- | --------------------------- |
| Component map and ownership       | System topology             |
| Per-request execution flow        | Request lifecycle           |
| Security/compliance explanation   | Trust boundary              |
| Reliability and fallback behavior | Consensus verification path |

## Related pages

1. [Architecture overview](/architecture)
2. [Determinism guarantee](/advanced/determinism-guarantee)
3. [Agent verification](/advanced/agent-verification)
4. [SDK guards](/sdks/guards)
