Skip to content

Bits of Thought - A feature-rich blog application built with the MERN stack. Secure authentication, post management, comments, and cloud-based image storage with a beautiful responsive UI.

Notifications You must be signed in to change notification settings

MalingaBandara/FullStack-Blog-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

80 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bits of Thought

A full-featured, modern blog application built with the MERN stack (MongoDB, Express.js, Node.js) featuring user authentication, post management, comments, and cloud-based image storage. Bits of Thought demonstrates modern web development practices including secure authentication, RESTful API design, cloud integration, and a beautiful, responsive user interface.

πŸ“‘ Quick Links


🎨 UI/UX Design Highlights

Responsive Design

  • Fully Responsive Layout - Seamlessly adapts to all screen sizes (mobile, tablet, desktop)
  • Mobile-First Approach - Optimized for mobile devices with touch-friendly interfaces
  • Flexible Grid System - Modern CSS Grid and Flexbox layouts for perfect alignment
  • Adaptive Navigation - Responsive navigation menu that adjusts to screen size

Modern UI Features

  • Hero Section - Eye-catching hero section with animated background overlays
  • Smooth Animations - CSS animations and transitions for enhanced user experience
  • Gradient Overlays - Beautiful gradient effects and visual depth
  • Clean Typography - Modern font choices and readable text hierarchy
  • Intuitive Navigation - User-friendly navigation with clear visual feedback
  • Interactive Elements - Hover effects and interactive buttons throughout the application
  • Loading States - Visual feedback for user actions
  • Error & Success Messages - Clear, user-friendly notification system

User Experience

  • Intuitive Interface - Clean and organized layout for easy navigation
  • Visual Feedback - Immediate response to user interactions
  • Consistent Design Language - Cohesive design system across all pages
  • Accessibility - Considerate design for better usability

πŸ“Έ Screenshots

Home Page

Home Page

Beautiful hero section with animated backgrounds and modern design

Posts Listing

Home Page

Responsive grid layout showcasing all blog posts

Post Details with Comments

Home Page

Detailed post view with image gallery and comment system

Comment Form

Home Page

Interactive comment form allowing users to add comments to posts

User Profile

Home Page

User profile page with bio, profile picture, and post history

Create Post

Home Page

Intuitive post creation form with multiple image upload support

Edit Post

Home Page

Add Comment

Home Page

Edit Comment

Home Page

Edit Profile

Home Page

Login Page

Home Page

Clean and modern login interface

Register Page

Home Page

User registration form with validation

Responsive Mobile View

Home Page

Fully responsive design optimized for mobile devices


πŸš€ Features

Authentication & User Management

  • User Registration & Login - Secure authentication using Passport.js with local strategy
  • Session Management - Persistent sessions stored in MongoDB using connect-mongo
  • Password Security - Passwords are hashed using bcryptjs before storage
  • User Profiles - View and manage user profiles with bio and profile pictures
  • Profile Editing - Update username, email, bio, and profile picture
  • Account Deletion - Complete account removal with cascade deletion of all associated data

Blog Post Management

  • Create Posts - Rich blog posts with title, content, and multiple images (up to 5 per post)
  • View Posts - Browse all posts with author information
  • Post Details - Detailed view of individual posts with all comments
  • Edit Posts - Update post content and images (author-only)
  • Delete Posts - Remove posts with automatic cleanup of associated images and comments (author-only)
  • Image Upload - Multiple image support per post with Cloudinary integration

Comment System

  • Add Comments - Users can comment on any post
  • Edit Comments - Update your own comments
  • Delete Comments - Remove your own comments
  • Comment Threading - Comments are linked to posts and display author information

Image Management

  • Cloudinary Integration - All images are stored in Cloudinary cloud storage
  • Profile Pictures - Upload and manage profile pictures
  • Post Images - Support for multiple images per blog post
  • Automatic Cleanup - Images are automatically deleted from Cloudinary when posts or accounts are deleted

Security & Authorization

  • Route Protection - Protected routes require authentication
  • Authorization Checks - Users can only edit/delete their own posts and comments
  • Error Handling - Comprehensive error handling with custom error middleware
  • Session Security - Secure session management with MongoDB store

