How itsarisid/slate works
Purpose and runtime entry points
Alphabet is a modular .NET school-ERP backend, currently centered on identity, authorization, staff operations, productivity, assets, communications, and scheduling. The primary API host is src/Gateway/Alphabet.AppWire/Program.cs; it exposes minimal API endpoints, Swagger, middleware, and module registrations. src/Gateway/Alphabet.ApiDocs/Program.cs is a separate API documentation portal with a Vite/React client at src/Gateway/Alphabet.ApiDocs/src/main.tsx.
Composition and request boundary
Alphabet.AppWire is the composition root: HTTP requests enter module endpoint mappers, pass global exception and request-logging middleware, then delegate to MediatR-based commands/queries. Core cross-cutting pipeline behaviors enforce validation, transactions, caching, logging, and performance measurement:
• src/Gateway/Alphabet.AppWire/Middleware/GlobalExceptionMiddleware.cs
• src/Core/Alphabet.Application/Common/Behaviors/ValidationBehavior.cs
• src/Core/Alphabet.Application/Common/Behaviors/TransactionBehavior.cs
Endpoints are intentionally thin; API models belong in each module’s Api folder, while feature behavior is organized as vertical application slices.
Shared domain and application kernel
The shared core supplies domain primitives (aggregate roots, value objects, domain events), repository/unit-of-work abstractions, result DTOs, mappings, and service contracts. This is the dependency boundary that modules consume rather than directly coupling to each other.
• src/Core/Alphabet.Domain/Common/AuditableEntity.cs
• src/Core/Alphabet.Domain/Interfaces/IRepository.cs
• src/Core/Alphabet.Application/Common/Interfaces/IModuleFacade.cs
Domain events support asynchronous-style business reactions such as registration, password reset, email, and notification events, while integrations are represented by application interfaces.
Persistence, caching, and operational infrastructure
EF Core persistence is centralized around AppDbContext, generic repositories, and a unit of work that owns SaveChanges/transaction completion. Database provider selection supports SQL Server, PostgreSQL, and in-memory operation. Redis is optional behind ICacheService; memory cache is the alternative. SQL Server and Redis can be launched through docker-compose.yml.
• src/Core/Alphabet.Infrastructure/Persistence/Context/AppDbContext.cs
• src/Core/Alphabet.Infrastructure/Persistence/Repositories/UnitOfWork.cs
• src/Core/Alphabet.Infrastructure/Caching/RedisCacheService.cs
Infrastructure also provides Serilog setup, health checks, current-user access, migration support, and an in-process background-job adapter.
Identity and authorization control plane
Identity uses ASP.NET Core Identity-oriented persistence, JWT/token services, refresh tokens, cookie writing, lockout, password recovery, and MFA. Privilege authorization extends role-based identity with direct user grants, policies, conditions, evaluations, audit logs, cache-backed lookup, and an ASP.NET authorization handler.
• src/Modules/IdentityModule/Api/IdentityModuleEndpoints.cs
• src/Modules/IdentityModule/Infrastructure/Identity/IdentitySetup.cs
• src/Modules/PrivilegeModule/Infrastructure/Security/PrivilegeAuthorizationHandler.cs
This is the main security boundary for all protected module endpoints.
Business modules and real-time collaboration
Bounded-context modules follow Api → Application → Domain → Infrastructure ownership. Major implemented domains are asset lifecycle/inventory/workflows, employee leave and approvals, collaborative productivity, outbound communication, products/orders, and privileges. Asset, leave, and productivity modules expose SignalR hubs for live client updates.
• src/Modules/AssetManagementModule/Api/AssetManagementModuleEndpoints.cs
• src/Modules/LeaveManagementModule/Api/LeaveManagementModuleEndpoints.cs
• src/Modules/ProductivityModule/Api/ProductivityModuleEndpoints.cs
Their application layers separate commands from queries; repositories and EF configurations remain module-owned where feature-specific.
Scheduling and external delivery
The scheduler persists job definitions/executions and uses a Hangfire-first scheduler implementation, with Quartz also present. It supports cron validation, retries, execution history, admin operations, and job handlers for HTTP calls, stored procedures, files, and code execution. Productivity, asset, and leave modules register background work such as reminders, reports, recurring tasks, and maintenance/accrual activities.
• src/Modules/SchedulerModule/Infrastructure/Scheduler/HangfireSchedulerService.cs
• src/Modules/SchedulerModule/Infrastructure/Scheduler/JobExecutor.cs
• src/Modules/CommunicationModule/Infrastructure/Services/CommunicationService.cs
Communication is an adapter boundary for email, SMS, push, in-app, and webhook delivery rather than a direct dependency from business modules to transport implementations.
Main entry points: ValidationBehavior.cs MediatR Application Pipeline · Program.cs AppWire API Host · IdentityModuleEndpoints.cs Identity Module · HangfireSchedulerService.cs Scheduler
Components 20
Gateway
- AppWire API Host · Composition root for endpoints, middleware, Swagger, and module registration.
src/Gateway/Alphabet.AppWire/Program.cs - Global Exception Middleware
src/Gateway/Alphabet.AppWire/Middleware/GlobalExceptionMiddleware.cs - API Documentation Portal · Separate API documentation portal.
src/Gateway/Alphabet.ApiDocs/Program.cs - Vite React Client
src/Gateway/Alphabet.ApiDocs/src/main.tsx
Shared Core
- MediatR Application Pipeline · Vertical slices with validation, transaction, caching, logging, and performance behaviors.
src/Core/Alphabet.Application/Common/Behaviors/ValidationBehavior.cs - Transaction Behavior
src/Core/Alphabet.Application/Common/Behaviors/TransactionBehavior.cs - Domain Kernel · Aggregate, value-object, domain-event, repository, and result contracts shared by modules.
src/Core/Alphabet.Domain/Common/AuditableEntity.cs - Module Facades · Shared contracts prevent direct module coupling.
src/Core/Alphabet.Application/Common/Interfaces/IModuleFacade.cs
Infrastructure
- AppDbContext · Central persistence context with selectable SQL Server, PostgreSQL, or in-memory providers.
src/Core/Alphabet.Infrastructure/Persistence/Context/AppDbContext.cs - Unit of Work · Owns SaveChanges and transaction completion.
src/Core/Alphabet.Infrastructure/Persistence/Repositories/UnitOfWork.cs - Cache Service · Redis-backed caching with memory-cache alternative.
src/Core/Alphabet.Infrastructure/Caching/RedisCacheService.cs
Business Modules
- Identity Module · JWT, refresh tokens, cookies, lockout, recovery, and MFA.
src/Modules/IdentityModule/Api/IdentityModuleEndpoints.cs - Identity Setup
src/Modules/IdentityModule/Infrastructure/Identity/IdentitySetup.cs - Privilege Authorization · Policies, grants, conditions, evaluations, audit logs, and protected-endpoint authorization.
src/Modules/PrivilegeModule/Infrastructure/Security/PrivilegeAuthorizationHandler.cs - Asset Management · Asset lifecycle, inventory, and workflow operations with live updates.
src/Modules/AssetManagementModule/Api/AssetManagementModuleEndpoints.cs - Leave Management · Employee leave and approval operations with live updates.
src/Modules/LeaveManagementModule/Api/LeaveManagementModuleEndpoints.cs - Productivity · Collaborative productivity operations with live updates.
src/Modules/ProductivityModule/Api/ProductivityModuleEndpoints.cs
Scheduling & Delivery
- Scheduler · Hangfire-first persisted scheduling with retries, history, and executable job handlers.
src/Modules/SchedulerModule/Infrastructure/Scheduler/HangfireSchedulerService.cs - Job Executor · Executes HTTP, stored-procedure, file, and code jobs.
src/Modules/SchedulerModule/Infrastructure/Scheduler/JobExecutor.cs - Communication Service · Adapter boundary for email, SMS, push, in-app, and webhook delivery.
src/Modules/CommunicationModule/Infrastructure/Services/CommunicationService.cs
Connections 26
- Vite React Client → API Documentation Portal: served by
- AppWire API Host → Global Exception Middleware: uses
- AppWire API Host → Identity Module: maps endpoints
- AppWire API Host → Asset Management: maps endpoints
- AppWire API Host → Leave Management: maps endpoints
- AppWire API Host → Productivity: maps endpoints
- Global Exception Middleware → MediatR Application Pipeline: forwards requests
- MediatR Application Pipeline → Transaction Behavior: includes
- MediatR Application Pipeline → Domain Kernel: uses contracts
- MediatR Application Pipeline → Unit of Work: persists through
- MediatR Application Pipeline → Cache Service: uses caching
- Unit of Work → AppDbContext: commits via
- Identity Module → Identity Setup: configured by
- Identity Module → AppDbContext: persists identity
- Privilege Authorization → Identity Module: extends identity
- Privilege Authorization → Cache Service: caches lookups
- AppWire API Host → Privilege Authorization: protects endpoints with
- Asset Management → MediatR Application Pipeline: commands and queries
- Leave Management → MediatR Application Pipeline: commands and queries
- Productivity → MediatR Application Pipeline: commands and queries
- Asset Management → Scheduler: registers maintenance work
- Leave Management → Scheduler: registers accrual work
- Productivity → Scheduler: registers reminders and reports
- Scheduler → Job Executor: dispatches
- Job Executor → Communication Service: delivers notifications
- Communication Service → Module Facades: exposed through