Skip to content

mithleshprasad/Learn-Coding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MERN Stack Interview Preparation README

By Mithlesh Prasad


📌 Overview

This guide contains:

  • MERN Stack Interview Questions
  • Deep Explanations
  • Real-world Examples
  • Project-based Answers
  • System Design Basics
  • React + Node.js + Database Concepts
  • DevOps Basics
  • HR Round Preparation

This README is specially prepared according to:

  • Your Resume
  • Your Experience
  • Current Job Description

📚 Table of Contents

  1. JavaScript Fundamentals
  2. React.js
  3. Next.js
  4. Node.js
  5. Express.js
  6. MongoDB
  7. SQL / PostgreSQL
  8. Redis
  9. Authentication (JWT)
  10. System Design
  11. DevOps Basics
  12. Docker
  13. CI/CD
  14. Real Project Questions
  15. Machine Coding Round
  16. HR Questions
  17. Final Interview Tips

1️⃣ JavaScript Fundamentals


❓ What is Closure?

Definition

A closure is a function that remembers variables from its outer scope even after the outer function has finished execution.


Example

function outer() {
  let count = 0;

  return function inner() {
    count++;
    console.log(count);
  };
}

const counter = outer();

counter(); // 1
counter(); // 2

Real-world Use

Closures are used in:

  • Data hiding
  • React hooks
  • Event handlers
  • Debouncing
  • Timers

❓ What is Hoisting?

Definition

JavaScript moves declarations to the top before execution.


Example

console.log(a);

var a = 10;

Internally:

var a;
console.log(a); // undefined
a = 10;

❓ Difference between == and ===

== ===
Loose comparison Strict comparison
Checks value Checks value + type

Example

console.log(5 == "5"); // true
console.log(5 === "5"); // false

❓ What is Event Loop?

Deep Explanation

Node.js is single-threaded but handles asynchronous tasks using:

  • Call Stack
  • Web APIs
  • Callback Queue
  • Event Loop

Flow

Call Stack → Web APIs → Callback Queue → Event Loop

Example

console.log("Start");

setTimeout(() => {
  console.log("Timeout");
}, 0);

console.log("End");

Output:

Start
End
Timeout

2️⃣ React.js


❓ What is Virtual DOM?

Explanation

Virtual DOM is a lightweight copy of the real DOM.

React compares:

  • Previous Virtual DOM
  • New Virtual DOM

Then updates only changed elements.


Benefits

  • Faster rendering
  • Better performance
  • Reduced DOM operations

❓ What are React Hooks?

Hooks allow functional components to use:

  • State
  • Lifecycle methods
  • Context

useState Example

import { useState } from "react";

function Counter() {
  const [count, setCount] = useState(0);

  return (
    <button onClick={() => setCount(count + 1)}>
      {count}
    </button>
  );
}

❓ useEffect Deep Explanation

Used for:

  • API calls
  • Event listeners
  • Timers
  • Side effects

Example

useEffect(() => {
  fetchData();
}, []);

Dependency Array

Dependency Meaning
[] Runs once
[count] Runs when count changes
No array Runs every render

❓ React Performance Optimization

Techniques

1. React.memo

export default React.memo(Component);

Prevents unnecessary re-renders.


2. useMemo

const value = useMemo(() => expensiveCalculation(), []);

Caches expensive calculations.


3. useCallback

const handleClick = useCallback(() => {}, []);

Caches functions.


4. Lazy Loading

const Dashboard = React.lazy(() => import("./Dashboard"));

Loads component only when needed.


3️⃣ Next.js


❓ Why Next.js?

Advantages

  • SEO support
  • SSR
  • SSG
  • Faster performance
  • File-based routing

❓ CSR vs SSR vs SSG

Type Meaning
CSR Client-side rendering
SSR Server-side rendering
SSG Static site generation

Example SSR

export async function getServerSideProps() {
  return {
    props: {}
  };
}

4️⃣ Node.js


❓ What is Node.js?

Node.js is a JavaScript runtime built on Chrome V8 engine.

Used for:

  • APIs
  • Real-time apps
  • Backend systems

❓ What is Middleware?

