Hydra Ecommerce is a modular monolith ecommerce platform built with ASP.NET Core and Clean Architecture ideas. The project is organized around business modules such as authentication, CMS, CRM, product catalog, inventory, shopping cart, orders, payments, and file storage.
The goal of Hydra is to provide a practical backend foundation for modern ecommerce products: modular enough to grow, simple enough to run as one application, and clear enough for contributors to add new features without learning a distributed system first.
- Modular monolith architecture with independent API/Core projects per business capability.
- ASP.NET Core Minimal APIs with module-based endpoint discovery.
- Clean separation of concerns between web host, infrastructure, module APIs, module contracts, domain models, and shared kernel.
- Entity Framework Core + PostgreSQL with automatic entity configuration discovery from module assemblies.
- ASP.NET Core Identity + JWT bearer authentication for users, roles, claims, and token-based access.
- Dynamic permission checks through endpoint-level permission requirements.
- Second-level EF caching with in-memory or Redis providers.
- Serilog logging with configurable sinks.
- Localization support through shared resources.
- Background scheduling infrastructure powered by Hangfire packages.
- Central package management through
Directory.Packages.props.
- Architecture
- Project Structure
- Modules
- Request Flow
- Frontend Project
- Prerequisites
- Configuration
- Run Locally
- Database and Migrations
- API Documentation
- How to Add a Feature
- How to Add a New Module
- Development Guidelines
- Contributing
- Roadmap Ideas
Hydra uses a modular monolith design. Everything runs in one ASP.NET Core host, but business capabilities are isolated into separate projects.
Client / Frontend
|
v
Hydra.Web
- ASP.NET Core host
- application startup
- middleware pipeline
- Swagger
|
v
Hydra.Infrastructure
- EF Core DbContext
- Identity/JWT
- module discovery
- repositories
- caching
- logging
- localization
- email/SMS/payment integrations
|
v
Feature Modules
Hydra.Auth.Api Hydra.Auth.Core
Hydra.Cms.Api Hydra.Cms.Core
Hydra.Crm.Api Hydra.Crm.Core
Hydra.Product.Api Hydra.Product.Core
Hydra.Inventory.Api Hydra.Inventory.Core
Hydra.ShoppingCart.Api Hydra.ShoppingCart.Core
Hydra.Order.Api Hydra.Order.Core
Hydra.Payment.Api Hydra.Payment.Core
Hydra.FileStorage.Api Hydra.FileStorage.Core
Hydra.Common.Api Hydra.Common.Core
|
v
Hydra.Kernel / Hydra.Ecommerce.Core
- shared abstractions
- shared ecommerce entities
- common models
- repository contracts
Hydra.Webis the executable application.Hydra.Infrastructurewires cross-cutting concerns and discovers modules.Hydra.Infrastructure.ModuleExtension.IModuleis the contract every API module implements.Hydra.*.Apiprojects register module services and map Minimal API endpoints.Hydra.*.Coreprojects contain contracts, models, domain types, entity configurations, constants, and permissions.ApplicationDbContextapplies EF Core configurations from allHydra*Coreassemblies automatically.Hydra.Webreferences API modules so they are loaded and discoverable at runtime.
.
├── Hydra.Web/ # ASP.NET Core entry point
├── Hydra.Infrastructure/ # Data, auth, modules, caching, logging, integrations
├── Hydra.Kernel/ # Shared primitives, contracts, helpers, common models
├── Hydra.Ecommerce.Core/ # Shared ecommerce domain entities and permissions
├── Hydra.Auth.Api/ # Auth endpoints and API handlers
├── Hydra.Auth.Core/ # Auth domain, models, interfaces, services
├── Hydra.Cms.Api/ # CMS endpoints and services
├── Hydra.Cms.Core/ # CMS domain, models, interfaces, EF configurations
├── Hydra.Crm.Api/ # CRM endpoints and services
├── Hydra.Crm.Core/ # CRM domain, models, interfaces, EF configurations
├── Hydra.Common.Api/ # Common ecommerce endpoints
├── Hydra.Common.Core/ # Common ecommerce models/interfaces
├── Hydra.Product.Api/ # Product/catalog endpoints and services
├── Hydra.Product.Core/ # Product/catalog interfaces and models
├── Hydra.Inventory.Api/ # Inventory endpoints and services
├── Hydra.Inventory.Core/ # Inventory interfaces and models
├── Hydra.ShoppingCart.Api/ # Shopping cart endpoints and services
├── Hydra.ShoppingCart.Core/ # Shopping cart interfaces and models
├── Hydra.Order.Api/ # Order endpoints and services
├── Hydra.Order.Core/ # Order interfaces and models
├── Hydra.Payment.Api/ # Payment endpoints and services
├── Hydra.Payment.Core/ # Payment interfaces and models
├── Hydra.FileStorage.Api/ # File upload/storage endpoints and services
├── Hydra.FileStorage.Core/ # File storage models, interfaces, domain
├── Directory.Packages.props # Central NuGet package versions
└── Hydra.slnx # Solution file
Current business modules include:
| Module | Purpose |
|---|---|
| Auth | Users, roles, permissions, JWT tokens, account operations |
| CMS | Articles, pages, menus, tags, topics, slideshows, site settings |
| CRM | Messages, email inbox/outbox, subscriptions, ticket/chat domain models |
| Common | Addresses, countries, currencies, discounts, taxes, delivery dates |
| Product | Products, categories, manufacturers, product attributes, tags, reviews |
| Inventory | Product stock and inventory operations |
| ShoppingCart | Cart and cart item operations |
| Order | Orders, order items, notes, order lifecycle features |
| Payment | Payment records and payment-related endpoints |
| FileStorage | File upload, file metadata, thumbnails, and storage rules |
- A request reaches
Hydra.Web. - The middleware pipeline applies HTTPS, static files, CORS, authentication, authorization, permissions, localization, and error handling.
MapModulesEndpoints()maps endpoints from every discoveredIModule.- The module endpoint calls a handler.
- The handler delegates business work to a module service.
- Services use shared repositories and
ApplicationDbContext. - Results are returned as standard Minimal API responses.
Hydra also has a companion frontend project built with Next.js. The frontend consumes these APIs and provides the user-facing ecommerce experience on top of this backend.
The Next.js frontend is also open source and ready for contributions. Contributors can help on both sides of the platform:
- Backend features, APIs, modules, permissions, integrations, and database improvements in this repository.
- Frontend pages, components, UX, API integrations, and ecommerce flows in the Next.js project.
- End-to-end improvements that connect frontend features with backend modules.
Add the frontend repository link here when publishing:
Frontend: https://github.com/info-aliahmadi/Ecommerce.Next
- .NET SDK 9
- PostgreSQL 12 or newer
- Optional: Redis if you want Redis-backed caching
- Optional: Docker if you want to containerize the app
Main configuration files are in Hydra.Web:
Hydra.Web/appsettings.jsonHydra.Web/appsettings.Development.jsonHydra.Web/appsettings.Production.json
Important settings:
Do not commit real production secrets. Use user secrets, environment variables, or your deployment platform secret store.
For local development, you can override sensitive values with user secrets:
cd Hydra.Web
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=HydraEcommerce"
dotnet user-secrets set "Authentication:Schemes:Bearer:Secret" "your-long-local-development-secret"Clone the repository:
git clone https://github.com/info-aliahmadi/Ecommerce
cd <your-repo>Restore packages:
dotnet restore Hydra.slnxCreate the PostgreSQL database if it does not exist:
createdb HydraEcommerceApply migrations:
dotnet ef database update --project Hydra.Infrastructure --startup-project Hydra.WebRun the API:
dotnet run --project Hydra.WebOpen Swagger in development:
https://localhost:<port>/swagger
The exact port is shown in the terminal when the app starts.
Hydra uses one database for the modular monolith.
Hydra.Infrastructure/Data/ApplicationDbContext.csis the EF Core DbContext.- Module entity configurations live in each module's
EntityConfigurationfolder. ApplicationDbContextautomatically loads configurations fromHydra*Coreassemblies.- Existing migrations are located in
Hydra.Infrastructure/Migrations.
Create a migration:
dotnet ef migrations add <MigrationName> --project Hydra.Infrastructure --startup-project Hydra.WebUpdate the database:
dotnet ef database update --project Hydra.Infrastructure --startup-project Hydra.WebIn production, the app currently attempts automatic migration during startup.
Swagger is enabled in development. Start the app and browse to:
/swagger
Most module endpoints require a bearer token because modules are mapped through an authorized route group. Use the Auth module to sign in/register and then authorize Swagger with:
Bearer <your-jwt-token>
Use the existing module patterns as the guide. A typical feature touches these layers:
- Domain/entity: Add or update entities in a Core project, usually under
Domain. - EF configuration: Add an
IEntityTypeConfiguration<T>class underEntityConfiguration. - Model/DTO: Add request/response models under
Models. - Interface: Add service contracts under
Interfaces. - Service: Implement business logic in the related API project's
Servicesfolder. - Handler: Add Minimal API handler methods in the API project's
Handlerfolder. - Endpoint mapping: Register routes in the module class under
Endpoints. - Permissions: Add constants and protect routes with
RequirePermission(...)when needed. - Migration: Create and apply an EF Core migration if the database schema changes.
Example locations for a product catalog feature:
Hydra.Product.Core/Models/
Hydra.Product.Core/Interfaces/
Hydra.Ecommerce.Core/Domain/
Hydra.Product.Api/Services/
Hydra.Product.Api/Handler/
Hydra.Product.Api/Endpoints/ProductModule.cs
Create two projects:
Hydra.YourModule.Core
Hydra.YourModule.Api
Recommended structure:
Hydra.YourModule.Core/
├── Constants/
├── Domain/
├── EntityConfiguration/
├── Interfaces/
└── Models/
Hydra.YourModule.Api/
├── Endpoints/
├── Handler/
└── Services/
Add project references:
Hydra.YourModule.Coreshould referenceHydra.Kerneland any shared domain project it needs.Hydra.YourModule.Apishould referenceHydra.InfrastructureandHydra.YourModule.Core.Hydra.Webmust referenceHydra.YourModule.Apiso the module assembly is loaded.
Implement IModule in the API project:
public class YourModule : IModule
{
private const string API_SCHEMA = "/YourModule";
public IServiceCollection RegisterModules(IServiceCollection services)
{
services.AddScoped<IYourService, YourService>();
return services;
}
public IEndpointRouteBuilder MapEndpoints(IEndpointRouteBuilder endpoints)
{
endpoints.MapGet(API_SCHEMA + "/GetItems", YourHandler.GetItems);
return endpoints;
}
}The infrastructure discovers classes implementing IModule in loaded Hydra*Api assemblies and calls both:
RegisterModules(...)MapEndpoints(...)
- Keep modules focused on one business capability.
- Put shared, cross-cutting code in
Hydra.Infrastructureonly when it is truly infrastructure. - Put reusable primitives and contracts in
Hydra.Kernel. - Avoid direct dependencies from one module API to another module API.
- Prefer interfaces in Core projects and implementations in API projects.
- Keep endpoint handlers thin; business rules belong in services.
- Add EF configurations beside the owning module/domain.
- Protect sensitive endpoints with permissions.
- Keep package versions centralized in
Directory.Packages.props. - Do not commit generated build output such as
bin,obj, or IDE metadata.
# Restore dependencies
dotnet restore Hydra.slnx
# Build the solution
dotnet build Hydra.slnx
# Run the web application
dotnet run --project Hydra.Web
# Add an EF migration
dotnet ef migrations add <MigrationName> --project Hydra.Infrastructure --startup-project Hydra.Web
# Apply migrations
dotnet ef database update --project Hydra.Infrastructure --startup-project Hydra.WebContributions are welcome. The best way to help is to keep changes focused, documented, and easy to review.
-
Fork the repository.
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes.
-
Build and test locally:
dotnet build Hydra.slnx
-
Update documentation when behavior, configuration, endpoints, or architecture changes.
-
Open a pull request with a clear description:
- What changed?
- Why is it needed?
- How was it tested?
- Are there migrations or breaking changes?
- The solution builds.
- Database migrations are included when schema changes.
- New endpoints are documented or visible through Swagger.
- Permissions are added for protected operations.
- No secrets, credentials, or local machine paths are committed.
- Generated files such as
bin,obj, and.vsare not included.
These improvements can make the project more useful and attractive for open-source users:
- Add automated tests for services and endpoint handlers.
- Add GitHub Actions for build, test, and code quality checks.
- Add Docker Compose for PostgreSQL, Redis, and the API.
- Add seed data for demo users, roles, permissions, products, and categories.
- Add OpenAPI examples for common flows such as login, product management, cart checkout, and payment.
- Add frontend sample integration.
- Add module-level documentation under a
docs/directory. - Add issue templates, PR templates, Code of Conduct, and Security policy.
- Add badges for build status, license, .NET version, and contributors.
MIT License
Copyright (c) 2026 Hydra Ecommerce | Ali Ahmadi.
{ "ConnectionStrings": { "DefaultConnection": "Host=localhost;Port=5432;Username=postgres;Password=1;Database=HydraEcommerce" }, "Authentication": { "Schemes": { "Bearer": { "Secret": "replace-this-with-a-secure-secret", "ExpirationMinutes": 30 } } }, "CoreOrigin": { "Url": "http://localhost:3000" }, "CacheProvider": "inmemory" }