Skip to content

divyam-jha123/Blogify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blogging Application

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.

Features

  • 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

Tech Stack

  • 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

Prerequisites

  • 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

Local Setup

1. Clone the repository

git clone https://github.com/YOUR_USERNAME/blogging-application.git
cd blogging-application

2. Install dependencies

npm install

3. Set up Cloudinary

  1. Create a free account at Cloudinary
  2. Go to your Dashboard
  3. Copy the following credentials (you'll need them for the .env file):
    • Cloud Name
    • API Key
    • API Secret

4. Environment variables

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-secret
  • PORT — 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
  • 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: .env is gitignored. Never commit real secrets.

5. Run the app

Production mode:

npm start

Development mode (with auto-restart):

npm run dev

The server runs at http://localhost:3000 (or whatever PORT you set).

6. Create an account

  1. Open http://localhost:3000 in your browser.
  2. You’ll be redirected to Login. Use Sign up to create an account.
  3. After signup, log in with your email and password.
  4. Use Add new blog to create posts.

Project Structure

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

Scripts

Command Description
npm start Run the server
npm run dev Run with nodemon (auto-reload)

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

1. Fork the Repository

Click the "Fork" button at the top right of this page to create your own copy of the repository.

2. Clone Your Fork

Clone the repository to your local machine:

git clone https://github.com/YOUR_USERNAME/blogging-application.git
cd blogging-application

3. Create a Branch

Create 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-bug

4. Make Changes

Make your code changes. Ensure you follow the existing code style.

  • If adding a new feature, consider updating the README.md if necessary.
  • Check package.json for any scripts you might need to run.

5. Commit Changes

Commit your changes with a clear and descriptive message:

git commit -m "Add some amazing feature"

6. Push to Your Fork

Push your changes to your forked repository:

git push origin feature/amazing-feature

7. Open a Pull Request

Go to the original repository on GitHub and click "Compare & pull request". Provide a clear description of your changes.

Reporting Issues

If you find a bug or have a feature request, please open an issue in the Issues tab.

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •