# atandritc/clearance architecture

> Architecture diagram of the GitHub repository atandritc/clearance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atandritc/clearance
- Repository: https://github.com/atandritc/clearance

## Overview

Clearance is a permission-aware company knowledge assistant. Employees sign in or use demo identities, ask a question, and receive an answer grounded in authorized document passages and permitted HR/IT tool results; unsupported answers abstain. A separate indexing workflow parses versioned Markdown, chunks and embeds it, and stores metadata and searchable vectors. The graph also preserves admin grant controls and evaluation as documented product capabilities. Runtime relationships follow the excerpts and README; some indexing and integration links are documented rather than verified in sampled implementation.

Main entry points: [`src/clearance/retrieval/search.py`](https://github.com/atandritc/clearance/blob/main/src/clearance/retrieval/search.py) (Authorized search), [`src/clearance/main.py`](https://github.com/atandritc/clearance/blob/main/src/clearance/main.py) (FastAPI), [`src/clearance/assistant/graph.py`](https://github.com/atandritc/clearance/blob/main/src/clearance/assistant/graph.py) (Assistant graph), [`scripts/index_knowledge_base.py`](https://github.com/atandritc/clearance/blob/main/scripts/index_knowledge_base.py) (Index builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["Web app<br/>[App.jsx]"]
end

subgraph group_identity["Identity and access"]
  node_api["FastAPI<br/>[main.py]"]
  node_auth["Auth and users<br/>[auth.py]"]
  node_access["Access grants<br/>[grants.py]"]
  node_postgres[("PostgreSQL")]
  node_models["Domain records<br/>[models.py]"]
end

subgraph group_knowledge["Knowledge indexing"]
  node_markdown["Markdown parser<br/>[markdown.py]"]
  node_chunking["Chunking<br/>[chunking.py]"]
  node_indexing["Index builder"]
  node_metadata_import["Metadata import"]
  node_embeddings["Embeddings<br/>[embeddings.py]"]
  node_qdrant[("Qdrant")]
end

subgraph group_answering["Retrieval and answers"]
  node_search["Authorized search<br/>[search.py]"]
  node_filters["Access filters<br/>[filters.py]"]
  node_assistant["Assistant graph<br/>[graph.py]"]
  node_answer["Answer validation<br/>[answer.py]"]
  node_llm["Groq client<br/>[client.py]"]
end

subgraph group_operations["Employee tools and evaluation"]
  node_mcp["HR and IT tools<br/>[mcp_server.py]"]
  node_evaluation["Evaluation runner<br/>[runner.py]"]
end

node_employee(("Employee"))
node_groq["Groq"]

node_employee -->|"asks"| node_web
node_web -->|"requests"| node_api
node_api -->|"authenticates"| node_auth
node_api -->|"searches"| node_search
node_api -->|"answers via"| node_assistant
node_api -->|"manages grants"| node_access
node_auth -->|"reads users"| node_postgres
node_access -->|"reads grants"| node_postgres
node_api -->|"uses session"| node_postgres
node_metadata_import -->|"parses documents"| node_markdown
node_metadata_import -->|"stores metadata"| node_postgres
node_indexing -->|"parses corpus"| node_markdown
node_indexing -->|"creates chunks"| node_chunking
node_indexing -->|"embeds chunks"| node_embeddings
node_indexing -->|"stores vectors"| node_qdrant
node_search -->|"embeds query"| node_embeddings
node_search -->|"loads grants"| node_access
node_search -->|"builds filter"| node_filters
node_search -->|"queries"| node_qdrant
node_assistant -->|"retrieves evidence"| node_search
node_assistant -->|"calls tools"| node_mcp
node_assistant -->|"generates response"| node_llm
node_assistant -->|"validates result"| node_answer
node_llm -->|"requests completion"| node_groq
node_mcp -->|"reads and writes"| node_postgres
node_evaluation -->|"evaluates retrieval"| node_search
node_evaluation -->|"evaluates answers"| node_answer

click node_web "https://github.com/atandritc/clearance/blob/main/frontend/src/App.jsx"
click node_api "https://github.com/atandritc/clearance/blob/main/src/clearance/main.py"
click node_auth "https://github.com/atandritc/clearance/blob/main/src/clearance/auth.py"
click node_access "https://github.com/atandritc/clearance/blob/main/src/clearance/retrieval/grants.py"
click node_models "https://github.com/atandritc/clearance/blob/main/src/clearance/models.py"
click node_markdown "https://github.com/atandritc/clearance/blob/main/src/clearance/ingestion/markdown.py"
click node_chunking "https://github.com/atandritc/clearance/blob/main/src/clearance/ingestion/chunking.py"
click node_indexing "https://github.com/atandritc/clearance/blob/main/scripts/index_knowledge_base.py"
click node_metadata_import "https://github.com/atandritc/clearance/blob/main/scripts/import_knowledge_metadata.py"
click node_embeddings "https://github.com/atandritc/clearance/blob/main/src/clearance/embeddings.py"
click node_search "https://github.com/atandritc/clearance/blob/main/src/clearance/retrieval/search.py"
click node_filters "https://github.com/atandritc/clearance/blob/main/src/clearance/retrieval/filters.py"
click node_assistant "https://github.com/atandritc/clearance/blob/main/src/clearance/assistant/graph.py"
click node_answer "https://github.com/atandritc/clearance/blob/main/src/clearance/assistant/answer.py"
click node_llm "https://github.com/atandritc/clearance/blob/main/src/clearance/llm/client.py"
click node_mcp "https://github.com/atandritc/clearance/blob/main/src/clearance/tools/mcp_server.py"
click node_evaluation "https://github.com/atandritc/clearance/blob/main/src/clearance/evaluation/runner.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web toneBlue
class node_api,node_auth,node_access,node_postgres,node_models toneAmber
class node_markdown,node_chunking,node_indexing,node_metadata_import,node_embeddings,node_qdrant toneMint
class node_search,node_filters,node_assistant,node_answer,node_llm toneRose
class node_mcp,node_evaluation,node_employee,node_groq toneIndigo
```

## Components

### Web client

- [Web app](https://github.com/atandritc/clearance/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### Identity and access

- [FastAPI](https://github.com/atandritc/clearance/blob/main/src/clearance/main.py): `src/clearance/main.py`
- [Auth and users](https://github.com/atandritc/clearance/blob/main/src/clearance/auth.py): `src/clearance/auth.py`
- [Access grants](https://github.com/atandritc/clearance/blob/main/src/clearance/retrieval/grants.py): `src/clearance/retrieval/grants.py`
- **PostgreSQL**
- [Domain records](https://github.com/atandritc/clearance/blob/main/src/clearance/models.py): `src/clearance/models.py`

### Knowledge indexing

- [Markdown parser](https://github.com/atandritc/clearance/blob/main/src/clearance/ingestion/markdown.py): `src/clearance/ingestion/markdown.py`
- [Chunking](https://github.com/atandritc/clearance/blob/main/src/clearance/ingestion/chunking.py): `src/clearance/ingestion/chunking.py`
- [Index builder](https://github.com/atandritc/clearance/blob/main/scripts/index_knowledge_base.py): `scripts/index_knowledge_base.py`
- [Metadata import](https://github.com/atandritc/clearance/blob/main/scripts/import_knowledge_metadata.py): `scripts/import_knowledge_metadata.py`
- [Embeddings](https://github.com/atandritc/clearance/blob/main/src/clearance/embeddings.py): `src/clearance/embeddings.py`
- **Qdrant**

### Retrieval and answers

- [Authorized search](https://github.com/atandritc/clearance/blob/main/src/clearance/retrieval/search.py): `src/clearance/retrieval/search.py`
- [Access filters](https://github.com/atandritc/clearance/blob/main/src/clearance/retrieval/filters.py): `src/clearance/retrieval/filters.py`
- [Assistant graph](https://github.com/atandritc/clearance/blob/main/src/clearance/assistant/graph.py): `src/clearance/assistant/graph.py`
- [Answer validation](https://github.com/atandritc/clearance/blob/main/src/clearance/assistant/answer.py): `src/clearance/assistant/answer.py`
- [Groq client](https://github.com/atandritc/clearance/blob/main/src/clearance/llm/client.py): `src/clearance/llm/client.py`

### Employee tools and evaluation

- [HR and IT tools](https://github.com/atandritc/clearance/blob/main/src/clearance/tools/mcp_server.py): `src/clearance/tools/mcp_server.py`
- [Evaluation runner](https://github.com/atandritc/clearance/blob/main/src/clearance/evaluation/runner.py): `src/clearance/evaluation/runner.py`

### Other components

- **Employee**
- **Groq**

## Connections

- Employee → Web app: asks
- Web app → FastAPI: requests
- FastAPI → Auth and users: authenticates (evidence: `src/clearance/main.py`)
- FastAPI → Authorized search: searches (evidence: `src/clearance/main.py`)
- FastAPI → Assistant graph: answers via
- FastAPI → Access grants: manages grants (evidence: `src/clearance/main.py`)
- Auth and users → PostgreSQL: reads users
- Access grants → PostgreSQL: reads grants
- FastAPI → PostgreSQL: uses session (evidence: `src/clearance/main.py`)
- Metadata import → Markdown parser: parses documents (evidence: `scripts/import_knowledge_metadata.py`)
- Metadata import → PostgreSQL: stores metadata
- Index builder → Markdown parser: parses corpus (evidence: `scripts/index_knowledge_base.py`)
- Index builder → Chunking: creates chunks (evidence: `scripts/index_knowledge_base.py`)
- Index builder → Embeddings: embeds chunks (evidence: `scripts/index_knowledge_base.py`)
- Index builder → Qdrant: stores vectors
- Authorized search → Embeddings: embeds query (evidence: `src/clearance/retrieval/search.py`)
- Authorized search → Access grants: loads grants (evidence: `src/clearance/retrieval/search.py`)
- Authorized search → Access filters: builds filter (evidence: `src/clearance/retrieval/search.py`)
- Authorized search → Qdrant: queries (evidence: `src/clearance/retrieval/search.py`)
- Assistant graph → Authorized search: retrieves evidence (evidence: `src/clearance/assistant/graph.py`)
- Assistant graph → HR and IT tools: calls tools (evidence: `src/clearance/assistant/graph.py`)
- Assistant graph → Groq client: generates response (evidence: `src/clearance/assistant/graph.py`)
- Assistant graph → Answer validation: validates result (evidence: `src/clearance/assistant/graph.py`)
- Groq client → Groq: requests completion (evidence: `src/clearance/llm/client.py`)
- HR and IT tools → PostgreSQL: reads and writes
- Evaluation runner → Authorized search: evaluates retrieval (evidence: `scripts/run_evaluation.py`)
- Evaluation runner → Answer validation: evaluates answers (evidence: `scripts/run_evaluation.py`)
