A modern approach to scalable and maintainable monoliths.
MFCA is a pragmatic backend architecture that combines Domain Driven Design (DDD) principles, Clean Architecture, REPR Pattern, Vertical Slice Architecture and N Layer Architecture.
csharp_mfca.API/
โโโ Configurations/
โโโ Constants/
โโโ Entities/
โโโ Exceptions/
โโโ Extensions/
โโโ Features/
โ โโโ Core/
โ โโโ Users/
โ โ โโโ Core/
โ โ โโโ CreateUser/
โโโ Models/
โโโ Middlewares/
โโโ Persistence/
โ โโโ Base/
โ โโโ Wrapper/
โโโ Resources/
โโโ Services/
โโโ Utils/
โโโ Program.cs / Dockerfile
| Layer | Responsibility |
|---|---|
| Configurations | Manages application settings efficiently using the Options Pattern, ensuring type safety and reducing the risk of spelling errors or misconfigurations across the codebase. |
| Constants | This is where the application constants and enum exist. |
| Entities | The main entities of the application if we are using one DB instance. |
| Exceptions | This is where we can implement custom exceptions and global handlers. |
| Extensions | Custom implementation of extensions including Mapper, Extension and DI extensions. |
| Features | Encapsulated domain features, Request DTOs, Response DTOs validators, and service calls. |
| Models | Domain entities used across features including aggregates. |
| Middlewares | Custom middlewares for interception and custom logic. |
| Persistence | Generic Repository Pattern, Unit Of Work Pattern lie in this layer. Also, ORM integration can be found there. |
| Resources | We can add localization here. |
| Services | Shared services like Fluent Email, JWT, AES, S3, SES, SNS, etc. |
| Utils | Mainly BaseResponseModel for consistent API response. |
| Traditional CQRS | MFCA |
|---|---|
| Two separate commands and queries | Request/Response DTOs under the slice and aggregates under the Core if needed. |
| Dual databases or projection layers | Single DB with layered access |
| Heavy setup and boilerplate | Minimal overhead, fast development |