Asp.Net Core app with Dynamic Modular Monolith Architecture - Part 1



Before the introduction, let me share why I am writing on this topic, although it happens every time, but it's the first time I am answering this why in any blog post. Every time I think about any problem that can be solved with software, as a software engineer, that ends up being writing that master piece by myself. Anyway, back to the topic, while thinking about a software, even before searching online, the next thought that hits my mind is, why not let's create by myself, this way I can create exactally as per my need, will have full control, and I can do another experiment with its architecture. 


Just for the reference, this website usmancode.com is also developed by me from scratch, and it is still getting mature. On weekends, I take care of any bugs or new features that can be added. I shared this because maybe that can keep you motivated and curious about this blog post series. If you still don't get the idea, let me tell you, this is going to be a detailed and apprehensive post series. Till the date, I have 13+ years of industry experience, believe me as you get more experienced, you realize, its the discussions and communication against a problem which matters the most, provides a source of learning and thinking not only the code, I mean code is also important when it comes to implementing the solution, I believe you will realize that soon. Again time to go back to the main agenda, as till now I had decided to develop an ASP.NET Core web app using .NET 9, next thing was what would be the architecture that supports me to develop any feature in isolation as a single app without the need to publish the whole application every time. Now take a short break and read the post title, i.e., Dynamic Modular Monolith.


Next, let's start a discussion around the project components and the abstract structure. In my mind, it consists of three components, the main one is Modules, where each feature will have its separate directory in isolation. All the modules will share some common structures, which I will put in the second component, which I will call Common. Next, who will take the responsibility to load all the modules with their dependencies and configurations, will be the WebHostApp, the third component. Now let's try to visualize this in the form of a diagram.



Let's start with the WebHostApp component, which references Common and discovers and loads modules from Modules. The second one is Common, which shares infrastructure code, contains interfaces, base DTOs, helpers, and plugin loading classes. At last, the main one is Modules, which are compiled into their own DLL. Each module follows a vertical slice structure, loaded at runtime by WebHostApp, which doesn't have any references to any module. That was all for this introductory post about my Dynamic Modular Monolith Architecture-based ASP.NET Core app.