Middleware runs between request and response.


Example

app.use((req, res, next) => {
  console.log("Middleware");
  next();
});

❓ Types of Middleware

  • Authentication
  • Logging
  • Validation
  • Error handling

❓ JWT Authentication Flow


Step-by-step

Login → Generate Token → Send Token → Verify Token

Example

Generate Token

const token = jwt.sign(
  { id: user._id },
  SECRET_KEY,
  { expiresIn: "1d" }
);

Verify Token

jwt.verify(token, SECRET_KEY);

5️⃣ Express.js


❓ REST API Example

app.get("/users", getUsers);

app.post("/users", createUser);

app.put("/users/:id", updateUser);

app.delete("/users/:id", deleteUser);

❓ Best Practices

  • Proper status codes
  • Validation
  • Error handling
  • Pagination
  • Authentication
  • Rate limiting

6️⃣ MongoDB


❓ SQL vs NoSQL

SQL NoSQL
Tables Documents
Structured Flexible
Relations Schema-less

❓ Mongoose Schema Example

const userSchema = new mongoose.Schema({
  name: String,
  email: String
});

❓ What is Indexing?

Indexes improve search speed.


Example

userSchema.index({ email: 1 });

❓ Aggregation Example

User.aggregate([
  {
    $match: {
      age: { $gt: 18 }
    }
  }
]);

7️⃣ PostgreSQL / SQL


❓ Joins

Join Meaning
INNER JOIN Matching records
LEFT JOIN All left records
RIGHT JOIN All right records

Example

SELECT users.name, orders.total
FROM users
INNER JOIN orders
ON users.id = orders.user_id;

8️⃣ Redis


❓ What is Redis?

Redis is an in-memory database used for:

  • Caching
  • Sessions
  • Rate limiting

❓ Why Redis?

Without Redis:

Request → Database → Response

With Redis:

Request → Redis Cache → Fast Response

Example

await redis.set("users", JSON.stringify(data));

9️⃣ System Design


❓ How to Design Scalable APIs?

Architecture

Client
 ↓
Load Balancer
 ↓
API Server
 ↓
Redis Cache
 ↓
Database

Important Concepts

  • Caching
  • Pagination
  • Indexing
  • Load balancing
  • Rate limiting
  • Queue systems

❓ Monolith vs Microservices

Monolith Microservices
Single app Multiple services
Easier initially More scalable

1️⃣0️⃣ Docker


❓ What is Docker?

Docker packages application + dependencies into containers.


Dockerfile Example

FROM node:18

WORKDIR /app

COPY . .

RUN npm install

CMD ["npm", "start"]

1️⃣1️⃣ CI/CD


❓ What is CI/CD?

CI CD
Continuous Integration Continuous Deployment

GitHub Actions Example

name: Deploy

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

1️⃣2️⃣ Real Project Questions


❓ Explain Swan Investment Dashboard

Answer

  • Financial admin dashboard
  • JWT authentication
  • RBAC
  • Payment integration
  • Optimized queries
  • Secure transactions

❓ Explain ERP Migration

Answer

  • Migrating monolith → microservices
  • Independent services
  • Docker deployment
  • Redis caching
  • CI/CD automation

1️⃣3️⃣ Machine Coding Round


Common Questions

  • Todo App
  • Pagination
  • Search Filter
  • Debounce Search
  • CRUD App
  • Authentication UI

Debounce Example

function debounce(fn, delay) {
  let timer;

  return function (...args) {
    clearTimeout(timer);

    timer = setTimeout(() => {
      fn(...args);
    }, delay);
  };
}

1️⃣4️⃣ HR Questions


❓ Why should we hire you?

Answer

I already have practical experience working on production-level MERN applications, performance optimization, CI/CD deployment, and scalable backend systems. I can contribute quickly with minimal guidance.


❓ Why are you switching?

Answer

I’m looking for larger technical challenges, better growth opportunities, and an environment where I can improve my architecture and backend skills further.


❓ Your Strengths

  • Problem solving
  • Full-stack ownership
  • Performance optimization
  • Fast learning
  • Team collaboration

1️⃣5️⃣ Final Interview Tips


✅ Before Interview

Revise:

  • JWT
  • React hooks
  • MongoDB queries
  • SQL joins
  • Redis
  • Docker basics
  • Event loop
  • Async await

✅ During Interview

  • Speak slowly
  • Explain real examples
  • Mention optimization results
  • Explain architecture clearly
  • Think before answering

✅ Avoid

  • Long unnecessary answers
  • Memorized definitions
  • Saying “I don’t know anything”

Instead say:

“I haven’t used it deeply yet, but I understand the basics.”


🎯 Final Advice

Your strongest points:

  • Real-world projects
  • Performance optimization
  • MERN stack experience
  • DevOps exposure
  • Production deployments

Main focus now:

  • Communication
  • Confidence
  • System design basics
  • JavaScript fundamentals

⭐ Author

Mithlesh Prasad Full Stack MERN Developer React.js | Node.js | MongoDB | DevOps | AWS | Docker


DSA Learning Hub 🚀

DSA Learning Hub is an interactive platform designed to help learners explore and master Data Structures and Algorithms (DSA). It provides examples, API integrations, and will soon include interactive visualizations for various topics such as arrays, strings, linked lists, stacks, graphs, and more.


Features

🌟 Current Features:

1. Sorting Algorithms

  • Bubble Sort: Show gradual bubbling of largest elements to the end
  • Merge Sort: Visualize the divide-and-conquer approach with splitting and merging
  • Quick Sort: Demonstrate pivot selection and partitioning
  • Insertion Sort: Show building the sorted array one element at a time
  • Selection Sort: Visualize repeatedly finding the minimum element

2. Graph Algorithms

  • Dijkstra's Algorithm: Animate finding shortest paths with a priority queue
  • A Search*: Show heuristic-based pathfinding with open/closed sets
  • Breadth-First Search: Demonstrate layer-by-layer exploration
  • Depth-First Search: Visualize backtracking through nodes
  • Minimum Spanning Tree (Prim's/Kruskal's): Show tree growing process

3. Dynamic Programming

  • Fibonacci Sequence: Visualize recursion tree vs. memoized/dp approach
  • Knapsack Problem: Show decision tree and DP table filling
  • Longest Common Subsequence: Animate matrix filling process

4. Tree Traversals

  • Inorder/Preorder/Postorder: Animate different traversal orders
  • AVL Tree Rotations: Show balancing operations
  • Red-Black Tree Insertions: Demonstrate color flipping and rotations

5. String Matching

  • Naive String Search: Show brute-force character comparisons
  • KMP Algorithm: Visualize prefix function and pattern shifting
  • Boyer-Moore: Demonstrate bad character and good suffix rules

6. Numerical Algorithms

  • Euclidean Algorithm: Animate GCD calculation
  • Sieve of Eratosthenes: Show prime number filtering
  • Fast Exponentiation: Demonstrate divide-and-conquer power calculation

7. Machine Learning Basics

  • K-Nearest Neighbors: Show decision boundaries forming
  • Linear Regression: Animate gradient descent convergence
  • K-Means Clustering: Visualize centroid movement

8. Cryptography

  • RSA Encryption: Demonstrate key generation and modular arithmetic
  • Caesar Cipher: Show letter shifting visualization
  • Diffie-Hellman: Animate key exchange process

Implementation Tips:

  1. Common UI Components you can reuse:

    • Array/graph visualization canvas
    • Speed controls
    • Step-by-step explanation panel
    • Algorithm comparison tabs
    • Pseudocode display synchronized with visualization
  2. Visual Elements to include:

    • Color-coding for different states (visited, current, etc.)
    • Pointer indicators for current positions
    • Animated transitions between steps
    • Performance metrics (time/space complexity)
  3. Educational Features:

    • Best/worst case scenario toggles
    • Big-O complexity graph comparison
    • Real-world use case examples
    • Common pitfalls/misconceptions

🔜 Coming Soon:

  • Interactive examples for arrays, strings, linked lists, stacks, and graphs.
  • Topic-wise tutorials and explanations.
  • Visualizations for DSA concepts.
  • Practice problems and solutions.

Project Structure

