NestJSBeginner
NestJS Introduction
NestJS কী, কেন ব্যবহার হয়, architecture, NestJS বনাম Express — বাংলায় পরিচিতি।
11টি অংশবাংলা ভাষায়
NestJS হলো একটি progressive, enterprise-ready Node.js framework যা TypeScript দিয়ে scalable, maintainable backend application তৈরি করতে সাহায্য করে। এটি Angular থেকে অনুপ্রাণিত।
NestJS কী?
NestJS হলো Node.js backend framework যা modular architecture, dependency injection, আর decorators — এই তিনটি মূল concept-এ ভিত্তি করে গড়ে ওঠে। এর under the hood Express (ডিফল্ট) or Fastify চলে।
NestJS কেন ব্যবহার করবেন?
- TypeScript-first — ধরনের সাথে সম্পূর্ণ type safety
- Modular — আলাদা module-এ কোড ভাগ, maintainable ও scalable
- Dependency Injection (DI) — ক্লাস gdatetime আবার testable
- Decorator-based — জারগন minimal, readable code
- Structure — architecture-এর নির্দিষ্ট guideline, ছোট project-ও পরিষ্কার
- Ecosystem — Mongoose, TypeORM, GraphQL, microservices — সব integrated
- Testing — unit & e2e testing built-in support
NestJS বনাম Express
| বৈশিষ্ট্য | Express | NestJS |
|---|---|---|
| Structure | Unopinionated (আপনার ইচ্ছা) | Opinionated (structure fix) |
| TypeScript | Optional | First-class |
| Dependency Injection | নেই | আছে (built-in) |
| Modularity | ম্যানুয়াল | আছে (module system) |
| Shining | Simple ও lightweight | Scalable ও enterprise |
| Learning curve | Easy | মধ্যম |
| Best for | Small/medium API | Large/complex application |
NestJS Architecture Overview
Core Building Blockstext
text
Client (HTTP Request)
│
▼
┌─────────────┐
│ Controller │ ← Routes define করে (GET/POST)
└──────┬──────┘
▼
┌─────────────┐
│ Providers │ ← Business logic (Service, Repository)
│ (Service) │
└──────┬──────┘
▼
┌─────────────┐
│ CORS/Guard/ │ ← Interceptors, Pipes, Middleware
│ Middleware │ (request-এর আগে-পরে)
└──────┬──────┘
▼
┌─────────────┐
│ Module │ ← সবগুলো organize করে (@Module)
└─────────────┘NestJS-এর প্রতিটি request flow: Controller → Guard → Interceptor/Pipe → Service → Repository → Database, আবার মাধ্যমে response ফেরত।
পরবর্তী ধাপ
পরবর্তী topic-এ NestJS ইনস্টল ও প্রথম project-এর structure বুঝবো।
শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।