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

# Architecture

# Find My Data — actual-code architecture

This diagram reflects the code as built (not aspiration). One deployable server
process hosts the API and an embedded durable worker; the worker can also run as a
separate process against the same queue (`bun run worker`). All stores are SQLite
tables behind role interfaces (ADR-0003); projections are rebuildable.

```mermaid theme={null}
flowchart TB
    subgraph WEB["packages/web — React UI"]
        UI[Home · Review · Landscape · Asset+Connections · Findings · Analyst · Actions · Governance · Operations · Audit]
    end

    subgraph SERVER["packages/server — modular monolith (Bun + Hono)"]
        subgraph KERNEL["kernel/"]
            CFG[config.ts<br/>production lockout]
            HTTP[http.ts<br/>sessions · CSRF · errors]
            AUTHZ[authz.ts<br/>capability + domain scope]
            AUD[audit.ts<br/>hash-chained trail]
            LOG[log.ts<br/>allowlist redaction]
            OBJ[objectstore.ts<br/>purpose-flagged artifacts]
        end
        subgraph MODULES["domain modules"]
            IDN[identity/<br/>dev auth · Entra seam]
            GOV[governance/<br/>onboarding · taxonomy · owners]
            AIGW[aigateway/<br/>mock · Azure OpenAI · Anthropic]
            CONN[connectors/<br/>contract · mock M365 · registry]
            SCAN[scan/<br/>queue · campaigns · pipeline · worker]
            INTEL[intelligence/<br/>detectors · similarity · ensemble<br/>risk · findings · projections · rescore]
            REV[review/<br/>queue · decisions · propagation]
            ANA[analyst/<br/>schema · planner · executor]
            ACT[actions/<br/>state machine · approvals · verify]
            READ[routes/read-models.ts<br/>home · landscape · assets · connections]
        end
    end

    subgraph STORE["SQLite (WAL) behind role interfaces"]
        REL[(system of record<br/>82 tables)]
        FTS[(search_fts + facets)]
        GRAPH[(graph_nodes/edges<br/>typed + reasons)]
        Q[(work_units + leases<br/>+ dead_letters)]
        ART[(artifacts on disk<br/>use-flag enforced)]
    end

    MOCK[Mock M365 tenant<br/>3 scopes · 15 fixture files<br/>scripted deltas + resync]
    GRAPHAPI[Microsoft Graph<br/>contract present · config-gated<br/>BLOCKED until credentials]

    UI -->|/api + CSRF| HTTP
    HTTP --> AUTHZ --> MODULES
    SCAN --> Q
    SCAN --> CONN
    CONN --> MOCK
    CONN -.blocked.-> GRAPHAPI
    SCAN --> INTEL
    INTEL --> REL & FTS & GRAPH
    INTEL --> OBJ --> ART
    REV --> INTEL
    ANA -->|typed plans only| FTS
    ACT --> CONN
    GOV --> AIGW
    MODULES --> AUD --> REL
```

## The staged pipeline (scan/pipeline.ts + intelligence/inference.ts)

```mermaid theme={null}
flowchart LR
    A[inventory_page /<br/>delta_run] --> B[observe<br/>asset·version·location<br/>key: sourceVersion]
    B --> C[permissions<br/>dedup sets<br/>key: sourceVersion]
    C --> D[labels<br/>GUID + state<br/>key: sourceVersion]
    D --> E[content<br/>fetch·hash·extract<br/>key: contentVersion]
    E --> F[features<br/>keyphrases·excerpts<br/>key: contentVersion]
    F --> G[inference<br/>ensemble·clusters<br/>key: contentVersion+context+release]
    G --> H[risk → findings →<br/>review candidates →<br/>graph/search projections]
```

Stage-cache keys encode the invalidation matrix: an eTag-only change (rename,
permission, label) reuses content/features as cache hits with **zero content
fetches** (tested); a cTag change re-fetches; an ensemble release re-scores from
retained features with **no connector dependency at all** (tested).

## What is real vs. gated here

| Capability                                                             | State                                                                                                                 |
| ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| Fixture connector, pipeline, ensemble, review, analyst, actions, audit | **Implemented + tested (86 tests)**                                                                                   |
| Azure OpenAI / Anthropic providers                                     | Adapters implemented, config-gated, not exercised by tests                                                            |
| Microsoft Graph live connector (read)                                  | **Implemented + validated read-only against the live Contoso CDX tenant** (ADR-0013). Mock stays the default/CI path. |
| Microsoft Graph live connector (write / label actions)                 | Not implemented — read-only app; write remains a separate protected path                                              |
| Entra ID sign-in                                                       | Seam + production lockout; OIDC flow not active in this build                                                         |
| Purview label write (live)                                             | Blocked on protected/metered API enablement                                                                           |
| Teams / Exchange connectors                                            | Not built — contracts and backlog only (see STATUS.md)                                                                |

```
```