πŸ› οΈ Tech Stack

Backend

  • Node.js - JavaScript runtime environment
  • Express.js - Web application framework
  • MongoDB - NoSQL database
  • Mongoose - MongoDB object modeling

Authentication & Security

  • Passport.js - Authentication middleware (Local Strategy)
  • bcryptjs - Password hashing
  • express-session - Session management
  • connect-mongo - MongoDB session store

File Upload & Storage

  • Multer - File upload middleware
  • Cloudinary - Cloud-based image storage and management
  • multer-storage-cloudinary - Multer storage engine for Cloudinary

Frontend & UI

  • EJS - Embedded JavaScript templating
  • Custom CSS - Modern, responsive styling with animations
  • Responsive Design - Mobile-first, adaptive layouts

Utilities

  • method-override - HTTP method override for PUT/DELETE requests
  • express-async-handler - Async error handling wrapper
  • dotenv - Environment variable management

πŸ“ Project Structure

Bits-of-Thought/
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ cloudinary.js      # Cloudinary configuration
β”‚   β”œβ”€β”€ multer.js          # Multer file upload configuration
β”‚   └── passport.js        # Passport authentication strategy
β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ authController.js  # Authentication logic (login, register, logout)
β”‚   β”œβ”€β”€ commentController.js # Comment CRUD operations
β”‚   β”œβ”€β”€ postController.js   # Post CRUD operations
β”‚   └── userController.js   # User profile management
β”œβ”€β”€ middlewares/
β”‚   β”œβ”€β”€ auth.js            # Authentication middleware
β”‚   └── errorHandler.js    # Global error handling
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ Comment.js          # Comment schema
β”‚   β”œβ”€β”€ File.js            # File metadata schema
β”‚   β”œβ”€β”€ Post.js            # Post schema
β”‚   └── User.js            # User schema
β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ authRoutes.js      # Authentication routes
β”‚   β”œβ”€β”€ commentRoutes.js   # Comment routes
β”‚   β”œβ”€β”€ postRoutes.js      # Post routes
β”‚   └── userRoutes.js      # User/profile routes
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── styles.css     # Application styles
β”‚   └── images/
β”‚       └── logo.png       # Application logo
β”œβ”€β”€ views/
β”‚   β”œβ”€β”€ partials/
β”‚   β”‚   β”œβ”€β”€ footer.ejs     # Footer partial
β”‚   β”‚   └── header.ejs     # Header partial
β”‚   β”œβ”€β”€ editPost.ejs       # Edit post page
β”‚   β”œβ”€β”€ editProfile.ejs    # Edit profile page
β”‚   β”œβ”€β”€ error.ejs          # Error page
β”‚   β”œβ”€β”€ home.ejs           # Home page
β”‚   β”œβ”€β”€ login.ejs          # Login page
β”‚   β”œβ”€β”€ newPost.ejs        # Create post page
β”‚   β”œβ”€β”€ postDetails.ejs    # Post details page
β”‚   β”œβ”€β”€ posts.ejs          # All posts page
β”‚   β”œβ”€β”€ profile.ejs        # User profile page
β”‚   └── register.ejs       # Registration page
β”œβ”€β”€ app.js                 # Main application file
β”œβ”€β”€ package.json           # Project dependencies
└── README.md              # Project documentation

πŸ“¦ Installation & Setup

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (local or MongoDB Atlas)
  • Cloudinary account (for image storage)
  • Git

Step 1: Clone the Repository

git clone https://github.com/MalingaBandara/FullStack-Blog-App.git
cd FullStack-Blog-App
# Or if repository is renamed:
# cd Bits-of-Thought

Step 2: Install Dependencies

npm install

Step 3: Environment Variables

Create a .env file in the root directory and add the following variables:

# MongoDB Connection
MONGODB_URL=mongodb://localhost:27017/blog-app
# Or use MongoDB Atlas:
# MONGODB_URL=mongodb+srv://username:password@cluster.mongodb.net/blog-app

