How kaoticz/nadekohub works
Project type and purpose
• NadekoHub is a cross-platform desktop application (built on .NET and Avalonia UI) designed to manage Discord bot instances (NadekoBot).
• It follows an MVVM (Model-View-ViewModel) architecture, uses dependency injection, and integrates with external APIs (GitHub, GitLab, “Evermeet” macOS FFmpeg host) and local processes (FFmpeg, yt-dl-pine via command line).
File structure
• Top-level
– NadekoHub.sln: .NET solution.
– NadekoHub/: main project directory.
– .github/workflows: CI/CD.
– Dockerfile/.dockerignore: containerization.
• Inside NadekoHub/
– App.axaml(.cs), Program.cs, App.manifest: application entry, Avalonia app.
– Avalonia/: UI resources (Styles, Assets, DesignData for XAML preview).
– Features/: modular feature folders (AppConfig, AppWindow, BotConfig, Home, Common). Each contains Models, Services, ViewModels, Views.
– Common/: shared controls and services.
– Extensions/: DI extensions, HTTP client helpers.
– Enums/, Common/, Usings.cs, ViewLocator.cs: app constants and wiring.
README
• Confirms core functions: install/update/remove bot instances, dependency management (FFmpeg, yt-dl), configuration UIs, log streaming, backups.
• No external database; persistence likely via local file system (AppConfigManager).
• Target platforms: Windows, Linux, macOS.
a. Main components
1. UI Layer (Avalonia Views & Resources)
2. Presentation Layer (ViewModels)
3. Service Layer
• AppConfig services (IAppConfigManager, IFfmpegResolver, IYtdlpResolver)
• BotConfig services (IBotOrchestrator, IBotResolver, ILogWriter)
• Home services (IAppResolver)
• Common services (IDependencyResolver)
4. Model Layer (DTOs for API responses, local settings, event args)
5. Infrastructure
• DI Container (IServiceCollectionExt)
• HTTP Client
• Local process runner (ProcessStart for bots, FFmpeg, yt-dl)
• File system (config files, logs, backups)
6. External Services
• GitHub API
• GitLab API
• Evermeet API
• FFmpeg/YT-DLP binaries repos
7. Platform Host
• Docker (optional)
• OS (Windows, Linux, macOS)
b. Relationships & data flow
• On startup, Program.cs → DI Container → App.axaml → MainWindow (AppView).
• AppView uses ViewLocator to pick feature Views (Home, Config, BotConfig).
• UI binds to ViewModels. ViewModels invoke Service Layer via injected interfaces.
• Service Layer calls Models and Infrastructure:
– HTTP calls to external APIs fetch release info.
– Local resolvers download/verify FFmpeg, yt-dl, manage bot binaries.
– BotOrchestrator launches/stops bot processes; LogWriter streams console output.
– AppConfigManager persists settings to file system.
• Events (ProcessStdWrite, BotExit) bubble back to ViewModels to update UI.
c. Architectural patterns & design principles
• MVVM: clear separation of Views, ViewModels, Models.
• Dependency Injection: IServiceCollectionExt for registration of Abstractions → Implementations.
• Modular features: each Feature folder encapsulates Models, Services, ViewModels, Views.
• Single Responsibility: resolvers, orchestrators, log writers each handle one concern.
• Asynchronous calls: non-blocking UI when calling external services or running processes.
d. Relevant technologies/frameworks
• Avalonia UI (cross-platform XAML)
• .NET 6+
• Microsoft.Extensions.DependencyInjection
• System.Net.Http (HttpClient)
• ProcessStart for external binaries
• GitHub/GitLab REST APIs
• GNU GPL v3 license