{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreihc7nwvpnyrqrpvagbeajzlpooz442g4366rwc2fde44dokxvvjhy",
    "uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mopkviegm4g2"
  },
  "coverImage": {
    "$type": "blob",
    "ref": {
      "$link": "bafkreihmqzxeqpph2oq2g6543sdifi6n42sskjbrkknfwmno7vitiesvtm"
    },
    "mimeType": "image/webp",
    "size": 158000
  },
  "path": "/ali_hamza_589ec7b3eb6688d/day-47-of-learning-mern-stack-5dpc",
  "publishedAt": "2026-06-20T09:07:52.000Z",
  "site": "https://dev.to",
  "tags": [
    "express",
    "node",
    "backend",
    "architecture"
  ],
  "textContent": "Hello Dev Community! 👋\n\nIt is officially **Day 47** of my daily coding run toward full-stack MERN mastery! Over the past few weeks, my Express.js server was growing quickly with custom routes, JSON handling, and rendering scripts. But as any senior dev will tell you: putting all your backend logic inside a single `index.js` file is a fast track to technical debt.\n\nToday, I advanced straight into **Prashant Sir's (Complete Coding) curriculum** to implement the golden standard of software organization: **MVC (Model-View-Controller) Architecture for clean code separation!**\n\n##  🧠 The Architectural Breakdown of MVC\n\nMVC is a structural software design pattern that splits an application's concerns into three distinct decoupled layers. Here is how I broke down my monolithic file today:\n\n###  1. Routes Directory (`/routes`)\n\nMoved all my endpoint paths out of the main server setup. The routes file has only one responsibility now: capturing incoming network paths (like `router.get(\"/api/users\", ...)` ) and mapping them instantly to the correct controller. No business logic lives here anymore!\n\n###  2. Controllers Layer (`/controllers`)\n\nThis is the operational command center. I isolated all the raw middleware functions, conditional evaluations, data finding metrics, and response execution handling cleanly inside independent, exported functions:\n\n\n    javascript\n    // /controllers/user.js\n    const users = require(\"../MOCK_DATA.json\");\n\n    const handleGetAllUsers = (req, res) => {\n        return res.json(users);\n    };\n\n    module.exports = { handleGetAllUsers };\n",
  "title": "Day 47 of Learning MERN Stack"
}