# dilolabs/nosia architecture

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

- Interactive diagram: https://gitdiagram.com/dilolabs/nosia
- Repository: https://github.com/dilolabs/nosia

## Overview

Nosia is a self-hosted, multi-tenant RAG and MCP platform. Users add documents, text, Q&A pairs, or websites to build a searchable knowledge base, then chat with models using retrieved context and optional tools; it also exposes an OpenAI-compatible API. The graph preserves source ingestion, chat, MCP, and agent-skill capabilities. Several runtime links are documented in the README rather than shown in sampled implementation, so those are cited as documented relationships; unsampled internals are not asserted.

Main entry points: [`app/jobs/chat_response_job.rb`](https://github.com/dilolabs/nosia/blob/main/app/jobs/chat_response_job.rb) (Chat response job), [`app/models/chat/augmented_prompt.rb`](https://github.com/dilolabs/nosia/blob/main/app/models/chat/augmented_prompt.rb) (Chat and prompt), [`app/models/mcp_server/client.rb`](https://github.com/dilolabs/nosia/blob/main/app/models/mcp_server/client.rb) (MCP connections), [`app/controllers/chats_controller.rb`](https://github.com/dilolabs/nosia/blob/main/app/controllers/chats_controller.rb) (Chat interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_chat_ui["Chat interface"]
  node_messages["Message handling"]
  node_completion_api["Completions API"]
end

subgraph group_knowledge["Knowledge ingestion"]
  node_source_ui["Source management"]
  node_source_types["Source endpoints"]
  node_index_jobs["Indexing jobs"]
  node_source_models["Source models<br/>[document.rb]"]
  node_chunk_search["Chunk search<br/>[searchable.rb]"]
end

subgraph group_ai["AI runtime"]
  node_chat_job["Chat response job"]
  node_chat_models["Chat and prompt"]
end

subgraph group_extensions["Tools and skills"]
  node_mcp_chat["MCP chat integration"]
  node_mcp_servers["MCP connections<br/>[client.rb]"]
  node_skills["Agent skills<br/>[executor.rb]"]
  node_openalex["OpenAlex tools"]
end

subgraph group_persistence["Persistence"]
  node_database[("PostgreSQL and vectors<br/>[schema.rb]")]
end

node_user(("User"))
node_model_service["AI model service"]
node_external_tools["External MCP tools"]

node_user -->|"starts chat"| node_chat_ui
node_user -->|"manages sources"| node_source_ui
node_user -->|"calls API"| node_completion_api
node_chat_ui -->|"routes messages"| node_messages
node_source_ui -->|"routes sources"| node_source_types
node_source_types -.->|"queues indexing"| node_index_jobs
node_index_jobs -.->|"indexes sources"| node_source_models
node_source_models -.->|"stores records"| node_database
node_messages -.->|"starts response"| node_chat_job
node_completion_api -.->|"generates completion"| node_chat_job
node_chat_job -.->|"builds context"| node_chat_models
node_chat_models -->|"retrieves chunks"| node_chunk_search
node_chunk_search -->|"vector search"| node_database
node_chat_job -->|"requests response"| node_model_service
node_chat_models -->|"supports tool context"| node_mcp_chat
node_mcp_chat -.->|"uses MCP"| node_mcp_servers
node_mcp_servers -->|"connects tools"| node_external_tools
node_chat_job -->|"extends chat"| node_skills
node_mcp_servers -.->|"offers tools"| node_openalex

click node_chat_ui "https://github.com/dilolabs/nosia/blob/main/app/controllers/chats_controller.rb"
click node_messages "https://github.com/dilolabs/nosia/blob/main/app/controllers/messages_controller.rb"
click node_completion_api "https://github.com/dilolabs/nosia/blob/main/app/controllers/api/v1/completions_controller.rb"
click node_source_ui "https://github.com/dilolabs/nosia/blob/main/app/controllers/sources_controller.rb"
click node_source_types "https://github.com/dilolabs/nosia/blob/main/app/controllers/sources/documents_controller.rb"
click node_index_jobs "https://github.com/dilolabs/nosia/blob/main/app/jobs/add_document_job.rb"
click node_source_models "https://github.com/dilolabs/nosia/blob/main/app/models/document.rb"
click node_chunk_search "https://github.com/dilolabs/nosia/blob/main/app/models/chunk/searchable.rb"
click node_chat_job "https://github.com/dilolabs/nosia/blob/main/app/jobs/chat_response_job.rb"
click node_chat_models "https://github.com/dilolabs/nosia/blob/main/app/models/chat/augmented_prompt.rb"
click node_mcp_chat "https://github.com/dilolabs/nosia/blob/main/app/models/chat/model_context_protocol.rb"
click node_mcp_servers "https://github.com/dilolabs/nosia/blob/main/app/models/mcp_server/client.rb"
click node_skills "https://github.com/dilolabs/nosia/blob/main/app/models/agent_skill/executor.rb"
click node_openalex "https://github.com/dilolabs/nosia/blob/main/app/models/open_alex_tools/get_author_comprehensive_works_tool.rb"
click node_database "https://github.com/dilolabs/nosia/blob/main/db/schema.rb"

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_chat_ui,node_messages,node_completion_api,node_user toneBlue
class node_source_ui,node_source_types,node_index_jobs,node_source_models,node_chunk_search toneAmber
class node_chat_job,node_chat_models toneMint
class node_mcp_chat,node_mcp_servers,node_skills,node_openalex toneRose
class node_database,node_model_service,node_external_tools toneIndigo
```

## Components

### User interaction

- [Chat interface](https://github.com/dilolabs/nosia/blob/main/app/controllers/chats_controller.rb): `app/controllers/chats_controller.rb`
- [Message handling](https://github.com/dilolabs/nosia/blob/main/app/controllers/messages_controller.rb): `app/controllers/messages_controller.rb`
- [Completions API](https://github.com/dilolabs/nosia/blob/main/app/controllers/api/v1/completions_controller.rb): `app/controllers/api/v1/completions_controller.rb`

### Knowledge ingestion

- [Source management](https://github.com/dilolabs/nosia/blob/main/app/controllers/sources_controller.rb): `app/controllers/sources_controller.rb`
- [Source endpoints](https://github.com/dilolabs/nosia/blob/main/app/controllers/sources/documents_controller.rb): `app/controllers/sources/documents_controller.rb`
- [Indexing jobs](https://github.com/dilolabs/nosia/blob/main/app/jobs/add_document_job.rb): `app/jobs/add_document_job.rb`
- [Source models](https://github.com/dilolabs/nosia/blob/main/app/models/document.rb): `app/models/document.rb`
- [Chunk search](https://github.com/dilolabs/nosia/blob/main/app/models/chunk/searchable.rb): `app/models/chunk/searchable.rb`

### AI runtime

- [Chat response job](https://github.com/dilolabs/nosia/blob/main/app/jobs/chat_response_job.rb): `app/jobs/chat_response_job.rb`
- [Chat and prompt](https://github.com/dilolabs/nosia/blob/main/app/models/chat/augmented_prompt.rb): `app/models/chat/augmented_prompt.rb`

### Tools and skills

- [MCP chat integration](https://github.com/dilolabs/nosia/blob/main/app/models/chat/model_context_protocol.rb): `app/models/chat/model_context_protocol.rb`
- [MCP connections](https://github.com/dilolabs/nosia/blob/main/app/models/mcp_server/client.rb): `app/models/mcp_server/client.rb`
- [Agent skills](https://github.com/dilolabs/nosia/blob/main/app/models/agent_skill/executor.rb): `app/models/agent_skill/executor.rb`
- [OpenAlex tools](https://github.com/dilolabs/nosia/blob/main/app/models/open_alex_tools/get_author_comprehensive_works_tool.rb): `app/models/open_alex_tools/get_author_comprehensive_works_tool.rb`

### Persistence

- [PostgreSQL and vectors](https://github.com/dilolabs/nosia/blob/main/db/schema.rb): `db/schema.rb`

### Other components

- **User**
- **AI model service**
- **External MCP tools**

## Connections

- User → Chat interface: starts chat
- User → Source management: manages sources
- User → Completions API: calls API
- Chat interface → Message handling: routes messages
- Source management → Source endpoints: routes sources
- Source endpoints → Indexing jobs: queues indexing
- Indexing jobs → Source models: indexes sources
- Source models → PostgreSQL and vectors: stores records
- Message handling → Chat response job: starts response
- Completions API → Chat response job: generates completion
- Chat response job → Chat and prompt: builds context
- Chat and prompt → Chunk search: retrieves chunks
- Chunk search → PostgreSQL and vectors: vector search
- Chat response job → AI model service: requests response
- Chat and prompt → MCP chat integration: supports tool context
- MCP chat integration → MCP connections: uses MCP
- MCP connections → External MCP tools: connects tools
- Chat response job → Agent skills: extends chat
- MCP connections → OpenAlex tools: offers tools
