Key takeaways
- Builds one real app, a task manager, from the Mongoose model to the React screen.
- Shows the full login flow: bcrypt hash, JWT, axios interceptor, protect middleware and a private route.
- Includes a troubleshooting table for CORS errors, Network Error, 404 on API calls, undefined req.body and missing VITE_ env values.
- Explains where to deploy each part: MongoDB Atlas, Render or Railway, and Vercel or Netlify.
About these MERN stack notes
MERN is a full stack built only with JavaScript: MongoDB stores data, Express and Node.js run the API, and React builds the screens. Because JSON flows from the database to the browser without changes, one language covers the whole app. These notes explain the stack with a food delivery example (React is the app you tap, Express on Node is the manager taking orders, MongoDB is the register) and then build a working app, so every concept is shown in the file where it really lives.
Please note: these are original Uncodemy study notes written in a handwritten style. They are not official documentation of MongoDB, the OpenJS Foundation, Express or Meta. Tools and versions change, so check the official docs linked below when something behaves differently on your machine.
What's inside the MERN stack notes
The PDF has 13 numbered sections across 11 pages. Here is what each one covers.
The four parts of the stack
What M, E, R and N do, a diagram of ports 5173, 5000 and 27017, a table of each part's job and main tools, and why teams choose MERN.
Project setup and folders
Tools to install, a two-app folder layout (server and client in one repo) and the exact npm commands to set up each side.
Backend with Express and Mongoose
The model, controller and route pattern, config/db.js and server.js, a sample .env file and a Mongoose model that links to another collection.
REST API design
Routes, actions and status codes for tasks, one error shape, search and pagination with skip and limit, and testing every route in Postman first.
React frontend essentials
Components, props, useState, useEffect, keys and controlled inputs, a reusable useFetch hook, and updating state without changing it directly.
Routing and forms in React
BrowserRouter, Routes, Link, useParams and useNavigate, and one state object for a whole form.
Connecting frontend to backend
Why CORS is needed between the two ports, one axios instance with a VITE_API_URL, fetch versus axios, and a table of common connection errors with their causes.
Mini project, task manager
Complete controllers and routes for listing, adding, toggling and deleting tasks, and the React App component that calls them.
Login and protected pages
Register and login controllers with bcrypt and JWT, a protect middleware, an axios interceptor that sends the token, and a PrivateRoute for logged-out users.
Global state with Context
An AuthContext with login and logout, and a table showing when to use useState, useReducer, Context, Redux Toolkit or Zustand, and TanStack Query.
Uploads and extra features
Image upload with multer, storing files on Cloudinary or S3, and tools for real-time chat, emails, payments, search, charts and input checks.
Deployment and best practices
Where and how to deploy the database, backend and frontend, the CORS and React Router rewrite changes for production, and a best practices table.
Projects and practice
Six projects (task manager, notes app with login, blog, e-commerce store, chat app, social media mini), a common mistakes table and ten practice questions.
How this differs from our other full stack pages
The Node.js Notes PDF stays on the server: the runtime, event loop, modules, Express and MongoDB in depth. These MERN notes connect the server to React and build a complete app with login. MERN Stack vs MEAN Stack helps you choose a stack, and the Full Stack Developer Roadmap PDF plans what to learn and when.
How to study MERN with these notes
Follow the notes in order and keep one repository open, because each section adds files to the same task manager app.
- Set up the server and client folders exactly as in section 2 and run both with npm run dev in two terminals.
- Finish the API and test it in Postman before writing any React code, so later bugs are clearly frontend bugs.
- Build the task manager from section 8 by typing it, not copying it, then add login from section 9.
- Deploy it early; a live link teaches you about environment variables, CORS and rewrites.
When something breaks, check the troubleshooting table in section 7 first. Most beginner MERN errors are the same five problems, and fixing them yourself is how you learn the stack.
Code patterns and definitions to memorise
- Model, controller, route: the backend pattern for every resource.
- Routes and codes: GET 200, POST 201, PATCH 200, DELETE 204, plus 400, 401 and 404 for errors.
- Never mutate state: use spread, filter and map to make a new array or object.
- The login flow: bcrypt hash on register, JWT on login, Bearer header on every call, protect middleware on the server.
- Vite env variables must start with VITE_ and need a dev server restart.
Common mistakes beginners make
- Pushing the .env file to GitHub.
- Forgetting to await database calls.
- Changing React state directly instead of making a copy.
- Sending the password hash back to React instead of using .select('-password').
- Hardcoding localhost URLs that break after deployment.
- Checking login only in React and leaving API routes unprotected.
Interview focus: MERN topics asked most
MERN interviews for freshers usually ask you to explain the flow of one request through the whole stack, then go deeper on one layer.
- The role of each letter and the request flow from React to MongoDB.
- Express middleware and a protect middleware for JWT.
- Mongoose versus the plain driver, and SQL versus MongoDB.
- CORS: why it happens and how to fix it.
- Context API versus Redux, and how to deploy a MERN app.
Typical interview and viva questions
- What is the MERN stack and what does each part do?
- Explain the full flow of a request from React to MongoDB and back.
- Why is CORS needed and how do you fix it?
- What is middleware in Express? Write a protect middleware.
- When would you choose MongoDB over a SQL database?
- How does JWT login work in a MERN app?
- When would you use Context and when would you use Redux?
A deployed project with login is the strongest answer to most MERN interview questions, so keep your live link and repository ready.
A 7-day plan with the MERN stack notes
- Day 1: The four parts of the stack, project setup and folders. Install tools and create both apps.
- Day 2: Backend with Express and Mongoose, REST API design. Build and test the tasks API in Postman.
- Day 3: React frontend essentials, routing and forms. Build the pages and the form.
- Day 4: Connecting frontend to backend and the task manager mini project. Make the full CRUD work.
- Day 5: Login and protected pages. Add register, login, the protect middleware and a private route.
- Day 6: Global state with Context, uploads and extra features. Add an AuthContext and one extra feature.
- Day 7: Deployment and best practices. Deploy all three parts, then answer the ten practice questions from memory.
After the first app works, pick a second project from the list, such as the blog or chat app, and build it without the notes open.
Who these notes are for
- Students who want to become MERN or JavaScript full stack developers.
- Freshers preparing for MERN, React or Node.js interviews.
- Frontend learners who know React and want to add a backend.
- Final-year students building a full stack project for their portfolio.
You should know basic JavaScript (variables, functions, arrays, objects and promises) before you start. For more backend depth, read the Node.js notes linked below.
Download MERN Stack Notes PDF
MERN Stack Notes PDF: MongoDB, Express, React, Node
The PDF carries the same content as this page in a clean, print-ready layout, so you can read it offline and keep it for revision.
11 pages · 153 KB · PDF · Updated 5 Nov 2026