121 lines
4.8 KiB
Markdown
121 lines
4.8 KiB
Markdown
# System Architecture
|
|
|
|
## System Overview
|
|
|
|
SlpModularCms is a modular, ASP.NET Core-based CMS platform. The backend is structured as a monolith-with-modules: a single API host (`SlpModularCms.Api`) that dynamically loads feature modules at startup. Each module is self-contained and registers its own services and HTTP middleware. Persistence is handled via Entity Framework Core with SQL Server. Authentication uses JWT Bearer tokens with refresh token rotation.
|
|
|
|
The frontend is a React SPA (to be built) that communicates with the API via REST/JSON. The example app (from ZIP) provides the design foundation: Vite + React Router v7 + shadcn/ui + Tailwind CSS v4 with primary color `#ac0000`.
|
|
|
|
## Architecture Diagram
|
|
|
|
```mermaid
|
|
graph TD
|
|
subgraph ClientLayer["Client Layer"]
|
|
Frontend["React SPA\nVite + TanStack Router + shadcn/ui\nTailwind CSS v4 #ac0000"]
|
|
end
|
|
|
|
subgraph ApiLayer["API Layer"]
|
|
Api["SlpModularCms.Api\nASP.NET Core\nJWT Bearer, CORS, Swagger"]
|
|
Identity["Identity Module\nAuthController\nSetupController\nUsersController"]
|
|
Avail["Availability Module\nAvailabilityController\nPersistentService + CircuitBreaker"]
|
|
end
|
|
|
|
subgraph CoreLayer["Core Layer"]
|
|
Core["SlpModularCms.Core\nApplicationDbContext\nDomain Entities\nIdentity Services\nIModule interface"]
|
|
end
|
|
|
|
subgraph DataLayer["Data Layer"]
|
|
DB[("SQL Server\nIdentity tables\nRefreshTokens\nInvitations\nGlobalAvailabilityState")]
|
|
end
|
|
|
|
Frontend -->|HTTP REST / JSON| Api
|
|
Api --> Identity
|
|
Api --> Avail
|
|
Identity --> Core
|
|
Avail --> Core
|
|
Core --> DB
|
|
|
|
style Frontend fill:#2196F3,stroke:#0D47A1,color:#fff
|
|
style Api fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style Identity fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style Avail fill:#4CAF50,stroke:#2E7D32,color:#fff
|
|
style Core fill:#FFC107,stroke:#F57F17,color:#000
|
|
style DB fill:#FF5722,stroke:#BF360C,color:#fff
|
|
```
|
|
|
|
## Component Descriptions
|
|
|
|
### SlpModularCms.Api
|
|
- **Purpose**: Web API host and application entry point
|
|
- **Responsibilities**: Bootstrap, module loading, middleware pipeline, CORS, Swagger
|
|
- **Dependencies**: SlpModularCms.Core, SlpModularCms.Modules.Identity, SlpModularCms.Modules.Availability
|
|
- **Type**: Application
|
|
|
|
### SlpModularCms.Core
|
|
- **Purpose**: Shared domain layer
|
|
- **Responsibilities**: Domain entities, EF Core DbContext, authentication services, module interface
|
|
- **Dependencies**: EF Core, ASP.NET Identity, SQL Server provider
|
|
- **Type**: Shared Library
|
|
|
|
### SlpModularCms.Modules.Identity
|
|
- **Purpose**: Identity and user management module
|
|
- **Responsibilities**: HTTP endpoints for auth, setup, and user invitation flows
|
|
- **Dependencies**: SlpModularCms.Core
|
|
- **Type**: Application Module
|
|
|
|
### SlpModularCms.Modules.Availability
|
|
- **Purpose**: System availability tracking module
|
|
- **Responsibilities**: Exposes system status, allows owners to update it, caches with circuit breaker
|
|
- **Dependencies**: SlpModularCms.Core
|
|
- **Type**: Application Module
|
|
|
|
### SlpModularCms.Frontend (To Be Built)
|
|
- **Purpose**: Admin SPA for CMS management
|
|
- **Responsibilities**: Login, dashboard, user management, CMS content management, availability status display
|
|
- **Dependencies**: SlpModularCms.Api (REST)
|
|
- **Type**: Frontend Application
|
|
|
|
## Data Flow
|
|
|
|
```mermaid
|
|
sequenceDiagram
|
|
participant Browser
|
|
participant AuthController
|
|
participant AuthService
|
|
participant DB
|
|
|
|
Note over Browser,DB: Login Flow
|
|
Browser->>AuthController: POST /auth/login
|
|
AuthController->>AuthService: AuthenticateAsync()
|
|
AuthService->>DB: Validate credentials
|
|
DB-->>AuthService: User found
|
|
AuthService-->>AuthController: access + refresh tokens
|
|
AuthController-->>Browser: 200 OK with tokens
|
|
|
|
Note over Browser,DB: Invite Flow
|
|
Browser->>AuthController: POST /users/invite
|
|
AuthController->>AuthService: CreateInvitationAsync()
|
|
AuthService->>DB: Store Invitation entity
|
|
DB-->>AuthService: Stored
|
|
AuthService-->>AuthController: invite token
|
|
AuthController-->>Browser: 200 OK with invite link
|
|
|
|
Note over Browser,DB: New User Setup
|
|
Browser->>AuthController: POST /users/complete-setup
|
|
AuthController->>AuthService: CompleteInvitationAsync()
|
|
AuthService->>DB: Set password, activate account
|
|
DB-->>AuthService: Updated
|
|
AuthService-->>AuthController: success
|
|
AuthController-->>Browser: 200 OK
|
|
```
|
|
|
|
## Integration Points
|
|
- **External APIs**: None currently
|
|
- **Databases**: SQL Server (via EF Core)
|
|
- **Third-party Services**: None currently
|
|
|
|
## Infrastructure Components
|
|
- **Deployment Model**: Single API process + React SPA (separate deploy or static files)
|
|
- **Authentication**: JWT Bearer tokens (HS256 or RS256 based on JwtSettings config)
|
|
- **Database Migrations**: EF Core Code-First migrations in SlpModularCms.Core/Migrations/
|