Thursday, June 26, 2025

๐Ÿงฉ Implementing a Lightweight Query Handler in .NET using GMediator fully free for commerical use

In modern .NET applications, maintaining clean architecture is critical — and that’s where the Mediator pattern shines. It decouples the request/response flow and promotes separation of concerns.

While libraries like MediatR are popular, sometimes you want something even lighter — with zero dependencies.

Enter: GMediator, a custom lightweight mediator implementation.


๐Ÿš€ What We’ll Build
In this blog, we’ll create a simple GET API using GMediator that returns a list of products stored in an in-memory store — no database, no ORM — just the core pattern in action.
๐Ÿงฑ Step 1: Define the Product Model

Code Snippet


๐Ÿ’พ Step 2: Create an In-Memory Store

Code Snippet


๐Ÿ“ฌ Step 3: Create the Query Request

Code Snippet


๐ŸŽฏ Step 5: Create the Controller

Code Snippet


๐Ÿงช Step 6: Register GMediator in Program.cs

Code Snippet


๐Ÿ’ก Final Thoughts
GMediator is a great option for internal projects, low-dependency APIs, or learning the Mediator pattern hands-on.
You can extend this by adding Create, Update, Delete, or integrating with a real database like SQLite or SQL Server.

Wednesday, June 11, 2025

Building a Scalable .NET Backend Using Clean Architecture (With Optional Layers) in just an second

If you're building a new .NET backend, Clean Architecture is the best way to keep your code organized, scalable, and future-proof.
๐Ÿงฑ What is Clean Architecture?
It's a way to structure your project into layers:
Domain – core business models
Application – commands, queries, interfaces
Infrastructure – external services (API, logging, etc.)
Persistence – database (EF Core, SQL)
API – controllers
Tests – optional unit/integration tests
⚙️ Script-Based Setup
You can auto-generate this structure using a simple CMD script.
✅ You choose what to include:
Want Infrastructure? Type y
Need Tests? Type n
Want to skip Persistence? Type n




Steps To use:

1. use notepad save below code as setup-architecture.cmd

Code Snippet


2. save this file in respective folder where u want your project files
3. open cmd at this location and run this script by just type its name only that is setup-architecture.cmd

How to Do Cross-Browser Testing on Windows — Including Safari via Playwright

To test follow few steps: Step 1. Install node Step 2. create Folder and run these commands commands Copy Code ...