A lightweight CQRS + Clean Architecture sample for building a simple e‑commerce backend.
CqrsShop is an educational, production-oriented sample backend demonstrating CQRS (via MediatR), Clean Architecture, EF Core with PostgreSQL, and ASP.NET Core Identity. It's ideal for teams and learners who want a realistic, well-structured starting point for e-commerce backends.
- Realistic domain modeling and separation of concerns
- Demonstrates MediatR-driven commands/queries and repository patterns
- Ready-to-run API with Swagger — great for experimentation and teaching
- 🛍️ Product CRUD with inventory support
- 🧾 Order placement, cancellation, and lifecycle
- 🔐 ASP.NET Core Identity-based authentication & refresh tokens
- ✉️ MediatR handlers for commands/queries (CQRS)
- 🐘 EF Core + Npgsql (Postgres) persistence with migrations
- 🧾 Serilog structured logging
- 🧩 Clean Architecture with clear layer separation
- .NET 7.0 SDK or later
- PostgreSQL database
- Visual Studio Code or Visual Studio 2022
- Clone the repository
git clone https://github.com/your-org/CqrsShop.git
cd CqrsShop- Configure the database connection
cd Src/Presentation
cp appsettings.Example.json appsettings.Development.jsonEdit appsettings.Development.json with your PostgreSQL connection string.
- Build and run
dotnet restore
dotnet build
cd Src/Infrastructure
dotnet ef database update --project Infrastructure --startup-project ../Presentation
cd ../Presentation
dotnet runAccess the Swagger UI at http://localhost:5180/swagger
Example API call:
curl -X POST http://localhost:5180/api/Products \
-H "Content-Type: application/json" \
-d '{
"name": "Test Product",
"description": "Description",
"price": 29.99,
"category": "electronics",
"initialStock": 100
}'- .NET 7.0+ ⚙️
- ASP.NET Core Web API 🕸️
- MediatR (CQRS) ✉️
- Entity Framework Core 🗄️
- PostgreSQL 🐘
- ASP.NET Core Identity 🔐
- Serilog 📝
- Swagger/OpenAPI 📘
CqrsShop/
├── src/
│ ├── Application/ # Business logic, CQRS handlers
│ ├── Domain/ # Entities, value objects
│ ├── Infrastructure/ # Data access, external services
│ └── Presentation/ # API endpoints, middleware
├── tests/ # Unit & integration tests
└── README.md
- Fork the repository
- Create your feature branch
git checkout -b feature/amazing-feature- Commit your changes
git commit -m 'Add some amazing feature'- Push to the branch
git push origin feature/amazing-feature- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Project Link: https://github.com/timmi-tech/CqrsShop
⭐ Star us on GitHub — it helps!