root/
│
├── index.html       # Main HTML file for the website
├── server.js        # Express server for API endpoints
├── README.md        # Project documentation
└── styles.css       # (Optional) External stylesheet for custom styles

API Endpoints

/info

  • Method: GET
  • Description: Returns a message indicating the API server is running successfully.
  • Sample Response:
    {
      "status": true,
      "message": "JSON server run successful!",
      "server": "Express"
    }

/array

  • Method: GET
  • Description: Returns an array and its reversed version.
  • Sample Response:
    {
      "status": true,
      "array": "Originally array 1,2,3,4,5,6 <br> Reversed array: 6,5,4,3,2,1"
    }

How to Run the Project

Prerequisites

  • Node.js installed on your machine.
  • A text editor (e.g., VSCode).

Steps

  1. Clone the Repository:

    git clone <repository-url>
    cd dsa-learning-hub
  2. Install Dependencies:

    npm install
  3. Run the Server:

    node server.js

    The server will start at http://localhost:8045.

  4. Open the Website:

    • Open index.html in a browser or serve it using a tool like Live Server.

Contribution

Contributions are welcome! Here's how you can help:

  1. Fork the repository.
  2. Create a new branch for your feature/bug fix.
  3. Submit a pull request with detailed information about your changes.

License

This project is licensed under the MIT License. Feel free to use, modify, and distribute it as you like.

///////////////////////////////////////////////////////////////////////////////////////////////////////////// 🔥 Alright Mithlesh! Here is the COMPLETE Day-by-Day DevOps Plan (40 Days) — the most practical, industry-ready roadmap made specifically for you as a MERN developer.

👇 Save this. Follow this. You will become DevOps Engineer in 40 Days.


🚀 DAY-BY-DAY DEVOPS PLAN (40 Days)

No theory bullshit. Only practical + real projects.


WEEK 1 — Linux + Git + DevOps Fundamentals

Day 1 — Linux Basics

  • Install Ubuntu (Dual Boot / WSL2)

  • Learn:

    • ls, cd, pwd, mkdir, rm
    • cat, touch, less
    • sudo, apt update, apt install
  • Practice navigation like a pro.

Day 2 — Linux Intermediate

  • File permissions: chmod, chown
  • Processes: ps, kill, top, htop
  • Services: systemctl start/stop/status
  • Networking: ping, curl, wget, ss -tulpn

Day 3 — Linux Advanced

  • Shell scripting basics:

    • variables
    • loops
    • functions
  • Write a script:

    #!/bin/bash
    echo "Server Time: $(date)"

Day 4 — Git Basics

  • Git clone / add / commit / push
  • Branching
  • Merging
  • .gitignore

Day 5 — Git Advanced

  • Git rebase
  • Git stash
  • Git cherry-pick
  • Git bisect

Day 6 — DevOps Fundamentals

  • What is DevOps
  • Continuous Delivery vs Deployment
  • CI vs CD
  • Containers
  • Infra-as-code
  • Cloud
  • Monitoring

Day 7 — Mini Project

Deploy a Node.js API on local Linux + push to GitHub.


WEEK 2 — AWS Basics + Deploy Backend on EC2

Day 8 — Create AWS Account

  • Setup free tier
  • Enable MFA
  • Create IAM user
  • Install AWS CLI

Day 9 — EC2

  • Launch Ubuntu EC2 instance
  • SSH using PEM file
  • Install Node.js, npm

Day 10 — Deploy First App on EC2

  • Clone MERN backend
  • Install + run via PM2
  • Test public IP

Day 11 — Install + Configure NGINX

  • Reverse proxy
  • Serve Node.js backend from port 80

Day 12 — MongoDB Setup

  • Use MongoDB Atlas
  • Connect from EC2
  • Fix IP allowlist

Day 13 — S3 Basics

  • Create bucket
  • Upload/download files
  • Learn public & private access
  • Learn bucket policies

Day 14 — AWS IAM

  • Users
  • Groups
  • Roles
  • Policies
  • Attach EC2 Role

🎯 Project Result: MERN backend deployed manually on AWS EC2 using NGINX + PM2


WEEK 3 — Docker (Most Important for DevOps)

