Skip to content

Timmi-tech/CqrsShop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CqrsShop 🧩

A lightweight CQRS + Clean Architecture sample for building a simple e‑commerce backend.

C# ASP.NET Core Entity Framework Core FluentValidation MediatR

About

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.

Why This Project?

  • 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

🔥 Features

  • 🛍️ 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

⚡ Getting Started

Prerequisites

  • .NET 7.0 SDK or later
  • PostgreSQL database
  • Visual Studio Code or Visual Studio 2022

Installation

  1. Clone the repository
git clone https://github.com/your-org/CqrsShop.git
cd CqrsShop
  1. Configure the database connection
cd Src/Presentation
cp appsettings.Example.json appsettings.Development.json

Edit appsettings.Development.json with your PostgreSQL connection string.

  1. Build and run
dotnet restore
dotnet build
cd Src/Infrastructure
dotnet ef database update --project Infrastructure --startup-project ../Presentation
cd ../Presentation
dotnet run

🚀 Usage

Access 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
  }'

🛠️ Tech Stack

  • .NET 7.0+ ⚙️
  • ASP.NET Core Web API 🕸️
  • MediatR (CQRS) ✉️
  • Entity Framework Core 🗄️
  • PostgreSQL 🐘
  • ASP.NET Core Identity 🔐
  • Serilog 📝
  • Swagger/OpenAPI 📘

Project Structure

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

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch
git checkout -b feature/amazing-feature
  1. Commit your changes
git commit -m 'Add some amazing feature'
  1. Push to the branch
git push origin feature/amazing-feature
  1. Open a Pull Request

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

Project Link: https://github.com/timmi-tech/CqrsShop


⭐ Star us on GitHub — it helps!

About

A lightweight CQRS + Clean Architecture sample for building a simple e‑commerce backend.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages