How damianmorozov/opentgresearcher works
Project type and purpose
• This is a multi-frontend .NET solution (“OpenTgResearcher”) that provides a Telegram research and download tool.
• It implements a layered architecture: Core (domain models & services), Infrastructure (helpers, contracts, view-models), Storage (EF Core repositories & contexts), and multiple Presentation apps (Blazor web UI, console, WinUI3/desktop, WPF desktop).
File structure
• Top-level solution file and Directory.Build.* define build settings.
• “Core/TgDownloaderDesktop.Core”: domain services and models (IFileService, sample data).
• “Core/TgInfrastructure”: common contracts (ITgConnectClient, ITgViewModelBase…), helpers (logging, licensing), enums, DTO/view-model interfaces.
• “Core/TgStorage”: EF Core contexts for various host types (Blazor, Console, Desktop, Memory, Test), repositories for entities (Apps, Contacts, Messages, Sources…), migrations, DTOs & view-models.
• “Presentation”: four independent host projects sharing the same Core/Infrastructure/Storage layers:
• TgDownloaderBlazor – Blazor Server app
• TgDownloaderConsole – console UI w/ menu helpers
• TgDownloaderDesktop – WinUI3 MVVM desktop
• TgDownloaderWinDesktopWPF – WPF desktop MVVM
• “Tests”: unit/integration tests for Core, Console, Desktop, Storage.
• “Settings”: JSON configs per host.
• Dockerfiles under Presentation projects for containerized deployment.
Key insights from README
• The product is a Telegram chat downloader/researcher.
• Requires Telegram API credentials (api_id/api_hash).
• Offers guides for console, desktop, Docker, filters, groups.
• Releases are published on GitHub and Docker Hub.
Main components
a. Core layer
– Domain models & services (FileService, SampleDataService).
b. Infrastructure layer
– Contracts & interfaces (ITgConnectClient, ITgDbProxy, ITgHelper)
– Helpers (TgLogHelper, TgLicenseManagerHelper)
– ViewModel base types & DTOs
c. Storage layer
– EF Core contexts (Blazor, Console, Desktop, Memory, Test)
– Repositories (Apps, Contacts, Messages, Sources, Proxies, Filters…)
– Migrations (per host)
– Database (SQLite/SQL Server, etc.)
d. Presentation layer (four hosts)
– Blazor Server app
– Console menu app
– WinUI3 desktop MVVM
– WPF desktop MVVM
e. External services & resources
– Telegram API (via TgConnectClientBase)
– License API (TgLicense)
– File system (FileService)
– Docker registry (for container images)
Relationships & interactions
• Presentation apps → call Infrastructure contracts (e.g., ITgConnectClient for Telegram, ITgDbProxy for storage)
• Infrastructure → delegates to Storage layer via repository interfaces (ITgEfRepository)
• Storage → EF Core contexts → Database
• Infrastructure & Storage → use Core services for file operations & sample data if needed
• Presentation apps → use MVVM: Views bind to ViewModels from Infrastructure
• All layers use dependency injection (inject services & repositories)
Architectural patterns & design principles
• Layered architecture (Core → Infrastructure → Storage → Presentation)
• Repository pattern (EF Core repositories abstract DB)
• MVVM pattern for desktop & Blazor (ViewModels expose data & commands)
• Dependency inversion (interfaces in Infrastructure, implementations in Storage & Core)
• Single solution with multiple host projects sharing layers
• Use of migrations for multiple contexts per host
Step-by-step guidance
8. Validate coverage: ensure all top-level folders/projects appear as components or sub-components.
Detail
• Major services and contracts.
• Reuse: one Storage layer serving multiple hosts.
• Migration sub-systems per host context.