ETHIOCODE SOFTSELECT ยท LESSON 18
FINAL PROJECT ยท FULL STACK

MERN STACK FULL PROJECT MongoDB ยท Express ยท React ยท Node

แ‹ซแˆˆแ‰ 17 แ‰ตแˆแˆ…แˆญแ‰ถแ‰ฝ แˆแˆ‰ แŠ แŠ•แ‹ต แˆ†แАแ‹! แˆ™แˆ‰ Blog App แŠจแ‹œแˆฎ! ๐Ÿ”ฅ
All 17 lessons combined โ€” build a complete full-stack Blog App from scratch!

๐Ÿƒ MongoDB
โšก Express
โš›๏ธ React
๐ŸŸข Node.js
A
Created by @AppMinds_ET
01๐Ÿ—๏ธ
MERN Stack แˆแŠ•แ‹ตแŠ• แАแ‹?// The 4 Technologies

MERN = 4 technologies แŠ แŠ•แ‹ต แˆ‹แ‹ญ โ€” แˆ™แˆ‰ Web App แˆˆแˆ˜แˆตแˆซแ‰ต แ‹จแˆšแ‹ซแˆตแˆแˆแŒ‰ แˆแˆ‰แˆ! Frontend + Backend + Database แˆแˆ‰ JavaScript แ‰ฅแ‰ป!
MERN = Full stack with ONE language (JavaScript) โ€” same code structure frontend and backend!

๐Ÿ—๏ธ MERN Architecture โ€” แˆ™แˆ‰ แˆแˆตแˆ:

โš›๏ธ React (Frontend)

  • Browser แ‹แˆตแŒฅ แ‹ญแˆฐแˆซแˆ
  • User UI แ‹ซแˆณแ‹ซแˆ
  • API calls แ‹ญแˆแŠซแˆ
  • State แ‹ซแˆตแ‰ฐแ‹ณแ‹ตแˆซแˆ
  • Port: 3000
โŸท
HTTP JSON

โšก Express + Node (Backend)

  • Server แˆ‹แ‹ญ แ‹ญแˆฐแˆซแˆ
  • REST API แ‹ซแ‹˜แŒ‹แŒƒแˆ
  • Auth (JWT) แ‹ญแˆฐแˆซแˆ
  • Business logic
  • Port: 5000
โŸท
Mongoose Query

๐Ÿƒ MongoDB (Database)

  • แ‹แˆ‚แ‰ฅ แ‰‹แˆš แ‹ซแˆตแ‰€แˆแŒฃแˆ
  • Documents (JSON)
  • Collections
  • Atlas (Cloud)
  • Port: 27017
02๐Ÿ“ฐ
Project โ€” Blog App// What We're Building

Blog App โ€” Users register/login, posts แ‹ญแˆแŒฅแˆซแˆ‰แฃ แ‹ซแАแ‰ฃแˆ‰แฃ แ‹ญแˆฐแˆญแ‹›แˆ‰! แˆแˆ‰แˆ MERN technologies แŠ แŠ•แ‹ต แˆ‹แ‹ญ!
A full blog platform โ€” users sign up, log in, create posts, read others' posts, and delete their own.

๐Ÿ”
Auth System
Register, Login, JWT, Protected routes
๐Ÿ“
CRUD Posts
Create, Read, Update, Delete posts
๐Ÿ‘ค
User Profiles
Profile page, own posts
โค๏ธ
Likes
Posts แˆ›แ‹ˆแ‹ฐแ‹ต / Like system
๐Ÿ”
Search & Filter
Posts search by tag or keyword
๐Ÿ“ฑ
Responsive
Mobile + Desktop design
03๐Ÿ“
Folder Structure// Project Layout
๐ŸŸข BACKEND (server/)
server/ โ”œโ”€โ”€ models/ โ”‚ โ”œโ”€โ”€ User.js โ”‚ โ””โ”€โ”€ Post.js โ”œโ”€โ”€ routes/ โ”‚ โ”œโ”€โ”€ auth.js โ”‚ โ””โ”€โ”€ posts.js โ”œโ”€โ”€ middleware/ โ”‚ โ””โ”€โ”€ protect.js โ”œโ”€โ”€ config/ โ”‚ โ””โ”€โ”€ db.js โ”œโ”€โ”€ index.js โ”œโ”€โ”€ .env โ””โ”€โ”€ package.json
โš›๏ธ FRONTEND (client/)
client/ (React) โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ pages/ โ”‚ โ”‚ โ”œโ”€โ”€ Home.jsx โ”‚ โ”‚ โ”œโ”€โ”€ Login.jsx โ”‚ โ”‚ โ””โ”€โ”€ Profile.jsx โ”‚ โ”œโ”€โ”€ components/ โ”‚ โ”‚ โ”œโ”€โ”€ PostCard.jsx โ”‚ โ”‚ โ””โ”€โ”€ Navbar.jsx โ”‚ โ”œโ”€โ”€ context/ โ”‚ โ”‚ โ””โ”€โ”€ AuthContext.jsx โ”‚ โ””โ”€โ”€ App.jsx โ””โ”€โ”€ package.json
04๐Ÿ“ก
API Endpoints// REST API Design

