A modular, clean-architecture and web-ready chat client built with .NET 10 to interact with local Large Language Models (LLMs) via Ollama.
This project leverages the latest Microsoft.Extensions.AI ecosystem and the Microsoft Agent Framework to orchestrate conversational sessions with advanced features like dynamic model switching mid-conversation, system prompt behavior customization, and local persistence.
Multi-Session Chat Management: Create, rename, and manage independent conversation sessions. Pick up exactly where you left off.
- Dynamic Model Switching: Run infinite different models (e.g., Llama 3, Phi-3, Mistral) within a single session. Every individual assistant message tracks which model generated it.
- Real-time Token Streaming: Modern asynchronous token streaming using C#'s
IAsyncEnumerablefor an instant, responsive UI experience. - System Prompt Customization: Define specific agent behaviors and roles (e.g., "Act as a software architecture professor", "Be technical", etc.) per session.
- Persistent Local History: Full conversation histories safely stored locally using Entity Framework Core (abstracted to allow seamless migration to Dapper or raw SQL).
- Rich Markdown Rendering: Native UI interpretation for titles, tables, code blocks, bullet points, and text emphasis.
The solution strictly follows Clean Architecture principles to ensure infrastructure components (like databases or AI orchestrators) can be swapped out without affecting the core application business rules.
┌─────────────────┐ │ Clients │ ├─────────────────┤ │ Blazor │ │ WPF (planned) │ │ MAUI (planned) │ └────────┬────────┘ │ ┌────────▼────────┐ │ Web API │ └────────┬────────┘ │ ┌───────▼────────┐ │ Application │ └───────┬────────┘ │ ┌───────▼────────┐ │ Domain │ └───────┬────────┘ │ ┌───────▼────────┐ │ Infrastructure │ └───────┬────────┘ │ ┌───────▼────────┐ │ Ollama │ └────────────────┘
- .NET 10
- ASP.NET Core Web API
- Blazor
- WPF
- Microsoft.Extensions.AI
- Microsoft Agent Framework
- Ollama
- Entity Framework Core
- SQLite
The persistence layer follows a hybrid identifier strategy designed for both performance and security:
- Integer (
int) primary keys are used internally for database relationships and indexing. - GUID tokens are exposed to API and client applications, preventing enumeration attacks and protecting internal database structure.
- Optimized for efficient joins, indexing, and scalability.
The Domain Layer contains zero third-party dependencies, ensuring:
- Clean Architecture compliance.
- High testability.
- Business rules independent of infrastructure concerns.
- Easier migration between technologies.
All database mappings are configured externally using Entity Framework Core Fluent API.
Benefits:
- Keeps entities clean and persistence-agnostic.
- Separates business logic from database concerns.
- Improves maintainability and flexibility.
| Category | Technology |
|---|---|
| Backend Framework | .NET 10 |
| AI Orchestration | Microsoft.Extensions.AI |
| Agent Framework | Microsoft Agent Framework (MAF) |
| Local LLM Runtime | Ollama |
| API Framework | ASP.NET Core Web API |
| ORM / Persistence | Entity Framework Core |
| Architecture | Clean Architecture |
| Data Access Pattern | Repository Pattern |
| Future Data Access | Optimized for Dapper/Raw SQL migration |
| Frontend | Blazor Server |
| Desktop Client | WPF (Planned) |
| Cross-Platform Client | .NET MAUI (Planned) |
Before running the project, ensure you have:
- .NET 10 SDK installed
- Ollama installed and running locally
Official Ollama server endpoint:
http://localhost:11434
Download one or more models using the terminal:
ollama pull llama3
ollama pull phi3git clone https://github.com/christianocj/OllamaPlatform.NET.gitcd ChatOllama/src/ChatOllama.Apidotnet run