This directory contains comprehensive coding rules and conventions for the DevMetrics Pro project.
.cursorrules(in project root) - Main rules file with project overview and quick reference
Each .mdc file contains in-depth rules for a specific area:
| File | Purpose | Key Topics |
|---|---|---|
| architecture.mdc | Clean Architecture principles | Layer responsibilities, dependency rules, file organization |
| dotnet-conventions.mdc | .NET & C# standards | C# 12 features, naming, async patterns, DI |
| blazor-rules.mdc | Blazor development | Components, lifecycle, SignalR, MudBlazor |
| database-rules.mdc | EF Core & PostgreSQL | Entities, migrations, queries, performance |
| testing-rules.mdc | Testing standards | xUnit, FluentAssertions, mocking, coverage |
The .cursorrules file is automatically loaded by Cursor AI. For detailed guidance on specific topics, refer to the appropriate .mdc file.
- Read
.cursorrulesfor project overview - Refer to specific
.mdcfiles when working in that area:- Adding a new entity? Read
architecture.mdcanddatabase-rules.mdc - Creating a Blazor component? Read
blazor-rules.mdc - Writing tests? Read
testing-rules.mdc
- Adding a new entity? Read
Core (Domain)
↑
Application (Business Logic)
↑
Infrastructure (Data & External Services)
↑
Web (UI & API)
Rule: Dependencies ONLY point upward (toward Core)
- Core has no dependencies on other layers
- Application depends only on Core
- Infrastructure implements interfaces from Application/Core
- Web orchestrates everything
- File-scoped namespaces:
namespace MyNamespace; - Nullable reference types:
<Nullable>enable</Nullable> - Async methods: Always include
CancellationToken - Private fields:
_camelCase - Public properties:
PascalCase
- Render mode:
@rendermode InteractiveServer - Component parameters:
[Parameter] public required Type Prop { get; set; } - Event callbacks:
[Parameter] public EventCallback OnClick { get; set; } - Lifecycle: Use
OnInitializedAsyncfor data loading
- Fluent API in separate configuration classes
- Always use async methods with
CancellationToken - Use
AsNoTracking()for read-only queries - Project to DTOs in queries with
Select()
- Test naming:
MethodName_Scenario_ExpectedBehavior - Use AAA pattern: Arrange-Act-Assert
- FluentAssertions for assertions
- 80% minimum code coverage
- Create entity in
Core/Entities/ - Create configuration in
Infrastructure/Data/Configurations/ - Create DTO in
Application/DTOs/ - Add to
ApplicationDbContext.cs - Create migration
- Write tests
- Create
.razorfile in appropriate folder - Add
@rendermode InteractiveServer - Define
[Parameter]properties - Implement lifecycle methods
- Create
.razor.cssfor component-specific styles - Write component tests
- Define interface in
Application/Interfaces/ - Create implementation in
Application/Services/ - Register in
Program.csDI container - Write unit tests with mocks
- Write integration tests
Is it a domain concept? → Core/
- Entity? →
Core/Entities/ - Enum? →
Core/Enums/ - Repository interface? →
Core/Interfaces/
Is it business logic? → Application/
- Service? →
Application/Services/ - DTO? →
Application/DTOs/ - Validator? →
Application/Validators/
Is it technical implementation? → Infrastructure/
- Database? →
Infrastructure/Data/ - Repository? →
Infrastructure/Repositories/ - External API? →
Infrastructure/Services/
Is it UI or API? → Web/
- Blazor component? →
Web/Components/ - API endpoint? →
Web/Controllers/ - SignalR? →
Web/Hubs/
-
❌ Referencing outer layers from inner layers
- Never
using Infrastructurein Core - Never
using Webin Application
- Never
-
❌ Using sync database calls
- Use
ToListAsync(), notToList() - Always pass
CancellationToken
- Use
-
❌ Exposing entities in APIs
- Use DTOs, not entities
- Map entities to DTOs in services
-
❌ Putting business logic in components/controllers
- Keep logic in Application services
- Components/controllers orchestrate only
-
❌ Not disposing resources
- Implement
IAsyncDisposablefor Blazor components - Dispose DbContext properly
- Implement
Before committing code:
- Follows Clean Architecture rules
- Uses async/await with CancellationToken
- DTOs used for API contracts
- Proper error handling
- Tests written (80% coverage)
- No linter errors
- Proper naming conventions
- XML documentation for public APIs
- For architecture questions: Read
architecture.mdc - For C# patterns: Read
dotnet-conventions.mdc - For Blazor help: Read
blazor-rules.mdc - For database queries: Read
database-rules.mdc - For testing guidance: Read
testing-rules.mdc
.ai/GETTING-STARTED.md- Quick start guide.ai/prd.md- Product requirements.ai/sprints/- Sprint plans and logs
Remember: These rules exist to maintain consistency, quality, and scalability. When in doubt, follow Clean Architecture principles and prioritize clarity over cleverness.