Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Projects › Intermediate

Blog Platform with Authentication

A full MERN app where users sign up, write Markdown posts, comment and like — the project most MERN interviews ask about.

Level: Intermediate · Time: 2 weeks · Tech stack: MongoDB, Express, React, Node.js, JWT

Features to build

What you will learn

Step-by-step guide

1. Backend structure

models/ (User, Post, Comment) · routes/ · middleware/auth.js · controllers/.

2. Auth

Hash passwords with bcrypt, return a JWT on login, and verify it in a middleware:

export function protect(req, res, next) {
  const token = req.headers.authorization?.split(' ')[1];
  try { req.user = jwt.verify(token, process.env.JWT_SECRET); next(); }
  catch { res.status(401).json({ message: 'Please log in' }); }
}

3. Posts API with ownership checks

PATCH /api/posts/:id must check post.author.equals(req.user.id) — otherwise anyone can edit anyone's post (an IDOR bug).

4. Pagination and search

const q = search ? { $text: { $search: search } } : {};
const posts = await Post.find(q).sort({ createdAt: -1 }).skip((page - 1) * 10).limit(10).populate('author', 'name');

Add a text index on title and body.

5. Images

Upload with multer to Cloudinary (free tier) and store only the URL.

6. React frontend

React Router pages, an AuthContext holding the user, axios with an interceptor adding the token, and a Markdown editor (react-markdown for preview). Sanitize HTML.

7. Deploy

Backend on Render, frontend on Vercel, database on MongoDB Atlas. Set CORS to your frontend URL only.

Level it up

On your resume

Learn on Codify