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

# System Architecture & ADRs

> Six-layer unidirectional dependency architecture and Architectural Decision Records governing safety and multitenancy.

The MithunAI platform is partitioned into six decoupled layers where every layer depends strictly on the layers beneath it and tenant boundaries fail closed at compile time.

Upper layers orchestrate user-facing applications, whereas lower layers enforce foundational storage, identity, and cryptographic isolation.

```
┌────────────────────────────────────────────────────────┐
│  Layer 6: Experience (React SPAs, Embeddable Widgets) │
└───────────────────────────┬────────────────────────────┘
                            ▼
┌────────────────────────────────────────────────────────┐
│  Layer 5: Workflow (Inference Gateway, Orchestration)  │
└───────────────────────────┬────────────────────────────┘
                            ▼
┌────────────────────────────────────────────────────────┐
│  Layer 4: Agents (State Graphs, Tool Calling, Loops)   │
└───────────────────────────┬────────────────────────────┘
                            ▼
┌────────────────────────────────────────────────────────┐
│  Layer 3: Knowledge (AST Chunking, Connectors, Index)  │
└───────────────────────────┬────────────────────────────┘
                            ▼
┌────────────────────────────────────────────────────────┐
│  Layer 2: AI (Model Adapters, Embeddings, Evaluation)  │
└───────────────────────────┬────────────────────────────┘
                            ▼
┌────────────────────────────────────────────────────────┐
│  Layer 1: Platform (Multi-Tenant DB, Auth, Auditing)   │
└────────────────────────────────────────────────────────┘
```

## Architectural Decision Records (ADRs)

Key architectural decisions are preserved in immutable records governing system behavior:

* **ADR 0010 (Zero-Hallucination Safe Default)**: When retrieval relevance falls below confidence thresholds, the engine abstains explicitly (`ERR_GROUNDING_THRESHOLD_UNMET`) instead of guessing.
* **ADR 0018 (Read-Only MCP Server)**: Model Context Protocol servers exposed to developer IDEs are strictly read-only, preventing external modification of indexed repositories.
* **ADR 0020 (Widget Visitor Isolation)**: Embeddable web widgets execute as unprivileged visitor sessions constrained by domain origin allowlists.
* **ADR 0022 (Query-Time OrganizationScope Boundary)**: Tenant isolation is an immutable SQL AST predicate compiled into every database lookup.
* **ADR 0025 (Consented Support Access)**: MithunAI staff can access customer sessions only with explicit, time-bounded customer opt-in consent.
