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

Wednesday, May 28, 2025

๐Ÿ”„ How to Extend Component Logic and Template in Angular (Simple Guide) => use of extends and ngTemplateOutlet

When building Angular apps, you might have common logic or reusable layouts across components. Instead of duplicating code, you can use extends in TypeScript and ng-template + ngTemplateOutlet in HTML.

Let’s walk through a simple example with 2 components where one extends logic and also injects custom HTML.


✅ Step 1: Create a Child Component (as base layout)

This is the reusable component that contains a common layout and logic.

child.component.ts

child.component.html

  • ✅ Layout and logic are defined here.
  • ✅ Accepts external HTML through contentTemplate.

✅ Step 2: Create a Parent Component That Extends Child

This component inherits logic from ChildComponent and injects its own template content.

parent.component.ts

parent.component.html

  • ✅ Inherits logic like title and getTitle() from ChildComponent.
  • ✅ Injects its own content via ng-template.

✅ Final Output

  • ChildComponent provides the reusable layout.
  • ParentComponent injects dynamic HTML and extends the logic.
  • This keeps your code DRY, clean, and scalable.

Use Cases: shared card layouts, reusable modal structures, dashboards, etc.

Friday, May 2, 2025

๐Ÿงน How to Remove SSR (Server Side Rendering) from an Angular 19 Project

Sometimes you add Angular SSR using @angular/ssr, but later want to return to a clean client-side app. Here's how to fully remove SSR (Server-Side Rendering) from your Angular project. ๐Ÿ”ฅ Step 1: Delete SSR Files Remove these files from the src/ folder: main.server.ts app.server.module.ts server.ts Any .server.ts files like: app.routes.server.ts app.config.server.ts ๐Ÿ› ️ Step 2: Update angular.json Inside "architect > build > options", remove the following: Also remove the entire "server" block from angular.json if it exists. ๐Ÿงพ Step 3: Clean Up TypeScript Config ❌ Delete: tsconfig.server.json ✅ Edit tsconfig.app.json like this: ๐Ÿงน Step 4: Uninstall SSR Dependencies ๐Ÿ–ฅ️ Run in Terminal / PowerShell / CMD: ๐Ÿš€ Step 5: Clean & Serve PowerShell (Windows): Mac/Linux terminal: ✅ Done! Your Angular app is now SSR-free and runs entirely with Client-Side Rendering (CSR) — faster dev, fewer headaches!

Saturday, March 29, 2025

๐Ÿš€ How to Copy a SQL Server Database Using a .bacpac File (Schema + Data) || Clone DB

#Clone Database 
Need to duplicate a full SQL Server database — including tables, views, stored procedures and data — without writing complex scripts?

Let me show you a simple, reliable method: Exporting and Importing a Data-tier Application (.bacpac). It’s perfect for backups, migrations, and creating dev/test clones.


 Step 1: Export the Source Database

  1. Open SQL Server Management Studio (SSMS).

  2. Right-click your source database → Tasks → Export Data-tier Application.

  3. Choose "Save to local disk", then pick a file path and name (YourDatabase.bacpac).

  4. Click Next through the wizard and generate the .bacpac file.


 Step 2: Import into Target Server

  1. In SSMS, right-click DatabasesImport Data-tier Application.

  2. Select the .bacpac file you exported.

  3. Give the new database a name.

  4. Complete the wizard. ๐ŸŽ‰ Done!


๐Ÿงฉ Diagram

[ Source DB ] | | Export as .bacpac ↓ [ YourFile.bacpac ] | | Import on Target Server ↓ [ New DB Clone ]

Why Use This?

  • ๐Ÿ”„ Migrate databases between environments (dev, staging, prod).

  • ๐Ÿ› ️ Create dev/test clones without risking production.

  • ๐Ÿ“ฆ Archive snapshots with both schema and data.

Friday, March 14, 2025

Run ai model in python code with ollama

 First download and install ollama By this blog:
Tech Journey With Gagan: Run Any AI Model with ollama in windows

For Use AI model in python:
1. run this script
Note: this example for mistral ai model please change acording to your model

Declare function


For run

it is work like this


Option 2: 
Run server explicitly 

1. Click on Quit Ollama


2. run server with ollama serve mean in cmd type "ollama serve".



Run Any AI Model with ollama in windows

Steps for install Any model with ollama in local : 
1. Download Olama  and install 


2.  open cmd and run "ollama" command to verify that ollama installed or not.



3. Install models  
    a. find your model and click on it.

   b. copy command and paste into terminal





                      press Enter now your model installed 

Note :Later on same command run your model will run automatically this time it is not downloading it just run 



How To work python with ollama: Run AI Model with Python

๐Ÿš€ Agentic Framework 1.0 in .NET: The Power Combo of Semantic Kernel + AutoGen

The AI landscape is shifting fast—from simple prompt-response systems to autonomous, decision-making agents . If you're still building b...