🚀 Overview
Blogify is a full-stack blogging platform where users can sign up, log in, write blogs, upload cover images, comment on posts, and read blogs. It includes JWT authentication, cookie-based sessions, Multer uploads, and a structured MVC-like architecture.
⭐ Features
🔐 User Authentication (JWT + Cookies)
📝 Create, Read, Update & Delete Blogs
💬 Comment System (Add comments on blogs)
🖼 Cover Image Upload using Multer
🗂 Clean Folder Structure (MVC-inspired)
🧩 Reusable EJS Partials
🚀 Fast & Lightweight Node.js backend
🗂 Folder Structure
BLOG_APP
├─ middlewares/
│ └─ authentication.js
├─ models/
│ ├─ blog.js
│ ├─ comment.js
│ └─ user.js
├─ node_modules/
├─ public/
│ ├─ images/
│ └─ uploads/
├─ routes/
│ ├─ blog.js
│ └─ user.js
├─ service/
│ └─ authentication.js
├─ views/
│ ├─ partials/
│ │ ├─ head.ejs
│ │ ├─ nav.ejs
│ │ └─ script.ejs
│ ├─ addBlog.ejs
│ ├─ blog.ejs
│ ├─ home.ejs
│ ├─ signin.ejs
│ └─ signup.ejs
├─ .env
├─ app.js
├─ package.json
└─ package-lock.json
⚙️ Tech Stack (with logos)
| Tool Used | Category |
|---|---|
| Node.js | Server runtime. |
| Express.js | Web framework. |
| MongoDB | Database (via Mongoose). |
| EJS | Templating engine. |
| JWT | Authentication tokens. |
| Multer | File upload middleware. |
| bcrypt | Password hashing. |
| dotenv | Environment variables. |
| cookie-parser | Cookie handling. |
| nodemon | Dev auto-restart. |
🚀 Quick Setup — (COPY & PASTE) Option A — If you're cloning this repo (recommended)
git clone
https://github.com/amankv1234/Blog_App.gitcd
npm installnpm run devnpm startOption B — If you're starting from scratch (new project)
mkdir blog-app && cd blog-app
npm init -ynpm install express ejs mongoose dotenv jsonwebtoken cookie-parser multer bcryptnpm install -D nodemon📦 Full list of recommended npm packages express ejs mongoose dotenv jsonwebtoken cookie-parser multer bcrypt cookie-signature (optional) Dev: nodemon You can install them all at once:
npm install express ejs mongoose dotenv jsonwebtoken cookie-parser multer bcryptnpm install -D nodemon🔧 Environment Variables (.env example)
Create a .env file in project root and populate values: PORT=3000
MONGODB_URI=mongodb://localhost:27017/blogify
How to run (commands)
Development (auto restart):
npm run devProduction:
npm start🔐 Authentication flow (high level)
User signs up → password hashed with bcrypt → saved to users collection.
On login → server validates credentials → signs a JWT (jsonwebtoken) → stores token in an HTTP-only cookie (cookie-parser).
Protected routes check cookie + verify JWT in middlewares/authentication.js.
📁 Views & Partials
views/partials/head.ejs — head tags, CSS links, meta.
views/partials/nav.ejs — navigation bar, user name, logout.
views/partials/script.ejs — JS imports.
Main pages: home.ejs, addBlog.ejs, blog.ejs, signin.ejs, signup.ejs.
🖼️ Image Uploads
Using multer to accept cover images and store them in public/uploads/.
Optionally configure Cloudinary and store the URL in the DB (recommended for production).
🤝 Contributing
Fork the repo → create a feature branch → open a PR with description.
Please follow consistent coding style and add meaningful commit messages.
📝 License
MIT License — see LICENSE file.
✉️ Author
Aman Kumar Vishwakarma
Email: amankumarvishwakarma






