How iokode/opinionatedframework works
Based on our analysis of the file tree and README, OpinionatedFramework is a comprehensive .NET 8+ framework designed to streamline the development of the application (or domain) layer by providing pre-built contracts and their default implementations. The framework is modular by design and organized into several components, each handling a specific concern (such as commands, filesystem interactions, emailing, encryption, events, logging, persistence, and more). It also includes bootstrapping and source generation capabilities to enhance developer productivity.
Main Components
• Bootstrapping: Represents the initialization logic (e.g., container setup, dependency scanning) found in the “src/Bootstrapping” directory and “DefaultBootstrapping” project.
• Foundation Layer: This is the heart of the framework’s core functionalities and contracts. It contains sub-components such as Commands, Emailing, Events, FileSystem, Persistence, Security, Logging, Notifications, and more (found in “src/Foundation”).
• Contract Implementations: Every core interface (contract) has its default implementation spread across the “src/ContractImplementations.*” directories (e.g., CommandExecutor, Aes256GcmModeEncrypter, Hangfire, MailKit, MicrosoftLogging, NHibernate, etc.). These projects effectively “plug into” the foundation layer, providing the concrete behavior.
• Source Generators: Code generation tools (under “src/SourceGenerators.*”) that automatically generate code related to ensuring, facades, migrations, and SQL query objects. These reduce boilerplate and enforce common patterns.
• Testing Modules: Comprehensive tests are included to verify individual modules (with separate test projects such as “src/Tests.*”). While not part of runtime architecture, they provide insight into the project’s capabilities and expected usage.
• Infrastructure and Internals: Supporting modules (like “src/Internals” and “src/MSBuild”) and documentation (under “docs”) which assist in build configuration and setup.
Relationships and Interactions
• Source Generators as an auxiliary engine that helps compile or generate some of the required supporting code. Connect these to the Foundation and Contract Implementations where auto-generation aids in creating supporting code structures.
• “Tests” block interacting with each of the above components to validate correctness and adherence to architectural principles. These tests help ensure the reliability of each module and their integration.
Architectural Patterns and Design Principles
• Dependency inversion by noting that the Foundation defines interfaces (contracts) while implementations can be swapped as needed.
• Separation of concerns between the core application/domain logic (Foundation) and the infrastructural implementation (Contract Implementations).
• Use of middleware patterns within the Command implementation (as referenced in the Foundation Commands), as well as the possible use of the Unit of Work in persistence.
• The bootstrapping phase is critical: mention how the framework uses its own service container (or static locator) to tie the components together without being coupled to external dependency injection frameworks.
Technology and Framework Specifics
• Important libraries (e.g., MailKit for emailing, NHibernate for persistence) associated with each module.