# Cloudinary Configuration
CLOUDINARY_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_SECRET=your_cloudinary_api_secret

# Server Port (optional, defaults to 3000)
PORT=3000

# Session Secret (optional, for production use a strong random string)
SESSION_SECRET=your_session_secret_key

Step 4: Start the Application

npm start

The server will start on http://localhost:3000 (or the port specified in your .env file).

🎯 Usage

Getting Started

  1. Register a new account - Navigate to /auth/register and create your account
  2. Login - Use your credentials to login at /auth/login
  3. Create a post - Go to /posts/add to create your first blog post
  4. View posts - Browse all posts at /posts
  5. Manage profile - Edit your profile at /user/edit

Key Routes

Authentication

  • GET /auth/register - Registration page
  • POST /auth/register - Register new user
  • GET /auth/login - Login page
  • POST /auth/login - User login
  • GET /auth/logout - User logout

Posts

  • GET /posts - View all posts
  • GET /posts/add - Create new post (protected)
  • POST /posts/add - Submit new post (protected)
  • GET /posts/:id - View post details
  • GET /posts/:id/edit - Edit post form (protected, author-only)
  • PUT /posts/:id - Update post (protected, author-only)
  • DELETE /posts/:id - Delete post (protected, author-only)

Comments

  • POST /posts/:id/comments - Add comment to post (protected)
  • PUT /comment/:id - Update comment (protected, author-only)
  • DELETE /comment/:id - Delete comment (protected, author-only)

User Profile

  • GET /user/profile - View user profile (protected)
  • GET /user/edit - Edit profile form (protected)
  • POST /user/edit - Update profile (protected)
  • POST /user/delete - Delete account (protected)

πŸ”’ Security Features

  • Password Hashing - All passwords are hashed using bcryptjs before storage
  • Session Management - Secure session handling with MongoDB persistence
  • Route Protection - Authentication middleware protects sensitive routes
  • Authorization - Users can only modify their own content
  • Input Validation - Form data validation and sanitization
  • Error Handling - Comprehensive error handling prevents information leakage

🎨 Features Highlights

Database Relationships

  • User-Post Relationship - One-to-many (User can have many posts)
  • Post-Comment Relationship - One-to-many (Post can have many comments)
  • User-Comment Relationship - One-to-many (User can have many comments)
  • Cascade Deletion - Deleting a user/post automatically removes associated data

Image Management

  • Images are uploaded directly to Cloudinary
  • Automatic cleanup when posts or accounts are deleted
  • Support for multiple images per post
  • Profile picture management

User Experience

  • Responsive Design - Fully responsive layout that works perfectly on all devices
  • Modern UI/UX - Clean, intuitive interface with smooth animations
  • Real-time Feedback - Instant error messages and success notifications
  • Intuitive Navigation - Easy-to-use navigation with clear visual hierarchy
  • Accessible Design - User-friendly interface designed for all users
  • Performance Optimized - Fast loading times and smooth interactions

πŸ‘€ Author

Malinga Bandara (BitLord)

Full-Stack Developer & Creator of Bits of Thought


About the Developer: Passionate about creating beautiful, functional web applications. Bits of Thought represents a combination of modern web technologies, clean code practices, and attention to user experience.

πŸ™ Acknowledgments

  • Express.js community
  • MongoDB documentation
  • Cloudinary for image storage services
  • Passport.js for authentication strategies

🎯 Project Showcase

Bits of Thought is a comprehensive blog application that showcases:

  • βœ… Full-stack development skills (MERN stack)
  • βœ… Modern, responsive UI/UX design
  • βœ… Secure authentication and authorization
  • βœ… Cloud integration (Cloudinary)
  • βœ… RESTful API architecture
  • βœ… Database design and relationships
  • βœ… Error handling and security best practices
  • βœ… Clean, maintainable code structure

Note: This project is built for educational and portfolio purposes. Make sure to configure your environment variables properly before deploying to production.

About

Bits of Thought - A feature-rich blog application built with the MERN stack. Secure authentication, post management, comments, and cloud-based image storage with a beautiful responsive UI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published