Web Development Roadmap
🌐 REST APIs & Routing in Express
Now you move from basic server → real backend API structure.
If you understand this topic properly, you can build production-level APIs.
🧠 What is a REST API?
REST = Representational State Transfer
Simple meaning:
👉 Backend exposes URLs
👉 Frontend sends HTTP requests
👉 Backend returns data (usually JSON)
🔥 REST API Structure
REST follows resources-based URLs.
Example resource: users
Instead of:
-
-
REST style:
- POST
- PUT
- DELETE
📌 HTTP Methods in REST
- GET -> Read data
- POST -> Create data
- PUT -> Update data
- DELETE -> Remove data
These map directly to CRUD.
🧩 Basic REST API Example
Step 1: Setup Express
🔍 1️⃣ GET – Fetch all users
➕ 2️⃣ POST – Add new user
✏️ 3️⃣ PUT – Update user
❌ 4️⃣ DELETE – Remove user
▶️ Start Server
🧠 What is Routing?
Routing means:
👉 Matching URL
👉 Matching HTTP method
👉 Running correct function
Example:
- GET /users → fetch users
- POST /users → create user
📁 Better Folder Structure (Real Projects)
Separation of concerns = scalable backend.
⚠️ Common Beginner Mistakes
- Not using express.json()
- Not parsing req.params correctly
- Not sending status codes
- Not handling missing data
🧪 Mini Practice Task
- Create REST API for products
- GET
- POST
- PUT
- DELETE
➡️ Double Tap ♥️ For More
🌐 REST APIs & Routing in Express
Now you move from basic server → real backend API structure.
If you understand this topic properly, you can build production-level APIs.
🧠 What is a REST API?
REST = Representational State Transfer
Simple meaning:
👉 Backend exposes URLs
👉 Frontend sends HTTP requests
👉 Backend returns data (usually JSON)
🔥 REST API Structure
REST follows resources-based URLs.
Example resource: users
Instead of:
-
/addUser-
/deleteUserREST style:
- POST
/users- PUT
/users/:id- DELETE
/users/:id📌 HTTP Methods in REST
- GET -> Read data
- POST -> Create data
- PUT -> Update data
- DELETE -> Remove data
These map directly to CRUD.
🧩 Basic REST API Example
Step 1: Setup Express
const express = require("express");
const app = express();
app.use(express.json()); // middleware for JSON
let users = [
{ id: 1, name: "Amit" },
{ id: 2, name: "Rahul" }
];
🔍 1️⃣ GET – Fetch all users
app.get("/users", (req, res) => {
res.json(users);
});
➕ 2️⃣ POST – Add new user
app.post("/users", (req, res) => {
const newUser = {
id: users.length + 1,
name: req.body.name
};
users.push(newUser);
res.json(newUser);
});
✏️ 3️⃣ PUT – Update user
app.put("/users/:id", (req, res) => {
const id = parseInt(req.params.id);
const user = users.find(u => u.id === id);
if (!user) {
return res.status(404).json({ message: "User not found" });
}
user.name = req.body.name;
res.json(user);
});
❌ 4️⃣ DELETE – Remove user
app.delete("/users/:id", (req, res) => {
const id = parseInt(req.params.id);
users = users.filter(u => u.id !== id);
res.json({ message: "User deleted" });
});
▶️ Start Server
app.listen(3000, () => {
console.log("Server running on port 3000");
});
🧠 What is Routing?
Routing means:
👉 Matching URL
👉 Matching HTTP method
👉 Running correct function
Example:
- GET /users → fetch users
- POST /users → create user
📁 Better Folder Structure (Real Projects)
project/
├── routes/
│ └── userRoutes.js
├── controllers/
├── server.js
Separation of concerns = scalable backend.
⚠️ Common Beginner Mistakes
- Not using express.json()
- Not parsing req.params correctly
- Not sending status codes
- Not handling missing data
🧪 Mini Practice Task
- Create REST API for products
- GET
/products- POST
/products- PUT
/products/:id- DELETE
/products/:id➡️ Double Tap ♥️ For More
❤12🔥2
What does REST stand for?
Anonymous Quiz
18%
A. Remote Execution System Tool
51%
B. Representational State Transfer
22%
C. Real-time Server Technology
9%
D. Resource Execution Structure Tool
❤2
Which HTTP method is used to fetch data in a REST API?
Anonymous Quiz
14%
A. POST
10%
B. PUT
75%
C. GET
1%
D. DELETE
❤1
Which HTTP method is commonly used to create new data in a REST API?
Anonymous Quiz
13%
A. GET
62%
B. POST
23%
C. PUT
2%
D. DELETE
In Express, how do you access route parameters like /users/:id?
Anonymous Quiz
18%
A. req.query.id
19%
B. req.body.id
59%
4%
Which middleware is used in Express to parse JSON request bodies?
Anonymous Quiz
10%
A. express.body()
63%
B. express.json()
25%
C. express.parse()
2%
D. express.data()
❤4
Complete 6-month front-end roadmap to crack product-based companies in 2025:
𝗠𝗼𝗻𝘁𝗵 𝟭: 𝗙𝗼𝘂𝗻𝗱𝗮𝘁𝗶𝗼𝗻𝘀 𝗼𝗳 𝗪𝗲𝗯 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗺𝗲𝗻𝘁
Basic HTML
- Form
- Import
- Elements
- Attributes
- Semantics
- Multimedia
- Block element
𝗕𝗮𝘀𝗶𝗰 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀
- Scope
- Closure
- Functions
- Data types
- Event loop
𝗕𝗮𝘀𝗶𝗰 𝗖𝗦𝗦 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀
- Box Model
- Pseudo Classes
- Class and other selectors
- CSS type - Flex, Grid, normal
𝗠𝗼𝗻𝘁𝗵 𝟮: 𝗔𝗱𝘃𝗮𝗻𝗰𝗲𝗱 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀
- How to center
- Media queries
- Bind/call/apply
- Design and CSS
- Pseudo Elements
- Class and inheritance
- Prototype and prototype chain
- All element states - active, hover
𝗠𝗼𝗻𝘁𝗵 𝟯: 𝗜𝗻𝘁𝗲𝗿𝗮𝗰𝘁𝗶𝘃𝗶𝘁𝘆 & 𝗦𝘁𝘆𝗹𝗶𝗻𝗴
- Grid
- DOM
- Mixins
- Flexbox
- CSS constants
- Page Styling Concepts
- Event loop continuation
- Pre-processors - SCSS or LESS
𝗠𝗼𝗻𝘁𝗵 𝟰: 𝗔𝗱𝘃𝗮𝗻𝗰𝗲𝗱 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗮𝗻𝗱 𝗔𝗣𝗜𝘀
- JWT
- XHR
- Cookie
- WebAPI
- Call stack
- Generators
- Task queue
- Async/await
- Working with Data
- APIs and Communication
- Local storage/Session storage
- REST/GraphQL/Socket connection
𝗠𝗼𝗻𝘁𝗵 𝟱: 𝗖𝗼𝗺𝗽𝗹𝗲𝘅 𝗪𝗲𝗯 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗺𝗲𝗻𝘁 𝗦𝗸𝗶𝗹𝗹𝘀
- CORS
- OOPs concept
- Debugging Application
- Chrome Dev Tool Features
- Understanding V8 in depth
- Front-End Engineering Practices
- Design Patterns (Singleton, Observer, Module, etc.)
𝗠𝗼𝗻𝘁𝗵 6: 𝗥𝗲𝗮𝗰𝘁 𝗮𝗻𝗱 𝗠𝗼𝗱𝗲𝗿𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗙𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸
- Routing
- Context API
- Virtual DOM
- React Hooks
- Custom Hooks
- State and Props
- Advanced React
- Introduction JSX
- React Ecosystem
- React Component
- Unit Testing with Jest
- Server-Side Rendering
- Redux/Flux for State Management
Apart from these, I would continuously focus on:
- Typescript
- Mocking Data
- Design Patterns in depth
- Understanding Webpack
- Advanced React patterns
- Babel, env, prettier, linter
- Tooling and Optimization
- Basic to advanced concepts for type-safety in JavaScript projects.
Web Development Resources ⬇️
https://whatsapp.com/channel/0029VaiSdWu4NVis9yNEE72z
React with emoji for more content like this
𝗠𝗼𝗻𝘁𝗵 𝟭: 𝗙𝗼𝘂𝗻𝗱𝗮𝘁𝗶𝗼𝗻𝘀 𝗼𝗳 𝗪𝗲𝗯 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗺𝗲𝗻𝘁
Basic HTML
- Form
- Import
- Elements
- Attributes
- Semantics
- Multimedia
- Block element
𝗕𝗮𝘀𝗶𝗰 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀
- Scope
- Closure
- Functions
- Data types
- Event loop
𝗕𝗮𝘀𝗶𝗰 𝗖𝗦𝗦 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀
- Box Model
- Pseudo Classes
- Class and other selectors
- CSS type - Flex, Grid, normal
𝗠𝗼𝗻𝘁𝗵 𝟮: 𝗔𝗱𝘃𝗮𝗻𝗰𝗲𝗱 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀
- How to center
- Media queries
- Bind/call/apply
- Design and CSS
- Pseudo Elements
- Class and inheritance
- Prototype and prototype chain
- All element states - active, hover
𝗠𝗼𝗻𝘁𝗵 𝟯: 𝗜𝗻𝘁𝗲𝗿𝗮𝗰𝘁𝗶𝘃𝗶𝘁𝘆 & 𝗦𝘁𝘆𝗹𝗶𝗻𝗴
- Grid
- DOM
- Mixins
- Flexbox
- CSS constants
- Page Styling Concepts
- Event loop continuation
- Pre-processors - SCSS or LESS
𝗠𝗼𝗻𝘁𝗵 𝟰: 𝗔𝗱𝘃𝗮𝗻𝗰𝗲𝗱 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗮𝗻𝗱 𝗔𝗣𝗜𝘀
- JWT
- XHR
- Cookie
- WebAPI
- Call stack
- Generators
- Task queue
- Async/await
- Working with Data
- APIs and Communication
- Local storage/Session storage
- REST/GraphQL/Socket connection
𝗠𝗼𝗻𝘁𝗵 𝟱: 𝗖𝗼𝗺𝗽𝗹𝗲𝘅 𝗪𝗲𝗯 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗺𝗲𝗻𝘁 𝗦𝗸𝗶𝗹𝗹𝘀
- CORS
- OOPs concept
- Debugging Application
- Chrome Dev Tool Features
- Understanding V8 in depth
- Front-End Engineering Practices
- Design Patterns (Singleton, Observer, Module, etc.)
𝗠𝗼𝗻𝘁𝗵 6: 𝗥𝗲𝗮𝗰𝘁 𝗮𝗻𝗱 𝗠𝗼𝗱𝗲𝗿𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗙𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸
- Routing
- Context API
- Virtual DOM
- React Hooks
- Custom Hooks
- State and Props
- Advanced React
- Introduction JSX
- React Ecosystem
- React Component
- Unit Testing with Jest
- Server-Side Rendering
- Redux/Flux for State Management
Apart from these, I would continuously focus on:
- Typescript
- Mocking Data
- Design Patterns in depth
- Understanding Webpack
- Advanced React patterns
- Babel, env, prettier, linter
- Tooling and Optimization
- Basic to advanced concepts for type-safety in JavaScript projects.
Web Development Resources ⬇️
https://whatsapp.com/channel/0029VaiSdWu4NVis9yNEE72z
React with emoji for more content like this
❤17🥰1😁1
🔗 Connecting React Frontend to Backend API
Now you connect React (Frontend) with Node.js/Express (Backend). This is the core of full-stack development. Frontend sends HTTP requests → Backend processes → Returns JSON data.
🧠 How Frontend and Backend Communicate
Flow:
1️⃣ React sends request (API call)
2️⃣ Backend receives request
3️⃣ Backend processes logic
4️⃣ Backend sends response
5️⃣ React updates UI
Example: React → GET /users → Express API → JSON → React UI
🌐 API Request Methods Used in React
- GET: Fetch data
- POST: Send data
- PUT: Update data
- DELETE: Remove data
⚡ Method 1: Fetch API
JavaScript has a built-in function called fetch().
📥 Example: Fetch users from backend
Backend endpoint: GET
React code:
➕ Sending Data to Backend (POST)
Example: Add new user.
✏️ Updating Data (PUT)
⚠️ Common Beginner Issues
1️⃣ CORS error
Backend must allow frontend.
Example:
2️⃣ Wrong API URL
Frontend must call:
3️⃣ Missing JSON middleware
🧪 Mini Practice Task
Build a simple React + Express full stack app
Tasks:
- Fetch users from backend
- Display users in React
- Add new user from React form
- Delete user from UI
➡️ Double Tap ♥️ For More
Now you connect React (Frontend) with Node.js/Express (Backend). This is the core of full-stack development. Frontend sends HTTP requests → Backend processes → Returns JSON data.
🧠 How Frontend and Backend Communicate
Flow:
1️⃣ React sends request (API call)
2️⃣ Backend receives request
3️⃣ Backend processes logic
4️⃣ Backend sends response
5️⃣ React updates UI
Example: React → GET /users → Express API → JSON → React UI
🌐 API Request Methods Used in React
- GET: Fetch data
- POST: Send data
- PUT: Update data
- DELETE: Remove data
⚡ Method 1: Fetch API
JavaScript has a built-in function called fetch().
📥 Example: Fetch users from backend
Backend endpoint: GET
http://localhost:3000/usersReact code:
import { useEffect, useState } from "react";
function App() {
const [users, setUsers] = useState([]);
useEffect(() => {
fetch("http://localhost:3000/users")
.then(res => res.json())
.then(data => setUsers(data));
}, []);
return (
<div>
<h2>User List</h2>
{users.map(user => (
<p key={user.id}>{user.name}</p>
))}
</div>
);
}
export default App;
Result: React automatically displays backend data.➕ Sending Data to Backend (POST)
Example: Add new user.
const addUser = async () => {
await fetch("http://localhost:3000/users", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ name: "Deepak" })
});
};
Backend receives JSON and stores it.✏️ Updating Data (PUT)
await fetch("http://localhost:3000/users/1", {
method: "PUT",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ name: "Updated Name" })
});
❌ Deleting Data (DELETE)await fetch("http://localhost:3000/users/1", {
method: "DELETE"
});
🧩 Common Full Stack Folder Structureproject/Frontend and backend run separately.
├── client/ (React frontend)
│ └── src/
├── server/ (Node backend)
│ └── routes/
├── package.json
⚠️ Common Beginner Issues
1️⃣ CORS error
Backend must allow frontend.
Example:
const cors = require("cors");
app.use(cors());
Install: npm install cors2️⃣ Wrong API URL
Frontend must call:
http://localhost:3000/api/users3️⃣ Missing JSON middleware
app.use(express.json())🧪 Mini Practice Task
Build a simple React + Express full stack app
Tasks:
- Fetch users from backend
- Display users in React
- Add new user from React form
- Delete user from UI
➡️ Double Tap ♥️ For More
❤14
How does a React frontend usually communicate with a backend server?
Anonymous Quiz
3%
A. Using CSS
88%
B. Using API requests (HTTP requests)
5%
C. Using HTML tags
4%
D. Using database queries directly
🔥6
Which JavaScript function is commonly used in React to call APIs?
Anonymous Quiz
15%
A. request()
67%
B. fetch()
16%
C. callAPI()
2%
D. connect()
🔥3🤔1
Which HTTP method is typically used to send new data from React to the backend?
Anonymous Quiz
18%
A. GET
72%
B. POST
9%
C. PUT
1%
D. DELETE
Why is the cors middleware used in Express?
Anonymous Quiz
4%
A. To store data in database
89%
B. To allow frontend and backend to communicate across different origins
5%
C. To compile JavaScript
2%
D. To speed up server performance
❤4
Which React hook is commonly used to fetch data when a component loads?
Anonymous Quiz
15%
A. useRef
60%
B. useEffect
6%
C. useMemo
19%
D. useCallback
❤1
🌐 Frontend Development Concepts You Should Know
Frontend development focuses on building the user interface (UI) of websites and web applications—the part users see and interact with in the browser. It combines design, structure, interactivity, and performance to create responsive and user-friendly web experiences.
1️⃣ Core Technologies of Frontend Development
Frontend development is built on three foundational technologies:
- HTML (HyperText Markup Language): provides the structure of a webpage
- CSS (Cascading Style Sheets): controls the visual appearance and layout
- JavaScript: adds interactivity and dynamic behavior to web pages
2️⃣ Important Frontend Concepts
- Responsive Design: ensures websites work properly across devices
- DOM (Document Object Model): represents the structure of a webpage as objects
- Event Handling: frontend applications respond to user actions
- Asynchronous Programming: fetch data without reloading pages
3️⃣ Frontend Frameworks & Libraries
- React: popular JavaScript library for building component-based UI
- Angular: full frontend framework for large-scale applications
- Vue.js: lightweight framework known for simplicity and flexibility
4️⃣ Styling Tools
- CSS Frameworks: Tailwind CSS, Bootstrap, Material UI
- CSS Preprocessors: Sass, Less
5️⃣ Frontend Development Tools
- VS Code: code editor
- Git: version control
- Webpack / Vite: module bundlers
- NPM / Yarn: package managers
- Chrome DevTools: debugging
6️⃣ Performance Optimization
- lazy loading
- code splitting
- image optimization
- caching strategies
- minimizing HTTP requests
7️⃣ Typical Frontend Development Workflow
1. UI/UX Design
2. HTML Structure
3. Styling with CSS
4. Add JavaScript Interactivity
5. Integrate APIs
6. Test and debug
7. Deploy application
8️⃣ Real-World Frontend Projects
- Responsive Portfolio Website
- Weather App
- To-Do List Application
- E-commerce Product Page
- Dashboard UI
Double Tap ♥️ For More
Frontend development focuses on building the user interface (UI) of websites and web applications—the part users see and interact with in the browser. It combines design, structure, interactivity, and performance to create responsive and user-friendly web experiences.
1️⃣ Core Technologies of Frontend Development
Frontend development is built on three foundational technologies:
- HTML (HyperText Markup Language): provides the structure of a webpage
- CSS (Cascading Style Sheets): controls the visual appearance and layout
- JavaScript: adds interactivity and dynamic behavior to web pages
2️⃣ Important Frontend Concepts
- Responsive Design: ensures websites work properly across devices
- DOM (Document Object Model): represents the structure of a webpage as objects
- Event Handling: frontend applications respond to user actions
- Asynchronous Programming: fetch data without reloading pages
3️⃣ Frontend Frameworks & Libraries
- React: popular JavaScript library for building component-based UI
- Angular: full frontend framework for large-scale applications
- Vue.js: lightweight framework known for simplicity and flexibility
4️⃣ Styling Tools
- CSS Frameworks: Tailwind CSS, Bootstrap, Material UI
- CSS Preprocessors: Sass, Less
5️⃣ Frontend Development Tools
- VS Code: code editor
- Git: version control
- Webpack / Vite: module bundlers
- NPM / Yarn: package managers
- Chrome DevTools: debugging
6️⃣ Performance Optimization
- lazy loading
- code splitting
- image optimization
- caching strategies
- minimizing HTTP requests
7️⃣ Typical Frontend Development Workflow
1. UI/UX Design
2. HTML Structure
3. Styling with CSS
4. Add JavaScript Interactivity
5. Integrate APIs
6. Test and debug
7. Deploy application
8️⃣ Real-World Frontend Projects
- Responsive Portfolio Website
- Weather App
- To-Do List Application
- E-commerce Product Page
- Dashboard UI
Double Tap ♥️ For More
❤26
🗄️ Database Integration — MongoDB with Node.js
Now you move from temporary data (arrays) → real database storage.
Backend apps must store data permanently.
That's where databases come in.
🧠 What is a Database
A database stores data persistently.
Examples:
• E-commerce: Products, orders
• Social media: Users, posts
• Banking app: Transactions
Without database → data disappears when server restarts.
🍃 What is MongoDB
MongoDB is a NoSQL database.
Instead of tables → it stores documents (JSON-like data).
Example document:
Collection = group of documents
Database = group of collections
📦 Why MongoDB is Popular
✅ JSON-like data
✅ Flexible schema
✅ Works perfectly with JavaScript
✅ Scales easily
Common in MERN stack.
MERN = MongoDB + Express + React + Node
🔗 Connecting MongoDB with Node.js
We use a library called Mongoose.
Install:
⚡ Step 1 — Connect Database
Example:
Now Node server is connected to MongoDB.
🧩 Step 2 — Create Schema
Schema defines data structure.
Example:
📄 Step 3 — Create Model
Model allows database operations.
➕ Step 4 — Create Data
🔍 Step 5 — Fetch Data
❌ Step 6 — Delete Data
✏️ Step 7 — Update Data
🔄 Full Backend Flow Now
React → API request
Express → Handles route
Mongoose → Talks to MongoDB
MongoDB → Stores data
⚠️ Common Beginner Mistakes
• Forgetting to install mongoose
• Not using async/await
• Wrong MongoDB URL
• Not validating schema
🧪 Mini Practice Task
Build Product API with MongoDB
Routes:
• POST /products
• GET /products
• PUT /products/:id
• DELETE /products/:id
Fields:
name
price
category
✅ Double Tap ♥️ For More
Now you move from temporary data (arrays) → real database storage.
Backend apps must store data permanently.
That's where databases come in.
🧠 What is a Database
A database stores data persistently.
Examples:
• E-commerce: Products, orders
• Social media: Users, posts
• Banking app: Transactions
Without database → data disappears when server restarts.
🍃 What is MongoDB
MongoDB is a NoSQL database.
Instead of tables → it stores documents (JSON-like data).
Example document:
{
"name": "Deepak",
"role": "Developer",
"age": 25
}
Collection = group of documents
Database = group of collections
📦 Why MongoDB is Popular
✅ JSON-like data
✅ Flexible schema
✅ Works perfectly with JavaScript
✅ Scales easily
Common in MERN stack.
MERN = MongoDB + Express + React + Node
🔗 Connecting MongoDB with Node.js
We use a library called Mongoose.
Install:
npm install mongoose
⚡ Step 1 — Connect Database
Example:
const mongoose = require("mongoose");
mongoose.connect("mongodb://127.0.0.1:27017/myapp")
.then(() => console.log("MongoDB Connected"))
.catch(err => console.log(err));
Now Node server is connected to MongoDB.
🧩 Step 2 — Create Schema
Schema defines data structure.
Example:
const userSchema = new mongoose.Schema({
name: String,
age: Number
});
📄 Step 3 — Create Model
Model allows database operations.
const User = mongoose.model("User", userSchema);
➕ Step 4 — Create Data
app.post("/users", async (req, res) => {
const user = new User({
name: req.body.name,
age: req.body.age
});
await user.save();
res.json(user);
});
🔍 Step 5 — Fetch Data
app.get("/users", async (req, res) => {
const users = await User.find();
res.json(users);
});
❌ Step 6 — Delete Data
app.delete("/users/:id", async (req, res) => {
await User.findByIdAndDelete(req.params.id);
res.json({ message: "User deleted" });
});
✏️ Step 7 — Update Data
app.put("/users/:id", async (req, res) => {
const user = await User.findByIdAndUpdate(
req.params.id,
req.body,
{ new: true }
);
res.json(user);
});
🔄 Full Backend Flow Now
React → API request
Express → Handles route
Mongoose → Talks to MongoDB
MongoDB → Stores data
⚠️ Common Beginner Mistakes
• Forgetting to install mongoose
• Not using async/await
• Wrong MongoDB URL
• Not validating schema
🧪 Mini Practice Task
Build Product API with MongoDB
Routes:
• POST /products
• GET /products
• PUT /products/:id
• DELETE /products/:id
Fields:
name
price
category
✅ Double Tap ♥️ For More
❤28
⚙️ MERN Stack Developer Roadmap
📂 HTML/CSS/JavaScript Fundamentals
∟📂 MongoDB (Installation, Collections, CRUD)
∟📂 Express.js (Setup, Routing, Middleware)
∟📂 React.js (Components, Hooks, State, Props)
∟📂 Node.js Basics (npm, modules, HTTP server)
∟📂 Backend API Development (REST endpoints)
∟📂 Frontend-State Management (useState, useEffect, Context/Redux)
∟📂 MongoDB + Mongoose (Schemas, Models)
∟📂 Authentication (JWT, bcrypt, Protected Routes)
∟📂 React Router (Navigation, Dynamic Routing)
∟📂 Axios/Fetch API Integration
∟📂 Error Handling & Validation
∟📂 File Uploads (Multer, Cloudinary)
∟📂 Deployment (Vercel Frontend, Render/Heroku Backend, MongoDB Atlas)
∟📂 Projects (Todo App → E-commerce → Social Media Clone)
∟✅ Apply for Fullstack / Frontend Roles
💬 Tap ❤️ for more!
📂 HTML/CSS/JavaScript Fundamentals
∟📂 MongoDB (Installation, Collections, CRUD)
∟📂 Express.js (Setup, Routing, Middleware)
∟📂 React.js (Components, Hooks, State, Props)
∟📂 Node.js Basics (npm, modules, HTTP server)
∟📂 Backend API Development (REST endpoints)
∟📂 Frontend-State Management (useState, useEffect, Context/Redux)
∟📂 MongoDB + Mongoose (Schemas, Models)
∟📂 Authentication (JWT, bcrypt, Protected Routes)
∟📂 React Router (Navigation, Dynamic Routing)
∟📂 Axios/Fetch API Integration
∟📂 Error Handling & Validation
∟📂 File Uploads (Multer, Cloudinary)
∟📂 Deployment (Vercel Frontend, Render/Heroku Backend, MongoDB Atlas)
∟📂 Projects (Todo App → E-commerce → Social Media Clone)
∟✅ Apply for Fullstack / Frontend Roles
💬 Tap ❤️ for more!
❤26
🔑 Authentication (Login Signup with JWT
Now you learn how real apps handle users and security.
👉 Every real app needs:
• Signup (register)
• Login (authenticate)
• Protected routes
🧠 What is Authentication
Authentication = verifying who the user is
Example:
• Login with email + password
• System checks credentials
• Grants access
🔑 What is JWT
JWT = JSON Web Token
👉 A secure token sent after login
👉 Used to identify user in future requests
Simple flow:
1️⃣ User logs in
2️⃣ Server creates token
3️⃣ Token sent to frontend
4️⃣ Frontend sends token in every request
📦 Install Required Packages
npm install jsonwebtoken bcryptjs
• jsonwebtoken → create token
• bcryptjs → hash passwords
🧩 Step 1 — User Schema
const mongoose = require("mongoose");
const userSchema = new mongoose.Schema({
email: String,
password: String
});
const User = mongoose.model("User", userSchema);
🔐 Step 2 — Signup API
const bcrypt = require("bcryptjs");
app.post("/signup", async (req, res) => {
const hashedPassword = await bcrypt.hash(req.body.password, 10);
const user = new User({
email: req.body.email,
password: hashedPassword
});
await user.save();
res.json({ message: "User registered" });
});
✔ Password is stored securely
✔ Never store plain text password
🔓 Step 3 — Login API
const jwt = require("jsonwebtoken");
app.post("/login", async (req, res) => {
const user = await User.findOne({ email: req.body.email });
if (!user) {
return res.status(400).json({ message: "User not found" });
}
const isMatch = await bcrypt.compare(req.body.password, user.password);
if (!isMatch) {
return res.status(400).json({ message: "Invalid credentials" });
}
const token = jwt.sign(
{ userId: user._id },
"secretkey",
{ expiresIn: "1h" }
);
res.json({ token });
});
✔ Validates user
✔ Generates token
🛡️ Step 4 — Protect Routes (Middleware)
const authMiddleware = (req, res, next) => {
const token = req.headers.authorization;
if (!token) {
return res.status(401).json({ message: "Access denied" });
}
try {
const verified = jwt.verify(token, "secretkey");
req.user = verified;
next();
} catch {
res.status(400).json({ message: "Invalid token" });
}
};
🔒 Step 5 — Use Protected Route
app.get("/profile", authMiddleware, (req, res) => {
res.json({ message: "Welcome user", user: req.user });
});
✔ Only logged-in users can access
🔄 Full Authentication Flow
Signup → Store user
Login → Verify user → Generate token
Frontend stores token
Frontend sends token in requests
Backend verifies token
⚠️ Common Beginner Mistakes
• Storing plain passwords ❌
• Not hashing passwords ❌
• Exposing secret key ❌
• Not verifying token ❌
🧪 Mini Practice Task
Build authentication system:
• POST /signup
• POST /login
• GET /dashboard (protected route)
• Use JWT middleware
Double Tap ♥️ For More
Now you learn how real apps handle users and security.
👉 Every real app needs:
• Signup (register)
• Login (authenticate)
• Protected routes
🧠 What is Authentication
Authentication = verifying who the user is
Example:
• Login with email + password
• System checks credentials
• Grants access
🔑 What is JWT
JWT = JSON Web Token
👉 A secure token sent after login
👉 Used to identify user in future requests
Simple flow:
1️⃣ User logs in
2️⃣ Server creates token
3️⃣ Token sent to frontend
4️⃣ Frontend sends token in every request
📦 Install Required Packages
npm install jsonwebtoken bcryptjs
• jsonwebtoken → create token
• bcryptjs → hash passwords
🧩 Step 1 — User Schema
const mongoose = require("mongoose");
const userSchema = new mongoose.Schema({
email: String,
password: String
});
const User = mongoose.model("User", userSchema);
🔐 Step 2 — Signup API
const bcrypt = require("bcryptjs");
app.post("/signup", async (req, res) => {
const hashedPassword = await bcrypt.hash(req.body.password, 10);
const user = new User({
email: req.body.email,
password: hashedPassword
});
await user.save();
res.json({ message: "User registered" });
});
✔ Password is stored securely
✔ Never store plain text password
🔓 Step 3 — Login API
const jwt = require("jsonwebtoken");
app.post("/login", async (req, res) => {
const user = await User.findOne({ email: req.body.email });
if (!user) {
return res.status(400).json({ message: "User not found" });
}
const isMatch = await bcrypt.compare(req.body.password, user.password);
if (!isMatch) {
return res.status(400).json({ message: "Invalid credentials" });
}
const token = jwt.sign(
{ userId: user._id },
"secretkey",
{ expiresIn: "1h" }
);
res.json({ token });
});
✔ Validates user
✔ Generates token
🛡️ Step 4 — Protect Routes (Middleware)
const authMiddleware = (req, res, next) => {
const token = req.headers.authorization;
if (!token) {
return res.status(401).json({ message: "Access denied" });
}
try {
const verified = jwt.verify(token, "secretkey");
req.user = verified;
next();
} catch {
res.status(400).json({ message: "Invalid token" });
}
};
🔒 Step 5 — Use Protected Route
app.get("/profile", authMiddleware, (req, res) => {
res.json({ message: "Welcome user", user: req.user });
});
✔ Only logged-in users can access
🔄 Full Authentication Flow
Signup → Store user
Login → Verify user → Generate token
Frontend stores token
Frontend sends token in requests
Backend verifies token
⚠️ Common Beginner Mistakes
• Storing plain passwords ❌
• Not hashing passwords ❌
• Exposing secret key ❌
• Not verifying token ❌
🧪 Mini Practice Task
Build authentication system:
• POST /signup
• POST /login
• GET /dashboard (protected route)
• Use JWT middleware
Double Tap ♥️ For More
❤23👍1
What is the main purpose of authentication in web applications?
Anonymous Quiz
6%
A. To design UI
89%
B. To verify user identity
3%
C. To store data
2%
D. To increase speed
What does JWT stand for?
Anonymous Quiz
16%
A. Java Web Token
62%
B. JSON Web Token
18%
C. JavaScript Web Tool
4%
D. JSON Working Token
🤔1
Which library is commonly used to hash passwords in Node.js?
Anonymous Quiz
12%
A. crypto-js
53%
B. bcryptjs
32%
C. hash-node
3%
D. secure-pass
❤2