แˆแˆ‰แˆ API Routes โ€” Backend แ‹ญแ‹›แ‰ธแ‹‹แˆ:

METHODPATHDESCRIPTIONAUTH
POST /api/auth/register แŠ แ‹ฒแˆต user แˆแ‹แŒˆแ‰ฃ / Register Public
POST /api/auth/login Login โ†’ JWT token Public
GET /api/posts แˆแˆ‰แˆ posts แ‹ซแˆแŒฃ / All posts Public
GET /api/posts/:id แŠ แŠ•แ‹ต post / Single post Public
POST /api/posts แŠ แ‹ฒแˆต post แแŒ แˆญ / Create post ๐Ÿ” Auth
PUT /api/posts/:id Post แ‰€แ‹ญแˆญ / Update post ๐Ÿ” Auth
DELETE /api/posts/:id Post แˆฐแˆญแ‹ / Delete post ๐Ÿ” Auth
PUT /api/posts/:id/like Post แŠ แ‹ˆแ‹ฐแ‹ต / Like post ๐Ÿ” Auth
05๐Ÿ’ป
แ‹‹แŠ“ Code Pieces// Backend + Frontend
server/models/Post.js โ€” Post Schema
const postSchema = new mongoose.Schema({
  title:   { type: String, required: true, trim: true },
  content: { type: String, required: true },
  author: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User',      // User model แŒ‹แˆญ แ‹ซแ‹ซแ‹ญแ‹›แˆ
    required: true,
  },
  tag:    { type: String, enum: ['tech','life','edu'], default: 'tech' },
  likes:  [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }],
  createdAt: { type: Date, default: Date.now },
}, { timestamps: true });

const Post = mongoose.model('Post', postSchema);
module.exports = Post;
server/routes/posts.js โ€” CRUD + Like
// GET แˆแˆ‰แˆ posts โ€” populate author name
router.get('/', async (req, res) => {
  const posts = await Post.find()
    .populate('author', 'name email') // author info แŒจแˆแˆญ
    .sort({ createdAt: -1 });
  res.json({ success: true, data: posts });
});

// POST แŠ แ‹ฒแˆต post โ€” protect middleware
router.post('/', protect, async (req, res) => {
  const post = await Post.create({
    ...req.body,
    author: req.user.id, // JWT แ‹แˆตแŒฅ แŠซแˆˆ user id
  });
  res.status(201).json({ success: true, data: post });
});

// PUT like/unlike toggle
router.put('/:id/like', protect, async (req, res) => {
  const post = await Post.findById(req.params.id);
  const liked = post.likes.includes(req.user.id);
  if (liked) {
    post.likes = post.likes.filter(id => id != req.user.id); // unlike
  } else {
    post.likes.push(req.user.id);  // like
  }
  await post.save();
  res.json({ success: true, likes: post.likes.length });
});
client/src/pages/Home.jsx โ€” React Frontend
import { useState, useEffect } from 'react';
import { useAuth } from '../context/AuthContext';

