This document describes the AI agents and automation used in the ModularGuard project.
ModularGuard is a CLI tool that validates project references in a modular monolith architecture. It ensures that C# projects follow the architectural rules defined for the modular monolith structure.
This project adheres to the following development standards:
- C#/.NET Best Practices: Follow established C# and .NET conventions, including naming conventions, code organization, and design patterns
- Code Readability: All code should be human-readable and easy to understand, with clear intent and minimal complexity
- Maintainability: Write code that is easy to modify, extend, and debug
- Clean Code: Use meaningful names, small focused methods, and clear abstractions
Validates that project references between modules comply with the modular monolith architecture rules.
The agent enforces the following reference constraints based on project type:
- Allowed references:
Shared.Core - Prohibited: References to Infrastructure, App, or Endpoints projects
- Allowed references:
Shared.Infrastructure- Same module's
*.Coreproject
- Prohibited: References to App or Endpoints projects
- Allowed references:
Shared.App.[Admin|Private|Public](matching the app type)- Same module's
*.Coreproject - Same module's
*.Infrastructureproject - Other modules'
*.Shared.Eventsprojects - Other modules'
*.Shared.Messagesprojects
- Prohibited: References to Endpoints projects
- Allowed references:
- Same module's
*.[Admin|Private|Public].Appproject (matching the endpoint type)
- Same module's
- Prohibited: Direct references to Core or Infrastructure projects
- Allowed references:
Shared.Events.Abstractions
- Allowed references: Message abstraction projects
The CLI is built using:
- Spectre.Console.Cli: Command-line interface framework for parsing commands and arguments
- Microsoft.Build.Evaluation.Project: MSBuild API for reading and analyzing
.csprojfiles
dotnet run -- check <path-to-solution-directory>The agent scans all .csproj files in the directory structure using Microsoft.Build.Evaluation.Project to parse
project references, then validates them according to the rules above.
The agent reports violations with:
- Source project path
- Invalid reference
- Reason for violation
- Suggested corrections
- Separation of Concerns: Core domain logic is isolated from infrastructure and application layers
- Dependency Direction: Dependencies flow inward (Endpoints → App → Infrastructure → Core)
- Module Independence: Modules can only communicate through defined contracts (Events, Messages)
- Shared Code Management: Common code is centralized in the Shared module with specific usage patterns
Potential agents for future implementation:
- Circular Dependency Detector: Identifies circular references between modules
- Dependency Graph Visualizer: Generates visual representations of module dependencies
- Migration Assistant: Helps refactor legacy code to comply with modular monolith rules
- Test Coverage Validator: Ensures all modules meet unit testing requirements