Posts

Showing posts from January, 2026

NoSQL & MongoDB | Lecture 13

NoSQL & MongoDB  1. What is a Database? A database is a place where we store data permanently . Example: Student details User login info Products in an e-commerce site 2. What is NoSQL? NoSQL means Not Only SQL .  It stores data without tables, rows, and columns . Why NoSQL? Handles large data Very fast Easy to scale Works well with modern web apps 3. SQL vs NoSQL (Simple Table) SQL NoSQL Tables Collections Rows Documents Fixed schema Flexible schema MySQL MongoDB 4. Types of NoSQL Databases Document-based → MongoDB  Key-Value → Redis Column-based → Cassandra Graph → Neo4j  We focus on MongoDB 5. What is MongoDB? MongoDB is a NoSQL document-based database .  It stores data in JSON-like format called BSON . 6. MongoDB Basic Terms Term Meaning Database Main container Collection Like a table Document Like a row Field Like a column 7. Example of MongoDB Document { "name": "Aakash", "age": 25, "course": "MERN Stack" }  One doc...

What is EJS | Lecture 12

EJS (Embedded JavaScript) 1. What is EJS? EJS is a template engine used with Express.js .  It helps us show dynamic data inside HTML. Simple Meaning: HTML + JavaScript = EJS 2. Why do we use EJS? Without EJS: We send plain HTML No dynamic data With EJS: We can show data from backend Reuse HTML Make pages dynamic Example: Show user name from server in HTML. 3. Install EJS npm install ejs 4. Setup EJS in Express app.js const express = require("express"); const app = express(); app.set("view engine", "ejs"); app.listen(3000, () => { console.log("Server running"); }); view engine tells Express to use EJS. 5. Folder Structure for EJS project/ │── app.js │── views/ │ └── home.ejs │ └── about.ejs EJS files must be inside views folder 6. First EJS Page app.js app.get("/", (req, res) => { res.render("home"); }); views/home.ejs <h1>Welcome to EJS</h1> 7. Send Data from Server to EJS app.js app.get(...

What is Middleware? | Lecture 11

    1. What is Middleware? Middleware is a function that runs between the client request and the server response. Flow: Client Request → Middleware → Route → Response Middleware can: Execute code Modify request or response objects End the request–response cycle Call the next middleware or route 2. Why Do We Need Middleware? Without middleware: Code becomes repetitive Logic is mixed inside routes Difficult to manage security and validation With middleware: Clean and reusable code Better security Easier debugging and maintenance 3. Middleware Syntax function middlewareName(req, res, next) {     // logic here     next(); } Key Points: req → request object res → response object next() → moves control to the next middleware or route If next() is not called, the request will stop. 4. Simple Middleware Example Step 1: Create Server const express =...

What is Express.js? The "Fast & Minimalist" Framework for Node.js | Lecture 10

Express.js with Node.js  1. What is Node.js? Node.js is a runtime environment that allows us to run JavaScript outside the browser . Why Node.js? Very fast (uses V8 Engine ) Non-blocking (handles many users at once) Used to create backend servers , APIs, real-time apps Example (Simple Node Program) console.log("Hello from Node.js"); Run using: node app.js 2. What is Express.js? Express.js is a framework built on Node.js that makes backend development easy and fast . Why Express? Less code Easy routing Easy API creation Used in MERN stack Industry standard  Node.js = Engine  Express.js = Toolkit 3. Installing Node.js & Express Step 1: Initialize project npm init -y Step 2: Install Express npm install express 4. Create First Express Server Basic Server Code const express = require("express"); const app = express(); app.listen(3000, () => { console.log("Server running on port 3000"); }); Explanation express() → creates app app.listen() → starts...

What is an API? | Lecture 9

What is an API?  API (Application Programming Interface) is a way for two applications to communicate with each other . Example: Your Node.js app asks a server: “Give me weather data” Server replies: “Here is the weather data” This request–response process is called API integration . Why We Use APIs in Node.js To fetch live data (weather, news, stock prices) To send data (login, signup, payments) To connect with external services like Google, YouTube, WhatsApp, payment gateways Types of APIs REST API – Most common, uses JSON SOAP API – Older, XML based Node.js applications mostly work with REST APIs . Tools Needed for API Integration in Node.js Node.js installed axios or fetch library Install Required Package Using Axios npm install axios Important API Terms Endpoint – API URL Method – GET, POST, PUT, DELETE Headers – Extra information (API key, token) Body – Data sent to server Response – Data returned by API Step 1: Import Axios const axios = require('axios'); Step 2...