Day 15 — Docker Basics

  • Containers vs VMs
  • Install Docker
  • Docker images
  • Docker containers
  • Docker Hub

Day 16 — Dockerfile

Write Dockerfile for Node.js app:

FROM node:18
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["node","index.js"]

Run container:

docker build -t myapp .
docker run -p 3000:3000 myapp

Day 17 — Docker Compose

  • Multi-container app
  • Backend + MongoDB

Example:

services:
  api:
    build: .
    ports:
      - 3000:3000
    depends_on:
      - db
  db:
    image: mongo
    ports:
      - 27017:27017

Day 18 — Docker Volumes

  • Persistent data
  • Bind mount vs volumes

Day 19 — Optimize Dockerfile

  • Multi-stage builds
  • Smaller image sizes

Day 20 — Docker on AWS EC2

  • Install Docker on EC2
  • Pull your image
  • Run container on cloud

Day 21 — Docker Project

🎯 Complete: Dockerize full MERN app + run on EC2 + push image to Docker Hub


WEEK 4 — CI/CD (AWS CodePipeline or GitHub Actions)

Day 22 — CI/CD Basics

  • What is CI?
  • What is CD?
  • Build → Test → Deploy pipelines

Day 23 — GitHub Actions

Create .github/workflows/deploy.yml

Triggers on push:

name: Node CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest

Day 24 — Build Docker On GitHub Actions

  • Build
  • Tag
  • Push to Docker Hub
  • Or push to AWS ECR

Day 25 — AWS ECR

  • Create ECR repo
  • Push Docker images using GitHub Actions

Day 26 — Deploy to EC2 via CI/CD

  • SSH into EC2 from GitHub Actions
  • Pull new Docker image
  • Restart container

Day 27 — AWS CodePipeline

  • GitHub → CodeBuild → ECR → ECS
  • Buildspec.yml

Day 28 — CI/CD Project

🎯 Complete: Fully automated CI/CD: On every push → Build Docker → Deploy to EC2


WEEK 5 — Terraform (Infra as Code)

Day 29 — Terraform Basics

  • Install Terraform
  • Providers
  • Resources
  • Variables

Day 30 — Create EC2 using Terraform

Create main.tf:

resource "aws_instance" "web" {
  ami           = "ami-12345"
  instance_type = "t2.micro"
}

Day 31 — Security Groups + IAM with Terraform

  • Create SG
  • Create IAM role
  • Outputs

Day 32 — Terraform Remote Backend

Use S3 + DynamoDB lock

Day 33 — Terraform Modules

Break infra into modules.

Day 34 — Full Infra

Build:

  • EC2
  • S3
  • VPC
  • IAM
  • Security groups

via one command:

terraform apply

Day 35 — Terraform Project

🎯 Complete: MERN app + EC2 + IAM + S3 fully created through Terraform


WEEK 6 — Monitoring, Scaling, Real Production

Day 36 — CloudWatch

  • Logs
  • Metrics
  • Alarms
  • SNS alerts (email & SMS)

Day 37 — Auto Scaling

  • Create launch template
  • Create ASG
  • Test scaling

Day 38 — Load Balancers

  • ALB
  • Target Groups
  • Health checks

Day 39 — Serverless

  • Lambda basics
  • Connect lambda to API Gateway

Day 40 — Final PRODUCTION Project

🎯 Deploy a Production-grade MERN App:

  • Docker
  • CI/CD
  • ECS or EC2
  • Terraform
  • Logging
  • Load Balancer
  • Auto Scaling
  • HTTPS + SSL
  • Monitoring

This is 100% real DevOps project.


🔥 If you want, I will also give you:

✔ Complete DevOps Portfolio Projects (3 real projects)

✔ GitHub Repo Structure for DevOps

✔ Resume for DevOps Engineer

✔ 100+ DevOps Interview Questions

✔ All scripts (Dockerfile, Terraform, CI/CD YAML) ready-to-use

//////////////////////////////////////////////////////////////////////////////

Author

Built with ❤️ by Mithlesh Prasad.


Releases

No releases published

Packages

 
 
 

Contributors

Languages