Skip to content

ilroberts/DotNetModularMonolith

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Modular Monolith E-Commerce Application

Overview

ECommerceApp is a modular monolith built with .NET 8 that demonstrates a scalable, maintainable e-commerce system using a modular architecture. The solution is organized into several projects and modules, each with a clear responsibility.

Key Features

  • Modular Monolith Architecture: Orders, Products, Customers, and Business Events modules, each with their own domain, endpoints, persistence, and services.
  • Admin UI: ASP.NET Core Razor Pages frontend for administration, with integration and unit tests.
  • Integration & Unit Testing: Comprehensive test projects for API modules and Admin UI, using in-memory databases and HTTP stubbing.
  • Dependency Injection: All modules and services use DI for decoupled communication.
  • Shared Contracts: DTOs and interfaces in a separate project to avoid circular dependencies.
  • Logging & Observability: Integrated logging and OpenTelemetry support.
  • Swagger UI: API documentation and testing via Swagger.
  • Database Migrations: Dedicated migrator project for applying EF Core migrations.
  • Docker & Kubernetes: Dockerfiles and k8s manifests for containerized deployment.

Table of Contents

Project Structure

ModularMonolith/
├── ECommerceApp/                       # Main API host (wires up modules)
├── ECommerce.Modules.Orders/           # Orders module (domain, endpoints, persistence, services)
├── ECommerce.Modules.Products/         # Products module (domain, endpoints, persistence, services)
├── ECommerce.Modules.Customers/        # Customers module (domain, endpoints, persistence, services)
├── ECommerce.BusinessEvents/           # Business events module
├── ECommerce.Contracts/                # Shared DTOs and interfaces
├── ECommerce.Common/                   # Shared result types, utilities
├── ECommerce.AdminUI/                  # ASP.NET Core Razor Pages admin UI
├── ECommerce.AdminUI.IntegrationTests/ # Integration tests for Admin UI (HTTP stubbing)
├── ECommerce.AdminUI.Tests/            # Unit tests for Admin UI
├── ECommerceApp.IntegrationTests/      # Integration tests for API modules (in-memory DB)
├── ECommerce.Modules.Orders.Tests/     # Unit tests for Orders module
├── ECommerce.BusinessEvents.Tests/     # Unit tests for Business Events module
├── ECommerce.DatabaseMigrator/         # Standalone EF Core migration runner
├── docs/                               # Architecture decision records, Swagger, etc.
├── README.md
└── ...

Requirements

  • .NET 8 SDK
  • Docker (for running containers and database)
  • (Optional) Kubernetes (for k8s manifests)

Setup and Installation

  1. Clone the repository
  2. Restore dependencies
    dotnet restore
  3. Apply database migrations
    dotnet run --project ECommerce.DatabaseMigrator
  4. Run the application
    dotnet run --project ECommerceApp
  5. Run the Admin UI
    dotnet run --project ECommerce.AdminUI

Usage

  • API Endpoints: Available at /orders, /products, /customers, /businessevents (see Swagger UI for details)
  • Admin UI: Navigate to the running Admin UI app for product, order, and customer management
  • Swagger UI: Visit /swagger on the API host

Testing

  • Integration Tests:
    • ECommerceApp.IntegrationTests: In-memory DB integration tests for API modules
    • ECommerce.AdminUI.IntegrationTests: HTTP-stubbed integration tests for Admin UI services
  • Unit Tests:
    • ECommerce.AdminUI.Tests, ECommerce.Modules.Orders.Tests, ECommerce.BusinessEvents.Tests
  • Run all tests:
    dotnet test

Logging & Observability

  • Logging via ILogger throughout all modules
  • OpenTelemetry support in Admin UI
  • API and Admin UI log to console by default

Kubernetes Manifests & Repository Separation

This repository contains the application code and development tooling (including the Tiltfile for local Kubernetes development). Production and staging Kubernetes manifests are maintained in a separate infrastructure repository:

Local Development (Tilt)

  • The Tiltfile in this repository is used for local development and testing.
  • It references Kubernetes manifests and resources needed for running the app locally.
  • Developers should use the manifests and configuration in this repository for local workflows.

Production/Staging (ArgoCD)

  • The infrastructure repository contains the manifests and configuration for production and staging environments.
  • These are managed by ArgoCD for GitOps-based deployment.
  • Do not point the Tiltfile to the infrastructure repository; keep local development resources close to the codebase.

Summary:

  • Use this repository for local development and testing with Tilt.
  • Use the infrastructure repository for production/staging deployments with ArgoCD.

Contributing

Contributions are welcome! Please see the docs/ folder for architecture decisions and contribution guidelines.

About

An implementation of the Modular Monolith using .Net 8 and C#

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 3

  •  
  •  
  •