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

# How Enfors works

> The architecture behind Enfors — from a model call to an auditable decision.

Enfors captures activity two ways — a local **watcher** for coding assistants and the
**gateway** for agent SDKs — and a fat backend does all the intelligence. Your agents never
wait on Enfors.

## The pipeline

```mermaid theme={null}
flowchart TD
  CLI[Claude Code CLI] --> T[(local transcript)]
  CD[Claude Desktop] --> T
  WA[Enfors watcher] -->|reads transcript| T
  WA -->|POST| DATA[data.enfors.ai · transcript ingest]
  SDK[Agent SDKs · e.g. OpenAI SDK] -->|direct calls| GW[llm.enfors.ai · gateway]
  DATA --> Q[(Ingest queue)]
  GW -->|callback| Q
  Q --> W[Worker]
  W --> R[Reconstruct decision + PII scrub]
  W --> G[(Graph)]
  W --> I[Insight engine]
  W --> F[Features / Epics / Pulse]
  R --> DB[(Decision ledger)]
  DB --> API[enfors-api: UI, MCP, Data API]
  G --> API
  API --> UI[Enfors UI + external AI clients]
```

### 1. Capture — two paths

Both paths land on the same ingest queue; the difference is only how activity gets there.

**Transcript watcher (coding assistants).** Claude Code (CLI) and Claude Desktop write a
transcript of every session to disk. The Enfors **watcher** — a single dependency-free Python
process, installed to run at login on macOS (LaunchAgent `ai.enfors.watcher`) or Windows
(Scheduled Task `EnforsWatcher`) — tails those files and, when a turn completes, uploads it
to `data.enfors.ai/api/ledger/transcript`. It **reads files only**: no proxy, no TLS
interception, no certificate, and it is not in your network path.

**Gateway (agent SDKs).** Agent SDKs (e.g. the OpenAI SDK) and other tools call the Enfors
**gateway** (`llm.enfors.ai`, built on [LiteLLM](https://litellm.ai)) **directly**. The
gateway is **model-agnostic** (Anthropic, OpenAI, Gemini, Bedrock, Azure…), tags each request
with identity headers (`x-enfors-agent-id`, `x-enfors-agent-name`, `x-enfors-execution-id`),
and does **nothing but transport** — it captures the call and enqueues it via its own callback
(`/api/ledger/intake`) while the client waits only on the model.

<Note>
  The watcher **replaces the earlier mitmproxy approach** for the coding assistants — no local
  proxy, no TLS interception, and no certificate to trust. See
  [Deployment & Security](/security/overview) for the full IT/CISO detail.
</Note>

### 2. Reconstruct (the backend)

A FIFO queue feeds a worker that:

* Reconstructs each captured turn into a **decision** with reasoning steps, findings,
  evidence, and artifacts.
* Classifies the **outcome** and **work type**, and computes quality metrics.
* **Scrubs PII** from stored records, offloading large payloads to object storage.
* Writes the relationship **graph** (best-effort, retried).
* Runs the **insight engine** and updates **Features, Epics, and Pulse reports**.

Using a queue eliminates the race conditions, duplication, and truncation that plague
inline processing.

### 3. Serve (read surfaces)

Everything you see is served by `enfors-api`:

* The **Enfors UI** (authenticated SPA).
* The **MCP server** — an OAuth-secured endpoint that lets external AI clients query
  Enfors and render branded views. See [MCP Server](/mcp/overview).
* The **Data API** — audit and analyse endpoints. See [API Reference](/api-reference/authentication).

## Where data lives

<CardGroup cols={2}>
  <Card title="Decision ledger" icon="database">
    The canonical record of every decision, with extracted columns for fast filtering and
    structured blobs for the full audit trail.
    See [The Decision Ledger](/concepts/decision-ledger).
  </Card>

  <Card title="Relationship graph" icon="circle-nodes">
    Agents, decisions, subjects, evidence, steps, findings, and artifacts, for traversal and
    the Explore canvas.
    See [Evidence & the Logic Trace](/concepts/evidence-and-logic-trace).
  </Card>
</CardGroup>

## The components

| Component        | Role                                                                                               |
| ---------------- | -------------------------------------------------------------------------------------------------- |
| `enfors gateway` | LiteLLM gateway (`llm.enfors.ai`) — captures agent-SDK calls (e.g. OpenAI SDK)                     |
| `enfors watcher` | Local macOS/Windows agent — captures Claude Code CLI + Claude Desktop by reading their transcripts |
| `enfors server`  | Processing engine — intake, worker, insight engine, graph ingest, schema owner                     |
| `enfors api`     | Read surfaces — UI routes, MCP server, public Data API                                             |
| `enfors app`     | Explore, dashboards, Pulse, insights                                                               |

<Note>
  Everything is scoped to **tenant, workspace, and user**, enforced at the database with
  Row-Level Security. See [Tenancy, Privacy & PII](/concepts/tenancy-privacy-pii).
</Note>
