120 lines
4.8 KiB
Markdown
120 lines
4.8 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
|
|
|
|
```mermaid
|
|
graph TD
|
|
Root["SlpModularCms/"]
|
|
Src["src/"]
|
|
Api["SlpModularCms.Api\n(API host)"]
|
|
ApiExt["Extensions/\nServiceCollectionExtensions.cs"]
|
|
ApiInfra["Infrastructure/\nGlobal exception handler"]
|
|
ApiProg["Program.cs\nApp startup + module loading"]
|
|
|
|
Core["SlpModularCms.Core\n(Shared core)"]
|
|
CoreAvail["Availability/\nAvailabilityOptions.cs\nAvailabilityStatus.cs"]
|
|
CoreData["Data/\nApplicationDbContext.cs"]
|
|
CoreIdentity["Identity/\nEntities, Models, Services\nAuthorization/"]
|
|
CoreMigrations["Migrations/\nEF Core migrations"]
|
|
CoreModules["Modules/\nIModule.cs, ModuleInfo.cs"]
|
|
|
|
ModIdentity["SlpModularCms.Modules.Identity\n(Identity module)"]
|
|
ModIdentityCtrl["Controllers/\nAuthController\nSetupController\nUsersController"]
|
|
|
|
ModAvail["SlpModularCms.Modules.Availability\n(Availability module)"]
|
|
ModAvailCtrl["Controllers/\nAvailabilityController"]
|
|
ModAvailSvc["Services/\nPersistentAvailabilityService"]
|
|
|
|
Tests1["SlpModularCms.Core.Tests"]
|
|
Tests2["SlpModularCms.Modules.Availability.Tests"]
|
|
Docs["aidlc-docs/\nAI-DLC workflow documentation"]
|
|
|
|
Root --> Src
|
|
Root --> Docs
|
|
Src --> Api
|
|
Src --> Core
|
|
Src --> ModIdentity
|
|
Src --> ModAvail
|
|
Src --> Tests1
|
|
Src --> Tests2
|
|
Api --> ApiExt
|
|
Api --> ApiInfra
|
|
Api --> ApiProg
|
|
Core --> CoreAvail
|
|
Core --> CoreData
|
|
Core --> CoreIdentity
|
|
Core --> CoreMigrations
|
|
Core --> CoreModules
|
|
ModIdentity --> ModIdentityCtrl
|
|
ModAvail --> ModAvailCtrl
|
|
ModAvail --> ModAvailSvc
|
|
|
|
style Api fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style ApiExt fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style ApiInfra fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style ApiProg fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style Core fill:#FFC107,stroke:#F57F17,color:#000
|
|
style CoreAvail fill:#FFC107,stroke:#F57F17,color:#000
|
|
style CoreData fill:#FFC107,stroke:#F57F17,color:#000
|
|
style CoreIdentity fill:#FFC107,stroke:#F57F17,color:#000
|
|
style CoreMigrations fill:#FFC107,stroke:#F57F17,color:#000
|
|
style CoreModules fill:#FFC107,stroke:#F57F17,color:#000
|
|
style ModIdentity fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style ModIdentityCtrl fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style ModAvail fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style ModAvailCtrl fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style ModAvailSvc fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style Tests1 fill:#9E9E9E,stroke:#424242,color:#fff
|
|
style Tests2 fill:#9E9E9E,stroke:#424242,color:#fff
|
|
style Docs fill:#CE93D8,stroke:#6A1B9A,color:#000
|
|
```
|
|
|
|
## 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
|