How pedrohenriquebr/horus works
Project type and purpose
• This is a full-featured AI assistant platform (“Horus AI Assistant”) built on .NET 8.0.
• It exposes an ASP.NET Core API (with a minimal static frontend in wwwroot), integrates with multiple LLM providers (Gemini, Ollama), implements a RAG-based memory layer (PostgreSQL + pgvector), uses Redis for caching and rate-limiting, and offers a Telegram Bot interface plus an extensible tool system (web search, file operations, etc.).
File structure
• Top-level:
• .docker & docker-compose.yaml – container definitions for Postgres, Redis, etc.
• backend/ – the main .NET solution (Horus.sln)
• legacy/ – older Python proof-of-concept (can be omitted or shown as “historical”).
• backend/ hierarchy:
• Api/RootBootstrapper – ASP.NET Core startup (Program.cs, middleware, static assets).
• Horus.Modules.Core.Application – Application layer (CQRS via MediatR, behaviors, decorators, services for embeddings, RAG, memory, Telegram Bot hosted service).
• Horus.Modules.Core.Domain – Domain entities, interfaces, value objects, domain services.
• Horus.Modules.Core.Infra – Infrastructure implementations (EF Core context, pgvector converter, Redis cache, LLM provider adapters for Gemini/Ollama, RAG/Postgres, rate limiter, file system tools).
• Shared & Contract projects – shared abstractions, configuration objects, events, audit logging.
• IntegrationTests / UnitTests / Benchmarks – test and performance projects illustrating pipelines and CI usage.
• Configuration:
• appsettings.json + environment overrides define connection strings, API keys, rate-limit settings.
• .env and Makefile/VSCode tasks for local dev.
Inspect the README for architectural insights
• “API Layer”: ASP.NET Core + MediatR (CQRS).
• “LLM Integration”: Multi-provider fallback system.
• “Storage”: PostgreSQL + pgvector, Redis.
• “Memory System”: RAG-based with similarity search.
• “Tools”: Modular.
• “Telegram Bot”: Hosted service.
• Docker Compose orchestrates dependencies in development.
a. Main components
• Clients:
– Telegram Bot users (via Telegram API)
– (Optional) Web UI served from wwwroot
– CLI or Playground projects
• API Layer: ASP.NET Core (RootBootstrapper)
• Application Layer: MediatR handlers, CQRS pipeline (Validation, UnitOfWork, Caching)
• Domain Layer: Entities, domain services, interfaces (IRepository, IPromptTemplate, etc.)
• Infrastructure Layer:
– Database: PostgreSQL + pgvector
– Cache: Redis
– LLM Providers: Gemini API, Ollama local
– RAG Service: PostgresRagService, DefaultMemoryProvider
– Tools subsystem: WebSearch, FileSystem
– Rate Limiter: TokenBucketRateLimiter
• Background Jobs: Hangfire queues or hosted services (TelegramBotHostedService)
• External Services:
– Telegram API
– Gemini Cloud API
– Ollama daemon
– Supabase / HuggingFace API (for embedding model)
b. Relationships & data flows
1. Client → ASP.NET Core API → MediatR → Application services
2. Application service may:
• Query Domain Entities via Repository → PostgreSQL
• Write Domain Events or persist entities → PostgreSQL
• Enqueue background tasks → Hangfire
• Check or populate Redis cache → Redis
• Call LLM Providers → Gemini / Ollama
• Perform RAG retrieval → pgvector similarity search → Document store
• Invoke Tools → Web search / File operations
3. Results flow back through Application → API → Client
c. Architectural patterns & design principles
• Layered (Onion/Clean) architecture
• CQRS & MediatR pipeline with behaviors (Validation, UnitOfWork, Caching)
• Dependency Injection via IServiceCollection extensions
• Decorator pattern (UnitOfWorkDecorator, caching attribute)
• Hosted services for long-running tasks (TelegramBotHostedService)
• RAG (Retrieval-Augmented Generation) for memory
d. Key technologies/frameworks
• ASP.NET Core 8.0, MediatR, Entity Framework Core + pgvector
• Redis (StackExchange.Redis)
• Docker & Docker Compose
• LLM integration libraries (HTTP clients for Gemini, Ollama, HuggingFace)
• xUnit for tests, BenchmarkDotNet for benchmarks
• C# attributes for caching and domain events
Diagramming conventions
• Presentation (light blue)
• Application (green)
• Domain (yellow)
• Infrastructure (orange)
• External (gray)