How ixi-enki/se-template works
1. Repository shape
- This is not a single app, but a solution template platform.
- The repo contains a reusable core architecture (SETemplate.*) plus a separate tooling layer (TemplateTools.*) that can clone, synchronize, and generate code for derived domain solutions.
2. Core domain boundary: SETemplate.Common
- Common holds the shared contracts, base models, enums, exceptions, validation helpers, and utility extensions.
- It is intentionally domain-agnostic and forms the lowest architectural layer reused by all other SETemplate projects.
3. Business layer: SETemplate.Logic
- Logic is the central runtime library: entities, data context, business rules, authorization, and account management live here.
- It exposes domain abstractions through contracts and partial classes, and it is the layer the rest of the system builds on.
4. Data access pattern inside Logic
- The data layer is organized around ProjectDbContext, EntitySet, and ViewSet abstractions.
- Entities and views are discovered via reflection by the generator, then wired into context and service contracts.
- This is the main persistence boundary, with EF Core and database-provider selection controlled by compile-time defines.
5. Authentication and authorization flow
- Authentication is an explicit subsystem centered on accounts, roles, password rules, sessions, and session tokens.
- If ACCOUNT_ON is enabled, access to context and sets is guarded by custom security attributes and security partials.
- The flow is: login with email/password → receive LoginSession with SessionToken → pass token into context/service operations.
6. REST boundary: SETemplate.WebApi
- WebApi is the network-facing host that exposes the logic layer as REST endpoints.
- It contains generic controllers for entities and views, account endpoints, middleware for exception handling, and DTO models.
- This is the main boundary for external clients, and it translates HTTP requests into Logic operations.
7. Client-side Angular host: SETemplate.AngularApp
- The Angular project is a frontend host built with Angular 19, Bootstrap 5.3, and ngx-translate.
- Its structure shows a clear split between pages, generic base components, services/interceptors/guards, and models.
- It talks to WebApi via generated HTTP services and uses interceptors for token/error handling.
8. Desktop/MVVM host: SETemplate.MVVMApp
- MVVMApp is an Avalonia-based desktop UI template using the MVVM pattern.
- It contains view models, views, dialogs, and template-specific item/list abstractions.
- Like the Angular app, it is a UI shell over the same shared domain/model concepts.
9. Initial setup and database bootstrap: SETemplate.ConApp
- ConApp is the initialization console app used to create or synchronize the database, seed accounts, and import data.
- It is mainly a bootstrap and maintenance host rather than a user-facing runtime.
- The README indicates it is typically used once during project setup or for admin maintenance.
10. Code generation runtime: SETemplate.CodeGenApp
- This is a smaller console entry point for code generation only.
- It exists to generate backend/frontend artifacts from the compiled logic assembly without the broader template-management features.
11. Template management layer: TemplateTools.ConApp + TemplateTools.Logic
- These projects are the template engineering engine of the repo.
- They handle copying a template solution into a domain solution, preprocessing defines, generating code, synchronizing template/code-copy states, cleaning build artifacts, and extra tooling.
- The tooling works across the solution structure, not inside the runtime app itself.
12. Generated-code and synchronization model
- The repo uses a marker-based source control strategy: @BaseCode, @CodeCopy, @GeneratedCode, @CustomCode, @AiCode.
- Generators can overwrite generated areas, while custom partials preserve manual code.
- This is a key architectural boundary: generated infrastructure is separable from handwritten business/UI extensions.
13. Cross-project data flow
- Typical flow is: domain entities in Logic → reflection-based generation → contracts/models/controllers/services/UI artifacts.
- Runtime flow is: UI or API client → WebApi or generated HTTP services → Logic → Common abstractions + EF Core persistence.
- Tooling flow is separate: template solution → TemplateTools → copied/synchronized domain solution.
14. Compile-time feature switching
- Several architecture decisions are controlled by preprocessor defines rather than runtime config: authentication, key type selection, database provider, rowversion support, generated-code mode, and developer-only operations.
- This means the solution can produce different runtime variants from the same source tree, which is important when drawing the architecture as a configurable template rather than a fixed app.
15. External/runtime technologies that materially matter
- Backend/runtime: .NET 8, ASP.NET Core, EF Core, with support for SQLite/PostgreSQL/SQL Server.
- Frontend/runtime: Angular 19, TypeScript, Bootstrap.
- Desktop runtime: Avalonia.
- Tooling: reflection-based code generation, console hosts, and an MCP server (SETemplate.McpSrv) for AI assistant integration and template guidance.
Main entry points: SETemplate.Logic SETemplate.Logic · SETemplate.WebApi SETemplate.WebApi · Generation Generators · ProjectDbContext.cs ProjectDbContext
Components 18
Core template
Shared contracts and reusable domain primitives.
- SETemplate.Common · Domain-agnostic contracts, models, enums, validations, and utilities reused across the solution.
SETemplate.Common
Runtime layers
Backend business, persistence, API, and client hosts.
- SETemplate.Logic · Central business layer with entities, context, security, and account management.
SETemplate.Logic - ProjectDbContext · Main data context that wires entities, views, and security-aware access.
SETemplate.Logic/DataContext/ProjectDbContext.cs - EntitySet · Generic entity collection abstraction with internal and security variants.
SETemplate.Logic/DataContext/EntitySet.cs - ViewSet · Generic view/query abstraction for projecting data through the logic layer.
SETemplate.Logic/DataContext/ViewSet.cs - Account access · Accounts, roles, sessions, password rules, and authorization helpers.
SETemplate.Logic/Modules/Account/AccountManager.cs - SETemplate.WebApi · HTTP boundary exposing logic operations through controllers, middleware, and DTOs.
SETemplate.WebApi - Entity API · Generic REST controllers for entity CRUD and security-gated operations.
SETemplate.WebApi/Controllers/GenericEntityController.cs - View API · Generic REST controllers for read-only view access.
SETemplate.WebApi/Controllers/GenericViewController.cs - Accounts API · Login/session endpoints and account-facing HTTP operations.
SETemplate.WebApi/Controllers/AccountsController.cs - SETemplate.AngularApp · Angular frontend shell with pages, base components, services, guards, and interceptors.
SETemplate.AngularApp - SETemplate.ConApp · Initialization console for database setup, seeding, and maintenance tasks.
SETemplate.ConApp - SETemplate.CodeGenApp · Console entry point focused on code generation from the compiled logic assembly.
SETemplate.CodeGenApp
Tooling layer
Template management, code generation, and synchronization.
- TemplateTools.Logic · Core tooling logic for copying, preprocessing, generating, and synchronizing template solutions.
TemplateTools.Logic - TemplateTools.ConApp · Console host that orchestrates template management commands and automation flows.
TemplateTools.ConApp - Generators · Backend/frontend generators for common, logic, Web API, Angular, MVVM, and diagrams.
TemplateTools.Logic/Generation
Desktop/AI
Avalonia shell and MCP service integration.
- SETemplate.MVVMApp · Avalonia MVVM desktop template with views, view models, and dialogs.
SETemplate.MVVMApp - SETemplate.McpSrv · MCP server for AI assistant integration and template guidance utilities.
SETemplate.McpSrv
Connections 24
- SETemplate.Common → SETemplate.Logic: contracts/models · Logic builds on common abstractions and reusable base models.
- SETemplate.Logic → ProjectDbContext: defines · Business layer centers on the main persistence context.
- SETemplate.Logic → EntitySet: exposes · Entities are accessed through generic entity set abstractions.
- SETemplate.Logic → ViewSet: exposes · Read models are accessed through generic view set abstractions.
- SETemplate.Logic → Account access: auth · Account management and authorization live inside Logic.
- ProjectDbContext → EntitySet: wires · Context composes entity sets for persistence operations.
- ProjectDbContext → ViewSet: wires · Context composes view sets for query operations.
- Account access → ProjectDbContext: guards · Security partials and session tokens gate access to context and sets.
- SETemplate.WebApi → SETemplate.Logic: calls · REST controllers translate HTTP requests into logic operations.
- SETemplate.WebApi → Entity API: contains · Generic entity controllers form the CRUD API surface.
- SETemplate.WebApi → View API: contains · Generic view controllers form the query API surface.
- SETemplate.WebApi → Accounts API: contains · Account endpoints handle logon and session flows.
- SETemplate.AngularApp → SETemplate.WebApi: consumes · Frontend talks to the REST host through generated HTTP services.
- SETemplate.MVVMApp → SETemplate.Logic: consumes · Desktop UI binds to the shared domain and model concepts.
- SETemplate.ConApp → SETemplate.Logic: boots · Initialization console uses Logic for setup, seeding, and synchronization.
- SETemplate.CodeGenApp → SETemplate.Logic: inspects · Code generation entry point reads compiled logic metadata.
- TemplateTools.ConApp → TemplateTools.Logic: hosts · Console host orchestrates the template tooling engine.
- TemplateTools.Logic → Generators: drives · Tooling logic coordinates generators, copy/sync, and preprocessing.
- Generators → SETemplate.Logic: emits · Generators produce logic-side artifacts from discovered entities and views.
- Generators → SETemplate.WebApi: emits · Generators produce controllers, DTOs, and API glue.
- Generators → SETemplate.AngularApp: emits · Generators produce frontend models and service scaffolding.
- Generators → SETemplate.MVVMApp: emits · Generators produce desktop models and MVVM scaffolding.
- TemplateTools.Logic → TemplateTools.ConApp: runs under · Template management workflows are executed through the console host.
- SETemplate.McpSrv → TemplateTools.Logic: integrates · AI-facing server hooks into tooling and guidance workflows.