function Home() {
  const [posts, setPosts]   = useState([]);
  const [title, setTitle]   = useState('');
  const [content, setContent] = useState('');
  const { user, token }     = useAuth(); // Context แ‰ฐแŒ แ‰…แˆž

  // Mount แˆฒแˆ†แŠ• posts load แ‹ซแ‹ตแˆญแŒ
  useEffect(() => { fetchPosts(); }, []);

  async function fetchPosts() {
    const res  = await fetch('/api/posts');
    const data = await res.json();
    setPosts(data.data);
  }

  async function createPost() {
    await fetch('/api/posts', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${token}`,
      },
      body: JSON.stringify({ title, content }),
    });
    fetchPosts(); // Reload
  }

  return (
    <div>
      {posts.map(p => (
        <PostCard key={p._id} post={p} onLike={likePost} />
      ))}
    </div>
  );
}
06๐ŸŽฎ
Live Blog App Demo!// MERN แˆตแˆœแ‰ต

แˆ™แˆ‰ MERN Blog App แˆแˆณแˆŒ! Posts แแŒ แˆญแฃ Like แŠ แ‹ตแˆญแŒแฃ แˆฐแˆญแ‹! Users แŠ แˆตแ‰ฐแ‹ณแ‹ตแˆญ! Stats แ‹ญแˆ˜แˆแŠจแ‰ต! ๐Ÿ”ฅ
Everything working together โ€” posts, users, likes, delete, live stats and API log!

๐Ÿš€ EthioCode Blog โ€” MERN App
MongoDB Express React Node
๐Ÿ“ Posts
๐Ÿ‘ฅ Users
๐Ÿ“Š Stats
๐Ÿ“ก API Log
REAL-TIME API LOG
โ† Actions แˆฒแ‹ซแ‹ฐแˆญแŒ‰ API calls แ‹ญแ‰ณแ‹ซแˆ‰...
07๐Ÿš€
Deployment โ€” Online แˆ›แˆณแ‹ซ// Go Live!

App แˆฐแˆญแ‰ถ แŠจแˆแŒ€ Internet แˆ‹แ‹ญ แˆˆแˆแˆ‰แˆ แˆ›แˆณแ‹ซ แŒŠแ‹œ! Backend + Frontend + Database แˆแˆ‰ แˆŒแˆŽแ‰ฝ แˆฐแ‹Žแ‰ฝ แˆ›แŒแŠ˜แ‰ต แ‹ญแ‰ฝแˆ‹แˆ‰!
After building, deploy so anyone can access your app from anywhere on the internet!

STEP 01
๐Ÿƒ
MongoDB Atlas
Cloud database โ€” Free tier! Connection string .env แ‹แˆตแŒฅ
mongodb.com/atlas
STEP 02
๐ŸŸข
Backend โ†’ Render
Express server deploy โ€” Free! GitHub connect แ‹ซแ‹ฐแˆญแŒ‹แˆ
render.com
STEP 03
โšก
Frontend โ†’ Netlify
React app deploy โ€” npm run build โ†’ Netlify drop!
netlify.com
STEP 04
๐Ÿ”—
Connect APIs
React แ‹แˆตแŒฅ REACT_APP_API_URL=Render URL แ‰€แˆแŒฅ
.env.production
08๐Ÿ“Œ
แ‹‹แŠ“ แ‹‹แŠ“ แАแŒฅแ‰ฆแ‰ฝ// All Lessons Combined!
โš›๏ธ
React (Frontend) โ€” User แˆšแ‹ซแ‹ซแ‹ แˆแˆ‰

Components, Props, useState, useEffect, Context, Router โ€” แˆแˆ‰แˆ แŠ แ‰ฅแˆฎ แˆฐแˆญแ‰ถ แ‰†แŠ•แŒ† UI แ‹ญแˆฐแˆซแˆ‰!
Lessons 10-14: React is the face of the app โ€” what users see and interact with.

๐ŸŸข
Node.js + Express (Backend) โ€” Logic แˆแˆ‰

REST API routes, Middleware, Auth, JSON responses โ€” React แŠ• แˆแˆ‰ แ‹ญแˆฐแŒฃแˆ!
Lesson 15: Express handles all the business logic and serves data to React.

๐Ÿƒ
MongoDB + Mongoose (Database) โ€” แ‹แˆ‚แ‰ฅ แˆแˆ‰

Documents, Schema, CRUD, Populate, Query โ€” แˆแˆ‰แˆ แ‹แˆ‚แ‰ฅ แ‰‹แˆš แˆ†แŠ– แ‹ญแ‰€แˆแŒฃแˆ!
Lesson 16: MongoDB stores all data permanently โ€” users, posts, likes, everything.

๐Ÿ”
JWT + bcrypt (Security) โ€” แ‹ฐแˆ…แŠ•แАแ‰ต

Password hash, Token auth, Protected routes โ€” แˆแˆ‰แˆ แ‹ฐแˆ…แŠ•แАแ‰ฑ แŒ แ‰ฅแ‰† แ‹ญแˆฐแˆซแˆ‰!
Lesson 17: Security layer โ€” bcrypt hashes passwords, JWT protects routes.

09๐ŸŽฏ
Final Quiz// แˆแˆ‰แˆ แ‰ตแˆแˆ…แˆญแ‰ถแ‰ฝ!
โ“ MERN Stack แ‹แˆตแŒฅ แ‹แˆ‚แ‰ฅ (data) แ‰‹แˆš แ‹จแˆšแ‰€แˆ˜แŒ แ‹ แ‹จแ‰ฑ technology แ‹แˆตแŒฅ แАแ‹?
In the MERN Stack, which technology stores data permanently?
A React โ€” Browser แ‹แˆตแŒฅ useState
B Express โ€” Server memory แ‹แˆตแŒฅ array
C MongoDB โ€” Database documents โœ…
D Node.js โ€” File system แ‹แˆตแŒฅ
๐ŸŽ‰ แŠญแแˆ 18 โ€” MERN STACK!

็ฅ่ดบ! Congratulations! 18 แ‰ตแˆแˆ…แˆญแ‰ถแ‰ฝ แŒจแˆจแˆฐแˆ…! HTML โžœ CSS โžœ JS โžœ React โžœ Node โžœ MongoDB โžœ Auth โžœ Full Stack! ๐Ÿš€

แ‰€แŒฃแ‹ญ: TypeScript, Next.js, Docker, AWS... โœจ

๐ŸŒ ethiocodesoftselect.netlify.app

โœˆ @EthioCodeSoftSelect

แ‰ปแŠ“แˆ‰แŠ• แŠญแˆแ‰ฑ โ†’ Join ๐Ÿš€
โœ๏ธ Created by@AppMinds_ET