A full-stack blogging platform built with Node.js, Express, and MongoDB. Users can sign up, log in, create blog posts with cover images, and browse a feed of all posts.
- User authentication — Sign up, log in, and log out with JWT-based sessions (stored in HTTP-only cookies)
- Create blogs — Add new posts with a title, content, and optional cover image
- Browse feed — Homepage shows all blogs sorted by newest first
- View single blog — Click a post to read the full content and see author info
- Image uploads — Cover images uploaded to Cloudinary and served via CDN
- GitHub Integration — Quick access to the repository via the navigation bar
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (Mongoose)
- Auto-restarting the server: Nodemon
- Template engine: EJS
- Auth: JWT + bcrypt
- File uploads: Multer (memory storage)
- Image hosting: Cloudinary
- Node.js (v18+ recommended)
- MongoDB — either:
- Local MongoDB installed and running, or
- A MongoDB Atlas cluster (free tier works)
- Cloudinary account (free tier works) — for image hosting
git clone https://github.com/YOUR_USERNAME/blogging-application.git
cd blogging-applicationnpm install- Create a free account at Cloudinary
- Go to your Dashboard
- Copy the following credentials (you'll need them for the
.envfile):- Cloud Name
- API Key
- API Secret
Create a .env file in the project root (same folder as package.json):
PORT=3000
MONGO_URI=mongodb://localhost:27017/blogging-app
SECRET_KEY=your-super-secret-jwt-key-change-in-production
CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name
CLOUDINARY_API_KEY=your-cloudinary-api-key
CLOUDINARY_API_SECRET=your-cloudinary-api-secretPORT— Port the server runs on (e.g.3000).MONGO_URI— MongoDB connection string.- Local:
mongodb://localhost:27017/blogging-app - Atlas:
mongodb+srv://<user>:<password>@<cluster>.mongodb.net/blogging-app?retryWrites=true&w=majority
- Local:
SECRET_KEY— Secret used to sign JWT tokens. Use a long, random string in production.CLOUDINARY_CLOUD_NAME— Your Cloudinary cloud name. Get this from your Cloudinary Dashboard.CLOUDINARY_API_KEY— Your Cloudinary API key. Get this from your Cloudinary Dashboard.CLOUDINARY_API_SECRET— Your Cloudinary API secret. Get this from your Cloudinary Dashboard.
Note:
.envis gitignored. Never commit real secrets.
Production mode:
npm startDevelopment mode (with auto-restart):
npm run devThe server runs at http://localhost:3000 (or whatever PORT you set).
- Open
http://localhost:3000in your browser. - You’ll be redirected to Login. Use Sign up to create an account.
- After signup, log in with your email and password.
- Use Add new blog to create posts.
blogging-application/
├── db/
│ └── connection.js # MongoDB connection
├── middlewares/
│ └── auth.js # JWT cookie auth & route protection
├── models/
│ ├── blog.js # Blog post schema
│ └── user.js # User schema
├── public/
│ └── image/ # Static images (e.g. default avatar)
├── routes/
│ ├── blog.js # Blog CRUD & Cloudinary image upload
│ └── user.js # Auth routes (signup, login, logout)
├── service/
│ └── authentication.js # JWT create/verify helpers
├── views/ # EJS templates
│ ├── addBlogs.ejs
│ ├── blog.ejs
│ ├── homepage.ejs
│ ├── login.ejs
│ ├── signup.ejs
│ └── partials/
├── .env # Your env vars (create this, not in git)
├── .gitignore
├── index.js # App entry point
├── package.json
└── README.md
| Command | Description |
|---|---|
npm start |
Run the server |
npm run dev |
Run with nodemon (auto-reload) |
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
Click the "Fork" button at the top right of this page to create your own copy of the repository.
Clone the repository to your local machine:
git clone https://github.com/YOUR_USERNAME/blogging-application.git
cd blogging-applicationCreate a new branch for your feature or bug fix. Use a descriptive name:
git checkout -b feature/amazing-feature
# or
git checkout -b fix/critical-bugMake your code changes. Ensure you follow the existing code style.
- If adding a new feature, consider updating the
README.mdif necessary. - Check
package.jsonfor any scripts you might need to run.
Commit your changes with a clear and descriptive message:
git commit -m "Add some amazing feature"Push your changes to your forked repository:
git push origin feature/amazing-featureGo to the original repository on GitHub and click "Compare & pull request". Provide a clear description of your changes.
If you find a bug or have a feature request, please open an issue in the Issues tab.