NexusChat
FlagshipCross-platform multi-model AI streaming client with local encrypted persistence in .NET 9 MAUI
Architecture Overview
NexusChat is a single-project cross-platform application built with C# and .NET 9 MAUI. The application targets Windows (WinUI 3), Android (API 21+), iOS (15+), and macOS (MacCatalyst).
It implements the MVVM architecture pattern using CommunityToolkit.Mvvm 8.4.0 source generators ([ObservableProperty], [RelayCommand]), providing compiled reactive bindings with minimal boilerplate.
Core Engineering Decisions
1. Decoupled AI provider factory
The application abstracts multiple AI model APIs behind a unified IAIService interface:
public interface IAIService
{
IAsyncEnumerable<string> StreamCompletionAsync(
ConversationContext context,
CancellationToken cancellationToken = default
);
Task<ModelCapabilities> GetCapabilitiesAsync();
}
The AIServiceFactory dynamically resolves concrete provider implementations for OpenAI, Anthropic Claude, Google Gemini, Groq, Azure OpenAI, and OpenRouter without coupling chat view models to specific network payloads.
2. Offline simulation engine (DummyAIService)
To enable full offline development, regression testing, and UI benchmarking without incurring LLM API token costs, the architecture includes a DummyAIService. It simulates realistic response streaming latency, configurable typing speeds, and simulated HTTP error codes.
3. Real-time token streaming via Server-Sent Events
Instead of buffering complete HTTP responses, NexusChat consumes Server-Sent Events (SSE) using IAsyncEnumerable<string>. Tokens render into custom XAML MessageBubble views with markdown formatting as they arrive over the wire.
4. Local encrypted persistence
All conversations, message trees, and user credentials persist locally using sqlite-net-pcl and SQLiteNetExtensions.Async. User passwords and cryptographic keys are hashed using BCrypt.Net-Next 4.0.3 and stored using platform-native secure storage APIs.
5. In-app developer diagnostic tools
- Live Database Viewer: In-app SQLite table explorer enabling developers to inspect, filter, and verify table rows in real time.
- Model Playground: Parameter sandbox to adjust temperature, top-p, and test model latency.
- Theme Token Explorer: Dynamic theme previewer managing dark/light modes and vector icons.