Skip to content

A modern, full-featured blog application built with Node.js, Express, and MongoDB. Create, share, and engage with blog posts in a beautiful, responsive interface.

License

Notifications You must be signed in to change notification settings

GitWitAnish/Blogify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

50 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ Blogify - Full-Stack Blog Application

A modern, full-featured blog application built with Node.js, Express, and MongoDB. Create, share, and engage with blog posts in a beautiful, responsive interface.

Node.js Express.js MongoDB Bootstrap

✨ Features

πŸ” Authentication & User Management

  • User Registration with profile image upload
  • Secure Login/Logout with JWT tokens
  • Session Management with 24-hour token expiration
  • Custom profile picture

πŸ“– Blog Management

  • Create Blog Posts with rich text content
  • Image Upload for blog cover images
  • View All Blogs in a responsive card layout
  • Blog Details with full content display
  • Author Attribution with profile information

πŸ’¬ Interactive Comments

  • Add Comments to blog posts (authenticated users only)
  • Comment Threading with user avatars
  • Author Badges for blog creators in comments
  • Real-time Comment Count display

🎨 User Experience

  • Responsive Design for mobile, tablet, and desktop
  • Modern UI with Bootstrap 5
  • Image Preview during upload
  • Error Handling with user-friendly messages
  • Loading States and visual feedback

πŸš€ Quick Start

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (local or cloud instance)
  • Git for version control

Installation

  1. Clone the repository

    git clone https://github.com/GitWitAnish/Blog-App.git
    cd Blog-App
  2. Install dependencies

    npm install
  3. Set up MongoDB

    • Make sure MongoDB is running locally on mongodb://localhost:27017
    • Or update the connection string in index.js for your database
  4. Create uploads directory

    mkdir -p public/uploads/profiles
  5. Start the application

    # Development mode (with auto-restart)
    npm run dev
    
    # Production mode
    npm start
  6. Open your browser

    • Visit http://localhost:8000
    • Start creating your blog!

πŸ“ Project Structure

Blog-App/
β”œβ”€β”€ πŸ“‚ middlewares/
β”‚   └── authentication.js       # JWT authentication middleware
β”œβ”€β”€ πŸ“‚ models/
β”‚   β”œβ”€β”€ blog.js                 # Blog post schema
β”‚   β”œβ”€β”€ comment.js              # Comment schema (separate model)
β”‚   └── user.js                 # User schema with authentication
β”œβ”€β”€ πŸ“‚ public/
β”‚   β”œβ”€β”€ πŸ“‚ images/
β”‚   β”‚   └── avatar.jpg          # Default user avatar
β”‚   └── πŸ“‚ uploads/
β”‚       └── πŸ“‚ profiles/        # User profile pictures
β”œβ”€β”€ πŸ“‚ routes/
β”‚   β”œβ”€β”€ blog.js                 # Blog and comment routes
β”‚   └── user.js                 # Authentication routes
β”œβ”€β”€ πŸ“‚ services/
β”‚   └── authentication.js      # JWT token creation/verification
β”œβ”€β”€ πŸ“‚ views/
β”‚   β”œβ”€β”€ πŸ“‚ partials/
β”‚   β”‚   β”œβ”€β”€ head.ejs           # HTML head section
β”‚   β”‚   β”œβ”€β”€ nav.ejs            # Navigation bar
β”‚   β”‚   └── scripts.ejs        # JavaScript imports
β”‚   β”œβ”€β”€ 404.ejs                # Error page
β”‚   β”œβ”€β”€ addBlog.ejs           # Blog creation form
β”‚   β”œβ”€β”€ blogDetails.ejs       # Blog post display
β”‚   β”œβ”€β”€ home.ejs              # Homepage with blog list
β”‚   β”œβ”€β”€ signin.ejs            # Login form
β”‚   └── signup.ejs            # Registration form
β”œβ”€β”€ .gitignore
β”œβ”€β”€ index.js                   # Main application entry point
β”œβ”€β”€ package.json
└── README.md

πŸ› οΈ Technology Stack

Backend

  • Node.js - JavaScript runtime
  • Express.js - Web application framework
  • MongoDB - NoSQL database
  • Mongoose - MongoDB object modeling
  • JWT - JSON Web Token authentication
  • Multer - File upload handling
  • Cookie Parser - Cookie parsing middleware

Frontend

  • EJS - Embedded JavaScript templating
  • Bootstrap 5 - CSS framework
  • Vanilla JavaScript - Client-side interactions

Security & Features

  • Password Hashing with crypto module
  • File Upload Validation (size, type)
  • XSS Protection with proper templating
  • Session Management with JWT expiration
  • Error Handling throughout the application

πŸ”§ Configuration

Environment Variables

Create a .env file for production configurations:

# Database
MONGODB_URI=mongodb://localhost:27017/blogify

# JWT
JWT_SECRET=your-super-secret-key-here

# Server
PORT=8000

# File Upload
MAX_FILE_SIZE=5242880  # 5MB in bytes

Database Configuration

The app automatically creates the blogify database and required collections on first run.

πŸ“ API Routes

Authentication Routes

  • GET /user/signup - Registration page
  • POST /user/signup - Create new user account
  • GET /user/signin - Login page
  • POST /user/signin - User authentication
  • GET /user/logout - Logout and clear session

Blog Routes

  • GET / - Homepage with all blogs
  • GET /blog/add - Create new blog page (auth required)
  • POST /blog/add - Submit new blog post (auth required)
  • GET /blog/:id - View specific blog post
  • POST /blog/:id/delete - Delete blog post (author only)

Comment Routes

  • POST /blog/comment/:blogId - Add comment (auth required)

πŸ‘€ User Features

For Visitors

  • βœ… View all blog posts
  • βœ… Read full blog content and comments
  • βœ… Register for new account
  • βœ… Login to existing account

For Authenticated Users

  • βœ… All visitor features
  • βœ… Create new blog posts with images
  • βœ… Add comments to any blog post
  • βœ… Upload custom profile picture
  • βœ… See personalized navigation
  • βœ… Delete own blog posts (future feature)

For Blog Authors

  • βœ… Special "Author" badge in comments
  • βœ… Author attribution on blog posts
  • βœ… Profile display in blog details

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin feature)
  5. Open a Pull Request

Future Enhancements

  • User Profiles - Dedicated profile pages
  • Blog Editing - Edit existing blog posts
  • Comment Replies - Nested comment threading
  • Search & Filter - Find blogs by title, author, or content
  • Categories & Tags - Organize blogs by topics
  • Like System - Like blogs and comments
  • Admin Dashboard - Manage users and content
  • Email Notifications - Notify users of new comments
  • Social Sharing - Share blogs on social media
  • Rich Text Editor - WYSIWYG blog editor

πŸ“„ License

This project is licensed under the ISC License.

πŸ‘¨β€πŸ’» Author

Anish - @GitWitAnish

About

A modern, full-featured blog application built with Node.js, Express, and MongoDB. Create, share, and engage with blog posts in a beautiful, responsive interface.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published