109 lines
5.1 KiB
Markdown
109 lines
5.1 KiB
Markdown
# Code Structure
|
|
|
|
## Build System
|
|
- **Type**: .NET SDK (MSBuild / dotnet CLI)
|
|
- **Configuration**: `SlpModularCms.sln` — solution file referencing all projects
|
|
- **Target Framework**: `net10.0`
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
SlpModularCms/
|
|
+-- src/
|
|
| +-- SlpModularCms.Api/ # API host
|
|
| | +-- Extensions/
|
|
| | | +-- ServiceCollectionExtensions.cs # DI setup (JWT, Identity, EF, Auth)
|
|
| | +-- Infrastructure/ # Global exception handler
|
|
| | +-- Properties/launchSettings.json
|
|
| | +-- Program.cs # App startup and module loading
|
|
| | +-- appsettings.json
|
|
| | +-- appsettings.local.json # Local dev overrides
|
|
| |
|
|
| +-- SlpModularCms.Core/ # Shared core
|
|
| | +-- Availability/
|
|
| | | +-- AvailabilityOptions.cs # Circuit breaker config
|
|
| | | +-- AvailabilityStatus.cs # Enum: Available, Maintenance, Unavailable
|
|
| | +-- Data/
|
|
| | | +-- ApplicationDbContext.cs # EF Core DbContext
|
|
| | +-- Exceptions/ # Custom exception types
|
|
| | +-- Identity/
|
|
| | | +-- Authorization/ # Policy handlers
|
|
| | | +-- Entities/
|
|
| | | | +-- ApplicationUser.cs # IdentityUser<Guid> + IsActive + CreatedAt
|
|
| | | | +-- ApplicationRole.cs # IdentityRole<Guid>
|
|
| | | | +-- RefreshToken.cs # Refresh token entity
|
|
| | | | +-- Invitation.cs # Invite entity with expiry
|
|
| | | | +-- GlobalAvailabilityState.cs # Persisted system status
|
|
| | | +-- Models/ # DTOs/request-response models
|
|
| | | +-- Services/
|
|
| | | +-- AuthService.cs # JWT generation + token validation
|
|
| | | +-- InvitationService.cs # Invite creation + completion
|
|
| | | +-- SetupService.cs # Initial owner creation
|
|
| | +-- Migrations/ # EF Core migrations
|
|
| | +-- Modules/
|
|
| | +-- IModule.cs # Module interface (Name, Version, RegisterServices, UseModule)
|
|
| | +-- ModuleInfo.cs # Module metadata record
|
|
| |
|
|
| +-- SlpModularCms.Modules.Identity/ # Identity feature module
|
|
| | +-- Controllers/
|
|
| | +-- AuthController.cs # /auth/* endpoints
|
|
| | +-- SetupController.cs # /setup/* endpoints
|
|
| | +-- UsersController.cs # /users/* endpoints
|
|
| |
|
|
| +-- SlpModularCms.Modules.Availability/ # Availability feature module
|
|
| | +-- Controllers/
|
|
| | | +-- AvailabilityController.cs # /availability/* endpoints
|
|
| | +-- Middleware/ # Availability check middleware
|
|
| | +-- Services/
|
|
| | +-- PersistentAvailabilityService.cs # Reads/writes status to DB + cache
|
|
| |
|
|
| +-- SlpModularCms.Core.Tests/ # Core unit tests
|
|
| +-- SlpModularCms.Modules.Availability.Tests/ # Availability unit tests
|
|
|
|
|
+-- aidlc-docs/ # AI-DLC workflow documentation
|
|
```
|
|
|
|
## Key Classes/Modules
|
|
|
|
### Core Domain Entities
|
|
- `ApplicationUser` — extends `IdentityUser<Guid>` with `IsActive`, `CreatedAt`, `Naam`
|
|
- `ApplicationRole` — extends `IdentityRole<Guid>`
|
|
- `RefreshToken` — linked to user; has `Token`, `ExpiryDate`, `IsRevoked`, `IsActive`
|
|
- `Invitation` — linked to user (invitee); has `Token`, `ExpiryDate`, `IsUsed`, `Role`
|
|
- `GlobalAvailabilityState` — singleton-ish entity storing `Status`, `Message`, `LastUpdatedAt`, `UpdatedBy`
|
|
|
|
### Core Services
|
|
- `IAuthService` / `AuthService` — `AuthenticateAsync`, `RefreshTokenAsync`, `RevokeTokenAsync`
|
|
- `IInvitationService` / `InvitationService` — `CreateInvitationAsync`, `CompleteInvitationAsync`, `ValidateInvitationAsync`
|
|
- `ISetupService` / `SetupService` — `IsSystemInitializedAsync`, `CreateInitialOwnerAsync`
|
|
- `IAvailabilityService` / `PersistentAvailabilityService` — `IsAvailableAsync`, `UpdateStatusAsync`
|
|
|
|
### Module System
|
|
- `IModule` — interface: `RegisterServices(IServiceCollection)`, `UseModule(IApplicationBuilder)`
|
|
- Modules discovered at startup and invoked in sequence
|
|
|
|
## Design Patterns
|
|
### Module Pattern
|
|
- **Location**: `SlpModularCms.Core/Modules/`, `SlpModularCms.Api/Program.cs`
|
|
- **Purpose**: Allows features to be developed, tested, and deployed independently
|
|
- **Implementation**: Each module class implements `IModule` and is registered in the API host
|
|
|
|
### Repository Pattern via EF Core
|
|
- **Location**: `ApplicationDbContext` used directly in services
|
|
- **Purpose**: Centralized persistence with Entity Framework
|
|
|
|
### JWT with Refresh Token Rotation
|
|
- **Location**: `AuthService.cs`, `AuthController.cs`
|
|
- **Purpose**: Stateless auth with token refresh capability
|
|
|
|
## Critical Dependencies
|
|
### ASP.NET Core Identity
|
|
- **Version**: .NET 10 built-in
|
|
- **Usage**: User/Role management, password hashing
|
|
- **Purpose**: Provides authentication primitives
|
|
|
|
### Entity Framework Core
|
|
- **Version**: .NET 10 built-in
|
|
- **Usage**: Data persistence with SQL Server provider
|
|
- **Purpose**: ORM for all domain entities
|