# granit-fx/granit-dotnet architecture

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

- Interactive diagram: https://gitdiagram.com/granit-fx/granit-dotnet
- Repository: https://github.com/granit-fx/granit-dotnet

## Overview

Granit is a modular .NET framework spanning infrastructure and business domains. The sampled query-engine code shows a clear user workflow: HTTP query requests reach a handler, which delegates execution to the EF Core query engine; query definitions describe available fields and operations. The repository also includes AI, chat, prompt, vector-search, extraction, storage, and data-exchange packages, reflected here as capability branches rather than a complete runtime call map. Unsampled integrations are grouped by their exact tree paths; their internal wiring is not assumed.

Main entry points: [`src/Granit.AI`](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI) (AI Abstractions), [`src/Granit.QueryEngine.EntityFrameworkCore/Internal/QueryEngine.cs`](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.EntityFrameworkCore/Internal/QueryEngine.cs) (EF Query Engine), [`src/Granit.QueryEngine.AI`](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.QueryEngine.AI) (Natural Language Query), [`src/Granit/Modularity/GranitModule.cs`](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit/Modularity/GranitModule.cs) (Module Lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundation["Framework Foundation"]
  node_modules["Module Lifecycle<br/>[GranitModule.cs]"]
  node_service_context["Service Configuration"]
  node_tenant_context["Tenant Context<br/>[ICurrentTenant.cs]"]
  node_data_filter["Data Filtering<br/>[IDataFilter.cs]"]
end

subgraph group_query["Query Engine"]
  node_query_http["Query HTTP API<br/>[Endpoints]"]
  node_query_handler["Query Handler"]
  node_query_definition["Query Definition<br/>[QueryDefinition.cs]"]
  node_query_builder["Definition Builder"]
  node_query_executor["EF Query Engine<br/>[QueryEngine.cs]"]
  node_query_metadata["Query Metadata<br/>[QueryMetadata.cs]"]
  node_query_nlq["Natural Language Query"]
  node_query_tools["Query AI Tools"]
end

subgraph group_ai["AI Capabilities"]
  node_ai_core["AI Abstractions<br/>[Granit.AI]"]
  node_ai_providers["LLM Providers<br/>[Granit.AI.OpenAI]"]
  node_ai_chat["AI Chat<br/>[Message.cs]"]
  node_ai_chat_api["Chat Endpoints<br/>[Endpoints]"]
  node_ai_prompts["Prompt Catalogue<br/>[Granit.AI.Prompts]"]
  node_ai_vectors["Vector Search"]
  node_ai_extraction["Document Extraction"]
  node_ai_mcp["MCP Integration<br/>[Granit.AI.Mcp]"]
end

subgraph group_domain["Domain Modules"]
  node_storage["Blob Storage"]
  node_data_exchange["Data Exchange"]
  node_presence["Presence Queries"]
end

node_developer(("Application Developer"))
node_query_client(("API Consumer"))

node_developer -->|"configures"| node_modules
node_modules -->|"configures services"| node_service_context
node_query_client -->|"sends query"| node_query_http
node_query_http -.->|"handles requests"| node_query_handler
node_query_handler -->|"executes query"| node_query_executor
node_query_definition -->|"configures"| node_query_builder
node_query_executor -->|"builds metadata"| node_query_metadata
node_query_nlq -->|"uses AI client"| node_ai_core
node_query_nlq -->|"uses query metadata"| node_query_definition
node_query_tools -->|"integrates query engine"| node_query_executor
node_ai_chat_api -.->|"serves chat"| node_ai_chat
node_ai_providers -.->|"provides LLMs"| node_ai_core
node_ai_vectors -.->|"supports semantic search"| node_ai_core
node_ai_extraction -.->|"supports extraction"| node_ai_core
node_ai_mcp -.->|"integrates MCP"| node_ai_core
node_ai_prompts -.->|"supplies prompts"| node_ai_chat
node_storage -.->|"stores exchange files"| node_data_exchange
node_tenant_context -.->|"provides tenant scope"| node_data_filter

click node_modules "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit/Modularity/GranitModule.cs"
click node_service_context "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit/Modularity/ServiceConfigurationContext.cs"
click node_tenant_context "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit/MultiTenancy/ICurrentTenant.cs"
click node_data_filter "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit/DataFiltering/IDataFilter.cs"
click node_query_http "https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.QueryEngine.Endpoints/Endpoints"
click node_query_handler "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.Endpoints/Internal/QueryEndpointHandler.cs"
click node_query_definition "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.Abstractions/QueryDefinition.cs"
click node_query_builder "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.Abstractions/QueryDefinitionBuilder.cs"
click node_query_executor "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.EntityFrameworkCore/Internal/QueryEngine.cs"
click node_query_metadata "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.Abstractions/Meta/QueryMetadata.cs"
click node_query_nlq "https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.QueryEngine.AI"
click node_query_tools "https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.QueryEngine.AI.Tools"
click node_ai_core "https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI"
click node_ai_providers "https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.OpenAI"
click node_ai_chat "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.AI.Chat/Domain/Message.cs"
click node_ai_chat_api "https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.Chat.Endpoints/Endpoints"
click node_ai_prompts "https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.Prompts"
click node_ai_vectors "https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.VectorData"
click node_ai_extraction "https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.Extraction"
click node_ai_mcp "https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.Mcp"
click node_storage "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.BlobStorage/Internal/DefaultBlobStorage.cs"
click node_data_exchange "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.DataExchange/Import/Pipeline/ImportPipelineContext.cs"
click node_presence "https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.Presence/Internal/PresenceQueryService.cs"

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_modules,node_service_context,node_tenant_context,node_data_filter toneBlue
class node_query_http,node_query_handler,node_query_definition,node_query_builder,node_query_executor,node_query_metadata,node_query_nlq,node_query_tools toneAmber
class node_ai_core,node_ai_providers,node_ai_chat,node_ai_chat_api,node_ai_prompts,node_ai_vectors,node_ai_extraction,node_ai_mcp,node_query_client toneMint
class node_storage,node_data_exchange,node_presence toneRose
class node_developer toneIndigo
```

## Components

### Framework Foundation

- [Module Lifecycle](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit/Modularity/GranitModule.cs): `src/Granit/Modularity/GranitModule.cs`
- [Service Configuration](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit/Modularity/ServiceConfigurationContext.cs): `src/Granit/Modularity/ServiceConfigurationContext.cs`
- [Tenant Context](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit/MultiTenancy/ICurrentTenant.cs): `src/Granit/MultiTenancy/ICurrentTenant.cs`
- [Data Filtering](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit/DataFiltering/IDataFilter.cs): `src/Granit/DataFiltering/IDataFilter.cs`

### Query Engine

- [Query HTTP API](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.QueryEngine.Endpoints/Endpoints): `src/Granit.QueryEngine.Endpoints/Endpoints`
- [Query Handler](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.Endpoints/Internal/QueryEndpointHandler.cs): `src/Granit.QueryEngine.Endpoints/Internal/QueryEndpointHandler.cs`
- [Query Definition](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.Abstractions/QueryDefinition.cs): `src/Granit.QueryEngine.Abstractions/QueryDefinition.cs`
- [Definition Builder](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.Abstractions/QueryDefinitionBuilder.cs): `src/Granit.QueryEngine.Abstractions/QueryDefinitionBuilder.cs`
- [EF Query Engine](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.EntityFrameworkCore/Internal/QueryEngine.cs): `src/Granit.QueryEngine.EntityFrameworkCore/Internal/QueryEngine.cs`
- [Query Metadata](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.QueryEngine.Abstractions/Meta/QueryMetadata.cs): `src/Granit.QueryEngine.Abstractions/Meta/QueryMetadata.cs`
- [Natural Language Query](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.QueryEngine.AI): `src/Granit.QueryEngine.AI`
- [Query AI Tools](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.QueryEngine.AI.Tools): `src/Granit.QueryEngine.AI.Tools`

### AI Capabilities

- [AI Abstractions](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI): `src/Granit.AI`
- [LLM Providers](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.OpenAI): `src/Granit.AI.OpenAI`
- [AI Chat](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.AI.Chat/Domain/Message.cs): `src/Granit.AI.Chat/Domain/Message.cs`
- [Chat Endpoints](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.Chat.Endpoints/Endpoints): `src/Granit.AI.Chat.Endpoints/Endpoints`
- [Prompt Catalogue](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.Prompts): `src/Granit.AI.Prompts`
- [Vector Search](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.VectorData): `src/Granit.AI.VectorData`
- [Document Extraction](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.Extraction): `src/Granit.AI.Extraction`
- [MCP Integration](https://github.com/granit-fx/granit-dotnet/tree/develop/src/Granit.AI.Mcp): `src/Granit.AI.Mcp`

### Domain Modules

- [Blob Storage](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.BlobStorage/Internal/DefaultBlobStorage.cs): `src/Granit.BlobStorage/Internal/DefaultBlobStorage.cs`
- [Data Exchange](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.DataExchange/Import/Pipeline/ImportPipelineContext.cs): `src/Granit.DataExchange/Import/Pipeline/ImportPipelineContext.cs`
- [Presence Queries](https://github.com/granit-fx/granit-dotnet/blob/develop/src/Granit.Presence/Internal/PresenceQueryService.cs): `src/Granit.Presence/Internal/PresenceQueryService.cs`

### Other components

- **Application Developer**
- **API Consumer**

## Connections

- Application Developer → Module Lifecycle: configures (evidence: `README.md`)
- Module Lifecycle → Service Configuration: configures services (evidence: `src/Granit/Modularity/GranitModule.cs`)
- API Consumer → Query HTTP API: sends query
- Query HTTP API → Query Handler: handles requests
- Query Handler → EF Query Engine: executes query (evidence: `src/Granit.QueryEngine.Endpoints/Internal/QueryEndpointHandler.cs`)
- Query Definition → Definition Builder: configures (evidence: `src/Granit.QueryEngine.Abstractions/QueryDefinition.cs`)
- EF Query Engine → Query Metadata: builds metadata (evidence: `src/Granit.QueryEngine.EntityFrameworkCore/Internal/QueryEngine.cs`)
- Natural Language Query → AI Abstractions: uses AI client (evidence: `src/Granit.QueryEngine.AI/GranitQueryEngineAIModule.cs`)
- Natural Language Query → Query Definition: uses query metadata (evidence: `src/Granit.QueryEngine.AI/GranitQueryEngineAIModule.cs`)
- Query AI Tools → EF Query Engine: integrates query engine (evidence: `src/Granit.QueryEngine.AI.Tools/GranitQueryEngineAIToolsModule.cs`)
- Chat Endpoints → AI Chat: serves chat
- LLM Providers → AI Abstractions: provides LLMs (evidence: `README.md`)
- Vector Search → AI Abstractions: supports semantic search (evidence: `README.md`)
- Document Extraction → AI Abstractions: supports extraction (evidence: `README.md`)
- MCP Integration → AI Abstractions: integrates MCP (evidence: `README.md`)
- Prompt Catalogue → AI Chat: supplies prompts
- Blob Storage → Data Exchange: stores exchange files
- Tenant Context → Data Filtering: provides tenant scope (evidence: `src/Granit/MultiTenancy/ICurrentTenant.cs`)
