Inside the Code: A Developer’s Guide to My Node.js Blog

Created on Sunday 27 July 2025 at 01:17 pm | Estimated Read Time: 2 minutes
All Articles

Inside the Code: A Developer’s Guide to My Node.js Blog

This blog isn’t powered by WordPress, Ghost, or any third-party CMS. I built it using Node.js, Express, MongoDB, and EJS all from scratch.

Here’s a peek under the hood at how it works.


🛠️ Tech Stack Overview


📁 Project Structure

├── server.js
├── routes/
│   └── articles.js
├── views/
│   └── articles/
│       ├── index.ejs
│       └── show.ejs
├── models/
│   └── article.js
├── public/
│   └── scripts/
│       └── NumberFormatter.js

🔁 The Main Flow

1. Home Route (/)

In server.js:

app.get('/', async (req, res) => {
  const articles = await Article.find().sort({ createdAt: 'desc' });
  res.render('articles/index', {
    articles,
    formatWithAbbreviation
  });
});

2. Article Routes (/articles)

In routes/articles.js, I handle:

EJS templates handle the views, and Mongoose manages the database logic.


🧮 Formatting Numbers Smartly

I wrote a tiny utility: NumberFormatter.js.

// Example usage
formatWithAbbreviation(12400); // "12.4K"

This keeps the blog clean and modern, especially for stats like views or likes.


🎨 Static Assets

app.use('/public', express.static('./public'));

All my CSS, JS, and media live in /public, and Express serves them directly.


🔐 Dev-Friendly Extras


🧠 Final Thoughts

This blog isn’t just a writing platform—it’s a playground for learning full-stack web development. I control every part of the stack, from server logic to templating and deployment.

If you’re thinking of building your own blog from scratch, I say go for it. It’s the best way to truly understand how the web works.