How leakyrus/hostedsender works
1. Overall shape
- This is a multi-project .NET solution split into a shared core, concrete handler packages, Windows-specific adapters, and host executables.
- The architecture is intentionally modular: most behavior is defined by interfaces in Handlers.Abstractions, while implementation lives in separate packages.
2. Core abstraction layer
- Handlers.Abstractions defines the domain contracts and settings models used across the system.
- It includes handler interfaces for major output domains: Box, Osc, PatternCollections, configuration, JSON, and pattern handling.
- This layer is the main boundary for dependency inversion: higher-level logic depends on abstractions, not on transport or OS-specific details.
3. Pattern execution model
- The PatternHandlerSettings folder defines the configuration objects that drive behavior, such as DefaultPatternHandlerSetting, MediaPatternHandlerSetting, DateTimePatternHandlerSetting, AfkPatternHandlerSettings, AnimationPatternHandlerSetting, and ProcessExecutionTimePatternHandlerSetting.
- PatternBuilder and IPatternBuilder/IPatternHandler indicate that the app constructs runtime handlers from configuration rather than hardcoding them.
- Handlers.PatternHandlers contains the concrete handler implementations that interpret those settings and produce pattern-specific results.
4. Configuration and persistence
- Handlers.Config provides the runtime config reader and default config creation.
- Handlers.Abstractions.Config and Handlers.Abstractions.Json define the contracts for config loading and serialization behavior.
- Handlers.Json supplies the concrete JSON serializer option provider and pattern-setting type resolver, which suggests polymorphic config serialization is a key part of the system.
5. Collection and grouping layer
- PatternCollections is a separate abstraction/implementation pair, implying the app groups patterns into collections rather than handling them one-by-one.
- This is likely the unit the host consumes: a collection of pattern definitions is loaded, built, and executed as a cohesive set.
6. Output/transport subsystems
- Handlers.Osc and Handlers.Box represent two distinct output domains.
- OSC support is split into handler, builder, and collection types, suggesting the app can assemble and manage multiple OSC endpoints or channels.
- Box support provides a similar abstraction for another output target or device-facing integration, likely treated as a separate transport boundary.
7. Context providers for runtime state
- Handlers.Abstractions.Media and Handlers.Media.Windows provide media state access through IMediaInfoProvider.
- Handlers.Abstractions.UserInputInfo and Handlers.UserInputInfo.Windows provide user-input/AFK-related state via IUserInputProvider.
- These are environment-aware inputs consumed by pattern handlers, so runtime behavior depends on live system state rather than only static config.
8. Host/runtime orchestration
- Hosted.Worker is the runtime coordinator: it contains Runner, WorkerHost, FileWatcher, and Lazier, indicating it watches for changes and drives execution lazily or incrementally.
- This layer is the main composition root for long-running behavior and likely owns the main control loop.
- appsettings.json in this project suggests it also has standard host configuration alongside the app-specific config files.
9. Executable entry points
- Hosted.Windows is the top-level runnable app, with Program.cs as the entry point.
- Hosted.Worker.Windows and Handlers.UserInputInfo.Windows / Handlers.Media.Windows are Windows-only implementation packages, which cleanly separate OS-dependent code from the shared core.
- The solution is therefore not purely cross-platform; Windows-specific services are isolated behind interfaces.
10. Dependency injection as composition mechanism
- Nearly every implementation project contains a DependencyInjection.cs, showing that startup wiring is done through DI modules rather than manual object creation.
- This is how abstractions, handlers, providers, and transports are assembled into a working pipeline at host startup.
11. Data flow at a high level
- Config is loaded and/or generated, then JSON type resolution materializes concrete pattern settings.
- Pattern collections are converted into pattern handlers through the builder layer.
- Pattern handlers pull live context from media and user-input providers and then emit output through OSC or Box handlers.
- The worker host monitors for changes and re-runs the pipeline as needed.
12. Operational/tooling boundary
- The repo includes a GitHub Actions workflow and publish profiles under Hosted.Windows, indicating it is built and packaged as a distributable Windows application.
- The solution file ties all packages together, but the important architecture boundary remains: shared contracts + modular implementations + hosted runtime.
Main entry points: Hosted.Worker.csproj Worker · Handlers.csproj Patterns · Handlers.Abstractions.csproj Handlers.Abstractions · PatternHandler.cs Pattern handlers
Components 16
Contracts
Shared abstractions and settings models
- Handlers.Abstractions · Core interfaces, settings, and domain contracts
Handlers.Abstractions/Handlers.Abstractions.csproj - Media contracts · Media state abstraction layer
Handlers.Abstractions.Media/Handlers.Abstractions.Media.csproj - Input contracts · User-input and AFK abstraction layer
Handlers.Abstractions.UserInputInfo/Handlers.Abstractions.UserInputInfo.csproj
Implementations
Concrete handler, config, and JSON packages
- Config · Config reader and default config creation
Handlers.Config/Handlers.Config.csproj - JSON · Polymorphic serialization support
Handlers.Json/Handlers.Json.csproj - Patterns · Concrete pattern handler implementations
Handlers/Handlers.csproj - PatternBuilder · Builds handlers from pattern settings
Handlers/PatternHandlers/PatternBuilder.cs - Pattern handlers · Default, media, datetime, AFK, animation, and timing handlers
Handlers/PatternHandlers/PatternHandler.cs - Box · Box output handler implementation
Handlers.Box/Handlers.Box.csproj - OSC · OSC handler, builder, and collection implementation
Handlers.Osc/Handlers.Osc.csproj - Collections · Pattern collection handling layer
Handlers.PatternCollections/Handlers.PatternCollections.csproj
Runtime
Worker and executable hosts
- Worker · File watcher, runner, lazy reload, host loop
Hosted.Worker/Hosted.Worker.csproj - Hosted.Windows · Top-level executable entry point
Hosted.Windows/Hosted.Windows.csproj
Windows
Windows-specific providers and host wiring
- Media provider · Windows media info provider
Handlers.Media.Windows/Handlers.Media.Windows.csproj - Input provider · Windows user-input provider
Handlers.UserInputInfo.Windows/Handlers.UserInputInfo.Windows.csproj - Worker.Windows · Windows-specific worker wiring
Hosted.Worker.Windows/Hosted.Worker.Windows.csproj
Connections 23
- Config → Handlers.Abstractions: implements config · Provides concrete config reader and default config creator
- JSON → Handlers.Abstractions: implements json · Provides serializer options and type resolution
- Collections → Handlers.Abstractions: implements collections · Implements collection contracts for patterns
- Box → Handlers.Abstractions: implements box · Implements box handler contracts
- OSC → Handlers.Abstractions: implements osc · Implements OSC handler contracts
- Patterns → Handlers.Abstractions: implements patterns · Implements pattern handler contracts
- Patterns → PatternBuilder: contains · Hosts the builder that materializes handlers
- PatternBuilder → Pattern handlers: creates · Builds concrete handlers from settings
- Pattern handlers → Media contracts: reads media · Consumes live media state through abstraction
- Pattern handlers → Input contracts: reads input · Consumes user-input/AFK state through abstraction
- Media provider → Media contracts: implements media · Windows media provider implementation
- Input provider → Input contracts: implements input · Windows user-input provider implementation
- Worker → Config: loads config · Reads runtime configuration and watches for changes
- Worker → Collections: runs collections · Coordinates loaded pattern collections
- Worker → Patterns: executes patterns · Drives pattern execution pipeline
- Worker → Box: routes output · Sends results to box transport
- Worker → OSC: routes output · Sends results to OSC transport
- Worker.Windows → Worker: wires · Windows-specific startup composition
- Hosted.Windows → Worker.Windows: starts · Executable entry point bootstraps worker host
- Hosted.Windows → Worker: hosts · Runs the long-lived worker pipeline
- Patterns → Media provider: uses provider · Pattern logic depends on live media data at runtime
- Patterns → Input provider: uses provider · Pattern logic depends on live input state at runtime
- JSON → Patterns: serializes settings · Supports polymorphic pattern setting materialization