# ezzylearning/ai_agents_in_csharp_dotnet architecture

> Architecture diagram of the GitHub repository ezzylearning/ai_agents_in_csharp_dotnet, 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/ezzylearning/ai_agents_in_csharp_dotnet
- Repository: https://github.com/ezzylearning/ai_agents_in_csharp_dotnet

## Overview

Northwind.Api exposes an order-support chat endpoint. A customer submits a message, the controller invokes the support-agent abstraction, and the Ollama-backed agent can use order tools to retrieve status or delivery information from the SQL-backed order store. The graph also shows the domain and persistence mapping layer. Evidence is limited to the supplied excerpts and SOURCE INDEX; startup wiring and some subsystem behavior are not shown, so unsupported links are omitted.

Main entry points: [`Northwind.Infrastructure/DependencyInjection.cs`](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/DependencyInjection.cs) (Infrastructure registration), [`Northwind.Infrastructure/Data/NorthwindDbContext.cs`](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/Data/NorthwindDbContext.cs) (EF database context), [`Northwind.Infrastructure/AI/Agents/Ollama/OllamaAgentFactory.cs`](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/AI/Agents/Ollama/OllamaAgentFactory.cs) (Agent factory), [`Northwind.Api/Controllers/SupportController.cs`](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Api/Controllers/SupportController.cs) (Support endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_support_controller["Support endpoint"]
end

subgraph group_support["AI support"]
  node_support_contract["Support contract"]
  node_ollama_agent["Ollama agent"]
  node_agent_factory["Agent factory"]
  node_order_tools["Order tools<br/>[OrderTools.cs]"]
end

subgraph group_orders["Order domain"]
  node_order_contract["Order repository contract"]
  node_order_repository["Order queries<br/>[OrderRepository.cs]"]
  node_order_entity["Order entity<br/>[Order.cs]"]
end

subgraph group_persistence["Persistence"]
  node_db_contract["Database contract"]
  node_db_context["EF database context"]
  node_order_mapping["Order mapping"]
  node_infrastructure_registration["Infrastructure registration"]
end

node_customer(("Customer"))
node_ollama_service["Ollama model"]
node_sql_database[("SQL database")]

node_customer -->|"submits message"| node_support_controller
node_support_controller -->|"asks agent"| node_support_contract
node_support_controller -->|"returns response"| node_customer
node_ollama_agent -->|"implements"| node_support_contract
node_ollama_agent -->|"creates agent"| node_agent_factory
node_agent_factory -->|"registers tools"| node_order_tools
node_agent_factory -->|"creates client"| node_ollama_service
node_order_tools -->|"requests order data"| node_order_contract
node_order_repository -->|"implements"| node_order_contract
node_order_repository -->|"queries orders"| node_db_contract
node_db_context -->|"implements"| node_db_contract
node_db_context -->|"exposes orders"| node_order_entity
node_db_context -->|"applies mappings"| node_order_mapping
node_order_mapping -->|"maps fields"| node_order_entity
node_infrastructure_registration -->|"registers context"| node_db_context
node_infrastructure_registration -->|"binds context"| node_db_contract
node_infrastructure_registration -->|"registers repository"| node_order_repository
node_infrastructure_registration -->|"binds repository"| node_order_contract
node_infrastructure_registration -->|"registers tools"| node_order_tools
node_infrastructure_registration -->|"registers factory"| node_agent_factory
node_infrastructure_registration -->|"binds agent"| node_ollama_agent
node_infrastructure_registration -->|"configures SQL"| node_sql_database
node_db_context -.->|"accesses store"| node_sql_database

click node_support_controller "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Api/Controllers/SupportController.cs"
click node_support_contract "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Application/AI/Agents/ICustomerSupportAgent.cs"
click node_ollama_agent "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/AI/Agents/Ollama/OllamaCustomerSupportAgent.cs"
click node_agent_factory "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/AI/Agents/Ollama/OllamaAgentFactory.cs"
click node_order_tools "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/AI/Tools/OrderTools.cs"
click node_order_contract "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Domain/Orders/IOrderRepository.cs"
click node_order_repository "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/Orders/OrderRepository.cs"
click node_order_entity "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Domain/Orders/Order.cs"
click node_db_contract "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Application/Data/IApplicationDbContext.cs"
click node_db_context "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/Data/NorthwindDbContext.cs"
click node_order_mapping "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/Orders/OrderConfigurations.cs"
click node_infrastructure_registration "https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/DependencyInjection.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_support_controller toneBlue
class node_support_contract,node_ollama_agent,node_agent_factory,node_order_tools,node_sql_database toneAmber
class node_order_contract,node_order_repository,node_order_entity toneMint
class node_db_contract,node_db_context,node_order_mapping,node_infrastructure_registration toneRose
class node_customer,node_ollama_service toneIndigo
```

## Components

### API entry

- [Support endpoint](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Api/Controllers/SupportController.cs): `Northwind.Api/Controllers/SupportController.cs`

### AI support

- [Support contract](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Application/AI/Agents/ICustomerSupportAgent.cs): `Northwind.Application/AI/Agents/ICustomerSupportAgent.cs`
- [Ollama agent](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/AI/Agents/Ollama/OllamaCustomerSupportAgent.cs): `Northwind.Infrastructure/AI/Agents/Ollama/OllamaCustomerSupportAgent.cs`
- [Agent factory](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/AI/Agents/Ollama/OllamaAgentFactory.cs): `Northwind.Infrastructure/AI/Agents/Ollama/OllamaAgentFactory.cs`
- [Order tools](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/AI/Tools/OrderTools.cs): `Northwind.Infrastructure/AI/Tools/OrderTools.cs`

### Order domain

- [Order repository contract](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Domain/Orders/IOrderRepository.cs): `Northwind.Domain/Orders/IOrderRepository.cs`
- [Order queries](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/Orders/OrderRepository.cs): `Northwind.Infrastructure/Orders/OrderRepository.cs`
- [Order entity](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Domain/Orders/Order.cs): `Northwind.Domain/Orders/Order.cs`

### Persistence

- [Database contract](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Application/Data/IApplicationDbContext.cs): `Northwind.Application/Data/IApplicationDbContext.cs`
- [EF database context](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/Data/NorthwindDbContext.cs): `Northwind.Infrastructure/Data/NorthwindDbContext.cs`
- [Order mapping](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/Orders/OrderConfigurations.cs): `Northwind.Infrastructure/Orders/OrderConfigurations.cs`
- [Infrastructure registration](https://github.com/ezzylearning/ai_agents_in_csharp_dotnet/blob/main/Northwind.Infrastructure/DependencyInjection.cs): `Northwind.Infrastructure/DependencyInjection.cs`

### Other components

- **Customer**
- **Ollama model**
- **SQL database**

## Connections

- Customer → Support endpoint: submits message (evidence: `Northwind.Api/Controllers/SupportController.cs`)
- Support endpoint → Support contract: asks agent (evidence: `Northwind.Api/Controllers/SupportController.cs`)
- Support endpoint → Customer: returns response (evidence: `Northwind.Api/Controllers/SupportController.cs`)
- Ollama agent → Support contract: implements (evidence: `Northwind.Infrastructure/AI/Agents/Ollama/OllamaCustomerSupportAgent.cs`)
- Ollama agent → Agent factory: creates agent (evidence: `Northwind.Infrastructure/AI/Agents/Ollama/OllamaCustomerSupportAgent.cs`)
- Agent factory → Order tools: registers tools (evidence: `Northwind.Infrastructure/AI/Agents/Ollama/OllamaAgentFactory.cs`)
- Agent factory → Ollama model: creates client (evidence: `Northwind.Infrastructure/AI/Agents/Ollama/OllamaAgentFactory.cs`)
- Order tools → Order repository contract: requests order data (evidence: `Northwind.Infrastructure/AI/Tools/OrderTools.cs`)
- Order queries → Order repository contract: implements (evidence: `Northwind.Infrastructure/Orders/OrderRepository.cs`)
- Order queries → Database contract: queries orders (evidence: `Northwind.Infrastructure/Orders/OrderRepository.cs`)
- EF database context → Database contract: implements (evidence: `Northwind.Infrastructure/Data/NorthwindDbContext.cs`)
- EF database context → Order entity: exposes orders (evidence: `Northwind.Infrastructure/Data/NorthwindDbContext.cs`)
- EF database context → Order mapping: applies mappings (evidence: `Northwind.Infrastructure/Data/NorthwindDbContext.cs`)
- Order mapping → Order entity: maps fields (evidence: `Northwind.Infrastructure/Orders/OrderConfigurations.cs`)
- Infrastructure registration → EF database context: registers context (evidence: `Northwind.Infrastructure/DependencyInjection.cs`)
- Infrastructure registration → Database contract: binds context (evidence: `Northwind.Infrastructure/DependencyInjection.cs`)
- Infrastructure registration → Order queries: registers repository (evidence: `Northwind.Infrastructure/DependencyInjection.cs`)
- Infrastructure registration → Order repository contract: binds repository (evidence: `Northwind.Infrastructure/DependencyInjection.cs`)
- Infrastructure registration → Order tools: registers tools (evidence: `Northwind.Infrastructure/DependencyInjection.cs`)
- Infrastructure registration → Agent factory: registers factory (evidence: `Northwind.Infrastructure/DependencyInjection.cs`)
- Infrastructure registration → Ollama agent: binds agent (evidence: `Northwind.Infrastructure/DependencyInjection.cs`)
- Infrastructure registration → SQL database: configures SQL (evidence: `Northwind.Infrastructure/DependencyInjection.cs`)
- EF database context → SQL database: accesses store
