# 065039/nexa_core_rag architecture

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

- Interactive diagram: https://gitdiagram.com/065039/nexa_core_rag
- Repository: https://github.com/065039/nexa_core_rag

## Overview

NexaCore AI is an enterprise policy and compliance Q&A platform. Departmental source files are converted and indexed, then employees ask questions through the web interface with role and department filters; the RAG engine retrieves permitted evidence, generates a grounded response, and presents citations or a not-found/restricted result. The graph preserves documented version-aware and cross-department retrieval, table-row indexing, and model caching. Some implementation details are unsampled, so uncertain internal call links are omitted.

Main entry points: [`src/rag.py`](https://github.com/065039/nexa_core_rag/blob/main/src/rag.py) (RAG engine), [`src/parser.py`](https://github.com/065039/nexa_core_rag/blob/main/src/parser.py) (Docling conversion), [`src/indexing.py`](https://github.com/065039/nexa_core_rag/blob/main/src/indexing.py) (Chunk and index), [`app/streamlit_app.py`](https://github.com/065039/nexa_core_rag/blob/main/app/streamlit_app.py) (Streamlit Q&A)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Document ingestion"]
  node_raw["Department documents"]
  node_registry["Document registry"]
  node_parser["Docling conversion<br/>[parser.py]"]
  node_converted["Converted corpus"]
  node_indexer["Chunk and index<br/>[indexing.py]"]
end

subgraph group_query["Question answering"]
  node_web["Streamlit Q&amp;A<br/>[streamlit_app.py]"]
  node_engine["RAG engine<br/>[rag.py]"]
  node_sources["Cited response<br/>[models.py]"]
end

subgraph group_policy["Access and configuration"]
  node_roles["Role policy<br/>[roles.yaml]"]
  node_access["Access rules<br/>[access.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_integrations["Storage and models"]
  node_qdrant[("Qdrant vectors<br/>[docker-compose.yml]")]
  node_embedding["Embedding model<br/>[models.py]"]
end

node_employee(("Employee"))
node_ollama{{"Ollama Cloud"}}
node_docling{{"Docling parser"}}

node_employee -->|"asks question"| node_web
node_web -->|"submits query"| node_engine
node_engine -->|"returns response"| node_web
node_web -->|"renders citations"| node_sources
node_raw -->|"supplies files"| node_parser
node_registry -->|"provides metadata"| node_parser
node_parser -->|"converts documents"| node_docling
node_parser -->|"writes Markdown and JSON"| node_converted
node_converted -->|"supplies Markdown"| node_indexer
node_indexer -->|"creates vectors"| node_embedding
node_indexer -->|"writes indexed chunks"| node_qdrant
node_engine -->|"retrieves filtered chunks"| node_qdrant
node_engine -->|"checks role access"| node_access
node_access -->|"loads role rules"| node_roles
node_engine -->|"generates grounded answer"| node_ollama
node_engine -->|"embeds query"| node_embedding
node_config -->|"configures runtime"| node_engine
node_config -->|"configures conversion"| node_parser
node_config -->|"configures indexing"| node_indexer

click node_web "https://github.com/065039/nexa_core_rag/blob/main/app/streamlit_app.py"
click node_engine "https://github.com/065039/nexa_core_rag/blob/main/src/rag.py"
click node_sources "https://github.com/065039/nexa_core_rag/blob/main/src/models.py"
click node_raw "https://github.com/065039/nexa_core_rag/tree/main/data/raw"
click node_registry "https://github.com/065039/nexa_core_rag/blob/main/data/document_registry.csv"
click node_parser "https://github.com/065039/nexa_core_rag/blob/main/src/parser.py"
click node_converted "https://github.com/065039/nexa_core_rag/tree/main/data/converted"
click node_indexer "https://github.com/065039/nexa_core_rag/blob/main/src/indexing.py"
click node_roles "https://github.com/065039/nexa_core_rag/blob/main/config/roles.yaml"
click node_access "https://github.com/065039/nexa_core_rag/blob/main/src/access.py"
click node_config "https://github.com/065039/nexa_core_rag/blob/main/src/config.py"
click node_qdrant "https://github.com/065039/nexa_core_rag/blob/main/docker-compose.yml"
click node_embedding "https://github.com/065039/nexa_core_rag/blob/main/src/models.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_raw,node_registry,node_parser,node_converted,node_indexer toneBlue
class node_web,node_engine,node_sources toneAmber
class node_roles,node_access,node_config toneMint
class node_qdrant,node_embedding toneRose
class node_employee,node_ollama,node_docling toneIndigo
```

## Components

### Document ingestion

- [Department documents](https://github.com/065039/nexa_core_rag/tree/main/data/raw): `data/raw`
- [Document registry](https://github.com/065039/nexa_core_rag/blob/main/data/document_registry.csv): `data/document_registry.csv`
- [Docling conversion](https://github.com/065039/nexa_core_rag/blob/main/src/parser.py): `src/parser.py`
- [Converted corpus](https://github.com/065039/nexa_core_rag/tree/main/data/converted): `data/converted`
- [Chunk and index](https://github.com/065039/nexa_core_rag/blob/main/src/indexing.py): `src/indexing.py`

### Question answering

- [Streamlit Q&A](https://github.com/065039/nexa_core_rag/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [RAG engine](https://github.com/065039/nexa_core_rag/blob/main/src/rag.py): `src/rag.py`
- [Cited response](https://github.com/065039/nexa_core_rag/blob/main/src/models.py): `src/models.py`

### Access and configuration

- [Role policy](https://github.com/065039/nexa_core_rag/blob/main/config/roles.yaml): `config/roles.yaml`
- [Access rules](https://github.com/065039/nexa_core_rag/blob/main/src/access.py): `src/access.py`
- [Runtime settings](https://github.com/065039/nexa_core_rag/blob/main/src/config.py): `src/config.py`

### Storage and models

- [Qdrant vectors](https://github.com/065039/nexa_core_rag/blob/main/docker-compose.yml): `docker-compose.yml`
- [Embedding model](https://github.com/065039/nexa_core_rag/blob/main/src/models.py): `src/models.py`

### Other components

- **Employee**
- **Ollama Cloud**
- **Docling parser**

## Connections

- Employee → Streamlit Q&A: asks question
- Streamlit Q&A → RAG engine: submits query
- RAG engine → Streamlit Q&A: returns response
- Streamlit Q&A → Cited response: renders citations
- Department documents → Docling conversion: supplies files
- Document registry → Docling conversion: provides metadata
- Docling conversion → Docling parser: converts documents
- Docling conversion → Converted corpus: writes Markdown and JSON
- Converted corpus → Chunk and index: supplies Markdown
- Chunk and index → Embedding model: creates vectors
- Chunk and index → Qdrant vectors: writes indexed chunks
- RAG engine → Qdrant vectors: retrieves filtered chunks
- RAG engine → Access rules: checks role access
- Access rules → Role policy: loads role rules
- RAG engine → Ollama Cloud: generates grounded answer
- RAG engine → Embedding model: embeds query
- Runtime settings → RAG engine: configures runtime
- Runtime settings → Docling conversion: configures conversion
- Runtime settings → Chunk and index: configures indexing
