How carmc99/squadnet works
Project Type and Purpose
• SquadNet is a modular .NET framework focused on processing SquadGame logs, real-time event detection, and RCON command integration.
• Its core functionality includes log monitoring (via FTP, Tail, and SFTP), an event system that triggers custom logic, and an extensible plugin architecture.
• Additional components (like the REST API and CLI) are under development, which indicates the framework is being built toward a full-stack tool with both service and interface aspects.
Analyzing the File Structure
• Projects are organized into several directories that resemble discrete modules:
• SquadNET.API: Implements a REST API layer (controllers and endpoints for Squad-related operations).
• SquadNET.Application: Contains primary business logic, implemented largely following a CQRS pattern with separate Commands and Queries (reflecting administrative tasks, map handling, player management, etc.).
• SquadNET.Core: Provides the core models, events, parsers, and RCON client functionality.
• SquadNET.Extensions.Exceptions: Adds middleware for standardized exception handling.
• SquadNET.LogManagement: Manages different log reading strategies – FTP, SFTP, Tail – which form the basis for the event system.
• SquadNET.Plugins.Abstractions and SquadNET.Plugins: Define and implement the extensibility model for injecting custom event processing logic.
• SquadNET.Rcon: Contains logic to interface with Squad servers using RCON protocols.
• SquadNET.SquadMonitoringService: Acts as a background service continuously monitoring log changes and handling event processing.
• SquadNET.Test: Contains unit tests, ensuring the core parsing and log management functionality works as expected.
• The solution file (SquadNet.sln) ties these modules together in a multi-project solution.
• The naming in directories (e.g., “Squad”, “Admin”, “Player”, “Map”, etc.) points toward modular responsibilities and separation of concerns in handling Squad game-related events and commands.
a. Main Components:
• Log Monitoring Module: Represents SquadNET.LogManagement with its implementations (FtpLogReader, SftpLogReader, TailLogReader). It’s responsible for ingesting log data.
• Event Processing Engine: Built around the components located in SquadNET.Application and SquadNET.Core. This subsystem translates log entries into events (using parsers) and pushes them for further action.
• API Layer: Provided in SquadNET.API – responsible for exposing endpoints (via controllers) to trigger administrative commands or query event data.
• RCON Integration: Represented by SquadNET.Rcon and part of SquadNET.Core, which manages command execution on Squad servers.
• Plugin Framework: Encapsulated by SquadNET.Plugins.Abstractions and SquadNET.Plugins, which allows custom logic (e.g., ChatMessagePlugin) to hook into the event stream.
• Background Service: Shown in SquadNET.SquadMonitoringService – a continuously running service monitoring logs and processing events in real time.
• Exception Middleware: Provided by SquadNET.Extensions.Exceptions to manage error handling globally across components.
• Test Components: SquadNET.Test is used for unit testing and validating various parts of the system (especially parsers), although it is more of a development tool rather than a runtime component.
b. Relationships and Interactions:
• Log Monitoring initiates data flows by reading logs and passing the raw data to the Event Processing Engine.
• The Event Processing Engine parses log data (using parsers in SquadNET.Core/Squad/Parsers) and produces events.
• Events are then consumed by:
• The Plugin Framework: Custom plugins register to receive events, processing them as defined (e.g., logging chat messages).
• The Background Service: SquadMonitoringService processes real-time events and may forward specific events for further action.
• The API Layer: Which can query event states or trigger commands via controllers that use application services.
• RCON Integration: Issues commands to Squad servers based on processed event information.
• Exception Middleware intercepts errors from multiple components ensuring that exceptions are standardized across the system.
c. Architectural Patterns and Key Design Principles:
• Modular Architecture: Each major functionality is separated into its own project/module, promoting loose coupling.
• CQRS Pattern: Within SquadNET.Application, the separation of Commands and Queries enhances clarity in data processing.
• Extensibility: The plugin system allows custom event handling, making the framework readily extensible.
• Dependency Injection: The frequent use of ServiceCollectionExtensions across modules indicates heavy dependency injection for managing services.
• Real-time Processing: The design emphasizes continuous monitoring (background service) and immediate event processing.
d. Relevant Technologies, Frameworks, or Libraries:
• .NET 6 (or higher) is the foundation for all projects.
• ASP.NET Core for the REST API.
• EF Core as the likely ORM for repository patterns used in various modules.
• Custom RCON client implemented in SquadNET.Core.
• Unit Testing Framework (e.g., xUnit or NUnit) used in SquadNET.Test.