Skip to content

Latest commit

Β 

History

42 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ BlogHub - Advanced MERN Blogging Platform

A modern, feature-rich blogging platform built with MongoDB, Express.js, React (Vite), and Node.js. Perfect for content creators, bloggers, and organizations looking for a complete content management solution.

License: MIT React Node.js MongoDB

Project Preview Video

Zidio.Dev.Project.2.mp4

🌟 Key Features

✨ User Experience

  • πŸ” Multi-tier Authentication - User, Admin, and Super Admin roles
  • πŸ“ Advanced Rich Text Editor - Powered by Tiptap with extensive formatting options
  • πŸ” Intelligent Search & Filters - Advanced search with AI-powered suggestions
  • πŸ’¬ Interactive Comments System - Nested comments with real-time updates
  • ❀️ Social Features - Like, bookmark, and share functionality
  • πŸ‘€ Comprehensive User Profiles - Customizable profiles with activity tracking
  • πŸ“± Fully Responsive Design - Seamless experience across all devices
  • πŸŒ“ Dark/Light Theme Support - User preference-based theming

πŸ›‘οΈ Admin & Management

  • πŸ“Š Advanced Analytics Dashboard - User, content, and engagement metrics
  • πŸ‘₯ User Management System - Role-based access control and user moderation
  • πŸ“ˆ Content Analytics - Blog performance tracking and insights
  • οΏ½ Admin Request System - Secure admin privilege request workflow
  • πŸ› οΈ Super Admin Controls - System-wide management and configuration

πŸš€ Technical Excellence

  • ⚑ High Performance - Optimized React components with Redux Toolkit
  • πŸ”’ Enterprise Security - JWT authentication with bcrypt encryption
  • πŸ“‘ RESTful API Design - Well-documented, scalable backend architecture
  • 🎨 Modern UI/UX - Tailwind CSS with custom design system
  • πŸ”„ Real-time Updates - Live notifications and content updates

πŸ› οΈ Tech Stack

Frontend

  • Framework: React 18.3.1 with Vite
  • State Management: Redux Toolkit
  • Styling: Tailwind CSS with custom components
  • Rich Text Editor: Tiptap (migrated from React Quill for better SSR support)
  • HTTP Client: Axios with interceptors
  • Routing: React Router DOM v6
  • Icons: React Icons
  • Notifications: React Hot Toast

Backend

  • Runtime: Node.js with Express.js
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT tokens with bcrypt hashing
  • File Upload: Multer with Cloudinary integration
  • Security: Helmet, CORS, rate limiting
  • Validation: Express validator middleware

Development Tools

  • Frontend Dev Server: Vite (Fast HMR)
  • Backend Dev Server: Nodemon
  • Code Quality: ESLint, Prettier
  • Version Control: Git with GitHub

πŸš€ Quick Start Guide

Prerequisites

  • Node.js (v16.0.0 or higher)
  • MongoDB Atlas account or local MongoDB installation
  • Git for version control

Installation Steps

  1. Clone the Repository

    git clone https://github.com/omkar2816/Zidio-Dev-Project-2.git
    cd Zidio-Dev-Project-2
  2. Install Dependencies

    # Install backend dependencies
    cd backend
    npm install
    
    # Install frontend dependencies
    cd ../frontend
    npm install
    
    # Install root dependencies (if any)
    cd ..
    npm install
  3. Environment Configuration

    Backend Environment (.env in /backend/)

    PORT=5000
    MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/blog-web-application
    JWT_SECRET=your_super_secret_jwt_key_min_32_characters
    NODE_ENV=development
    
    # Optional: For image uploads (Cloudinary)
    CLOUDINARY_CLOUD_NAME=your_cloudinary_name
    CLOUDINARY_API_KEY=your_cloudinary_key
    CLOUDINARY_API_SECRET=your_cloudinary_secret

    Frontend Environment (.env in /frontend/)

    VITE_API_URL=http://localhost:5000/api
  4. Database Setup

    # Test database connection
    cd backend
    node checkDatabase.js
    
    # Create super admin (optional)
    node scripts/createSuperAdmin.js
  5. Start Development Servers

    # Terminal 1: Start Backend Server
    cd backend
    npm start
    # Backend runs on: http://localhost:5000
    
    # Terminal 2: Start Frontend Server
    cd frontend
    npm run dev
    # Frontend runs on: http://localhost:5174

πŸ“± User Manual

πŸ” Getting Started

User Registration & Login

  1. Sign Up: Navigate to /register and create an account

    • Choose username, email, and secure password
    • Optionally request admin access during registration
    • Account verification via email (if configured)
  2. Login: Access your account at /login

    • Supports User, Admin, and Super Admin roles
    • Auto-redirect based on user permissions
    • Remember me functionality

Role Overview

  • πŸ‘€ User: Create, edit, and manage your own blogs
  • πŸ›‘οΈ Admin: Moderate users and content, access analytics
  • ⚑ Super Admin: Full system control, manage admins, system settings

✍️ Content Creation

Creating Blog Posts

  1. Navigate to Create: Click "Create" button or visit /create
  2. Fill Blog Details:
    • Title: Engaging, SEO-friendly title
    • Category: Choose from predefined categories
    • Tags: Add relevant tags (comma-separated)
    • Featured Image: Upload file or provide URL
  3. Content Creation: Use the rich text editor
    • Formatting: Bold, italic, headers, lists
    • Media: Insert images, add links
    • Layout: Text alignment, spacing
  4. Publish: Click "Publish Blog" to make it live

Rich Text Editor Features

  • Text Formatting: Bold, italic, strikethrough
  • Headers: H1, H2, H3 for content structure
  • Lists: Bullet points and numbered lists
  • Alignment: Left, center, right text alignment
  • Links: Add hyperlinks with custom text
  • Images: Insert images via URL with preview
  • Responsive: Works on desktop and mobile

Managing Your Content

  • Edit Blogs: Visit /edit/:id to modify your posts
  • Delete Blogs: Remove unwanted content
  • Draft System: Save work in progress (coming soon)
  • Analytics: Track views, likes, and engagement

πŸ” Discovery & Interaction

Search & Filter

  • Smart Search: AI-powered search with synonyms
  • Category Filter: Browse by technology, tutorials, etc.
  • Sort Options: Latest, most liked, most viewed, alphabetical
  • Advanced Filters: Combine multiple criteria

Social Features

  • Like Posts: Show appreciation for great content
  • Bookmark: Save posts for later reading (/bookmarks)
  • Comment: Engage with authors and other readers
  • Share: Social media integration (coming soon)

πŸ‘€ Profile Management

Your Profile (/profile)

  • Profile Information: Update name, bio, avatar
  • Activity Overview: Your blogs, comments, likes
  • Statistics: Content performance metrics
  • Account Settings: Password, email preferences

Privacy & Security

  • Password Management: Update passwords securely
  • Account Visibility: Control profile visibility
  • Data Export: Download your content (coming soon)

πŸ›‘οΈ Admin Features

Admin Dashboard (/admin)

  • User Management: View, edit, delete users
  • Content Moderation: Manage all blog posts
  • Analytics: System-wide statistics and insights
  • Role Management: Promote/demote user roles (Super Admin only)

Super Admin Controls (/superadmin)

  • System Overview: Complete platform statistics
  • Admin Management: Manage admin users
  • Admin Requests: Approve/reject admin access requests
  • System Settings: Platform configuration

πŸ”§ API Documentation

Authentication Endpoints

Method Endpoint Description Access
POST /api/auth/register User registration Public
POST /api/auth/login User authentication Public
GET /api/auth/me Get current user Private
PUT /api/auth/profile Update profile Private

Blog Management

Method Endpoint Description Access
GET /api/blogs Get all published blogs Public
GET /api/blogs/:id Get single blog post Public
POST /api/blogs Create new blog Private
PUT /api/blogs/:id Update blog post Private (Author/Admin)
DELETE /api/blogs/:id Delete blog post Private (Author/Admin)
POST /api/blogs/:id/like Like/unlike blog Private
GET /api/blogs/user/:userId Get user's blogs Public

Comment System

Method Endpoint Description Access
GET /api/blogs/:id/comments Get blog comments Public
POST /api/blogs/:id/comments Add comment Private
PUT /api/comments/:id Update comment Private (Author/Admin)
DELETE /api/comments/:id Delete comment Private (Author/Admin)

User Management

Method Endpoint Description Access
GET /api/users/:id Get user profile Public
PUT /api/users/:id Update user profile Private (Self/Admin)
GET /api/admin/users Get all users Admin
DELETE /api/admin/users/:id Delete user Admin
PUT /api/admin/users/:id/role Update user role Super Admin

Admin Features

Method Endpoint Description Access
GET /api/admin/analytics System analytics Admin
GET /api/admin-request/pending Pending admin requests Super Admin
PUT /api/admin-request/:id/approve Approve admin request Super Admin
PUT /api/admin-request/:id/reject Reject admin request Super Admin

πŸ“ Project Structure

BlogHub/
β”œβ”€β”€ πŸ“ backend/                    # Express.js Backend
β”‚   β”œβ”€β”€ πŸ“ config/                 # Database & app configuration
β”‚   β”‚   └── db.js                  # MongoDB connection
β”‚   β”œβ”€β”€ πŸ“ controllers/            # Route controllers
β”‚   β”‚   β”œβ”€β”€ authController.js      # Authentication logic
β”‚   β”‚   β”œβ”€β”€ blogController.js      # Blog CRUD operations
β”‚   β”‚   β”œβ”€β”€ userController.js      # User management
β”‚   β”‚   β”œβ”€β”€ adminController.js     # Admin operations
β”‚   β”‚   └── adminRequestController.js # Admin request handling
β”‚   β”œβ”€β”€ πŸ“ middleware/             # Custom middleware
β”‚   β”‚   β”œβ”€β”€ authMiddleware.js      # JWT authentication
β”‚   β”‚   └── errorMiddleware.js     # Error handling
β”‚   β”œβ”€β”€ πŸ“ models/                 # MongoDB schemas
β”‚   β”‚   β”œβ”€β”€ User.js               # User model with roles
β”‚   β”‚   └── Blog.js               # Blog post model
β”‚   β”œβ”€β”€ πŸ“ routes/                 # API route definitions
β”‚   β”‚   β”œβ”€β”€ authRoutes.js         # Authentication routes
β”‚   β”‚   β”œβ”€β”€ blogRoutes.js         # Blog management routes
β”‚   β”‚   β”œβ”€β”€ userRoutes.js         # User profile routes
β”‚   β”‚   β”œβ”€β”€ adminRoutes.js        # Admin panel routes
β”‚   β”‚   └── adminRequestRoutes.js # Admin request routes
β”‚   β”œβ”€β”€ πŸ“ scripts/               # Utility scripts
β”‚   β”‚   └── createSuperAdmin.js   # Super admin creation
β”‚   β”œβ”€β”€ πŸ“ uploads/               # File upload directory
β”‚   β”œβ”€β”€ .env                      # Environment variables
β”‚   β”œβ”€β”€ package.json              # Backend dependencies
β”‚   └── server.js                 # Express server entry point
β”‚
β”œβ”€β”€ πŸ“ frontend/                   # React Frontend
β”‚   β”œβ”€β”€ πŸ“ public/                # Static assets
β”‚   β”œβ”€β”€ πŸ“ src/
β”‚   β”‚   β”œβ”€β”€ πŸ“ components/        # Reusable React components
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.jsx        # Navigation component
β”‚   β”‚   β”‚   β”œβ”€β”€ BlogCard.jsx      # Blog preview card
β”‚   β”‚   β”‚   β”œβ”€β”€ SearchBar.jsx     # Advanced search component
β”‚   β”‚   β”‚   β”œβ”€β”€ TiptapEditor.jsx  # Rich text editor
β”‚   β”‚   β”‚   β”œβ”€β”€ AnalyticsChart.jsx # Data visualization
β”‚   β”‚   β”‚   └── AdminRequestStatus.jsx # Admin request component
β”‚   β”‚   β”œβ”€β”€ πŸ“ pages/             # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx          # Landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx         # Authentication page
β”‚   β”‚   β”‚   β”œβ”€β”€ Register.jsx      # User registration
β”‚   β”‚   β”‚   β”œβ”€β”€ CreateBlog.jsx    # Blog creation
β”‚   β”‚   β”‚   β”œβ”€β”€ EditBlog.jsx      # Blog editing
β”‚   β”‚   β”‚   β”œβ”€β”€ BlogDetails.jsx   # Individual blog view
β”‚   β”‚   β”‚   β”œβ”€β”€ MyProfile.jsx     # User profile page
β”‚   β”‚   β”‚   β”œβ”€β”€ Bookmarks.jsx     # Saved posts
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminDashboard.jsx # Admin panel
β”‚   β”‚   β”‚   └── SuperAdminPanel.jsx # Super admin interface
β”‚   β”‚   β”œβ”€β”€ πŸ“ store/             # Redux state management
β”‚   β”‚   β”‚   β”œβ”€β”€ store.js          # Redux store configuration
β”‚   β”‚   β”‚   └── slices/           # Redux slices
β”‚   β”‚   β”‚       β”œβ”€β”€ authSlice.js  # Authentication state
β”‚   β”‚   β”‚       β”œβ”€β”€ blogSlice.js  # Blog management state
β”‚   β”‚   β”‚       └── themeSlice.js # Theme preferences
β”‚   β”‚   β”œβ”€β”€ πŸ“ services/          # API service functions
β”‚   β”‚   β”‚   β”œβ”€β”€ blogService.js    # Blog API calls
β”‚   β”‚   β”‚   β”œβ”€β”€ userService.js    # User API calls
β”‚   β”‚   β”‚   └── synonymService.js # Search enhancement
β”‚   β”‚   β”œβ”€β”€ πŸ“ utils/             # Utility functions
β”‚   β”‚   β”œβ”€β”€ πŸ“ styles/            # CSS and styling
β”‚   β”‚   β”‚   β”œβ”€β”€ globals.css       # Global styles
β”‚   β”‚   β”‚   └── tiptap.css        # Rich editor styles
β”‚   β”‚   β”œβ”€β”€ App.jsx               # Main application component
β”‚   β”‚   └── main.jsx              # React entry point
β”‚   β”œβ”€β”€ .env                      # Frontend environment variables
β”‚   β”œβ”€β”€ package.json              # Frontend dependencies
β”‚   β”œβ”€β”€ tailwind.config.js        # Tailwind CSS configuration
β”‚   └── vite.config.js            # Vite build configuration
β”‚
β”œβ”€β”€ πŸ“„ README.md                  # This documentation file
β”œβ”€β”€ πŸ“„ PROJECT_REPORT.md          # Detailed project report
β”œβ”€β”€ πŸ“„ TIPTAP_MIGRATION.md        # Editor migration guide
└── πŸ“„ package.json               # Root project configuration

πŸš€ Deployment Guide

Frontend Deployment (Netlify/Vercel)

Netlify Deployment

  1. Build the project:

    cd frontend
    npm run build
  2. Deploy to Netlify:

    • Upload frontend/dist folder to Netlify
    • Set build command: npm run build
    • Set publish directory: dist
    • Set environment variables:
      VITE_API_URL=https://your-backend-url.com/api
      

Vercel Deployment

  1. Connect GitHub repository
  2. Configure build settings:
    • Framework Preset: Vite
    • Root Directory: frontend
    • Build Command: npm run build
    • Output Directory: dist
  3. Add environment variables:
    VITE_API_URL=https://your-backend-url.com/api
    

Backend Deployment (Railway/Render/Heroku)

Railway Deployment

  1. Connect your GitHub repository
  2. Set root directory: backend
  3. Environment variables:
    PORT=5000
    MONGO_URI=mongodb+srv://user:pass@cluster.mongodb.net/database
    JWT_SECRET=your_production_jwt_secret
    NODE_ENV=production
    CLOUDINARY_CLOUD_NAME=your_cloud_name
    CLOUDINARY_API_KEY=your_api_key
    CLOUDINARY_API_SECRET=your_api_secret

Render Deployment

  1. Create new Web Service
  2. Build Command: cd backend && npm install
  3. Start Command: cd backend && npm start
  4. Add environment variables (same as above)

Heroku Deployment

  1. Create Heroku app:
    heroku create your-app-name
  2. Set buildpack:
    heroku buildpacks:set heroku/nodejs
  3. Configure environment variables:
    heroku config:set MONGO_URI=your_mongo_uri
    heroku config:set JWT_SECRET=your_jwt_secret

Database Setup (MongoDB Atlas)

  1. Create MongoDB Atlas Account

    • Sign up at MongoDB Atlas
    • Create a new cluster (free tier available)
  2. Configure Database Access

    • Create database user with read/write permissions
    • Whitelist IP addresses (0.0.0.0/0 for all IPs)
  3. Get Connection String

    • Click "Connect" β†’ "Connect your application"
    • Copy the connection string
    • Replace <password> with your actual password
  4. Database Collections The application will automatically create the following collections:

    • users - User accounts and profiles
    • blogs - Blog posts and content
    • comments - User comments (embedded in blogs) Collections which you have to make:
    • bookmarks - Store Bookmarked post for each user
    • categories - Various categories of Blogs (Web Development, etc.)
    • likes - Store likes of Blogs
    • tags - Hashtag to make blog trend
    • views - To Store views

πŸ”§ Development Guide

Setting Up Development Environment

  1. Code Editor Setup

    • VS Code (recommended) with extensions:
      • ES7+ React/Redux/React-Native snippets
      • Tailwind CSS IntelliSense
      • MongoDB for VS Code
      • GitLens
  2. Development Tools

    # Install nodemon globally for backend development
    npm install -g nodemon
    
    # Install Redux DevTools browser extension
    # Available for Chrome and Firefox

Code Style & Standards

  • Frontend: ESLint + Prettier configuration
  • Backend: Node.js best practices with error handling
  • Database: Mongoose schema validation
  • Git: Conventional commit messages

Testing

Backend Testing

cd backend
npm run test

Frontend Testing

cd frontend
npm run test

Performance Optimization

Frontend Optimizations

  • Code Splitting: Lazy loading for routes
  • Image Optimization: WebP format, lazy loading
  • Bundle Analysis: Use npm run build -- --analyze
  • Caching: Service worker for offline support

Backend Optimizations

  • Database Indexing: Optimized queries
  • Caching: Redis for session management
  • Rate Limiting: API protection
  • Compression: Gzip compression enabled

πŸ” Troubleshooting

Common Issues & Solutions

Frontend Issues

Issue: Vite dev server not starting

# Solution: Clear cache and reinstall dependencies
rm -rf node_modules package-lock.json
npm install
npm run dev

Issue: Environment variables not loading

# Solution: Check .env file format (no spaces around =)
VITE_API_URL=http://localhost:5000/api

Issue: Build fails with TypeScript errors

# Solution: Check component imports and prop types
npm run build -- --no-strict

Backend Issues

Issue: MongoDB connection fails

# Solution: Check connection string and network access
# Verify MongoDB Atlas IP whitelist includes your IP

Issue: JWT authentication not working

# Solution: Verify JWT_SECRET is set and same across all instances
echo $JWT_SECRET

Issue: File upload errors

# Solution: Check Cloudinary credentials and upload preset
# Verify file size limits in middleware

Database Issues

Issue: Duplicate key errors

# Solution: Check unique indexes and handle conflicts
# Use proper error handling in try-catch blocks

Issue: Slow query performance

# Solution: Add database indexes for frequently queried fields
# Use MongoDB Compass to analyze query performance

Debug Mode

Enable Debug Logging

# Backend debugging
DEBUG=blog:* npm start

# Frontend debugging
VITE_DEBUG=true npm run dev

Browser DevTools

  • Network Tab: Monitor API calls and responses
  • Application Tab: Check localStorage and sessionStorage
  • Console: View React and Redux logs

Support & Community

  • GitHub Issues: Report bugs and feature requests
  • Documentation: Check PROJECT_REPORT.md for detailed technical documentation
  • Migration Guide: See TIPTAP_MIGRATION.md for editor implementation details

πŸ“„ Default Admin Accounts

Creating Super Admin

cd backend
node scripts/createSuperAdmin.js

Test Accounts

For development and testing purposes:

Super Admin:

  • Email: superadmin@bloghub.com
  • Password: SuperAdmin123!

Regular Admin:

  • Email: admin@bloghub.com
  • Password: Admin123!

Test User:

  • Email: user@bloghub.com
  • Password: User123!

⚠️ Security Note: Change default passwords in production!

πŸ“Š Performance Metrics

Application Performance

  • Frontend Load Time: < 2 seconds
  • API Response Time: < 200ms average
  • Database Query Time: < 100ms average
  • SEO Score: 90+ (Lighthouse)
  • Accessibility Score: 95+ (WCAG AA)

Scalability Features

  • Horizontal Scaling: Stateless backend design
  • Database Sharding: MongoDB cluster support
  • CDN Ready: Static asset optimization
  • Caching Layer: Redis integration ready
  • Load Balancing: Multiple instance support

πŸ“ˆ Roadmap & Future Features

Version 2.0 (Coming Soon)

  • πŸ”„ Real-time Collaboration: Live editing and comments
  • πŸ“Š Advanced Analytics: Detailed content performance metrics
  • 🌐 Multi-language Support: Internationalization (i18n)
  • πŸ“± Mobile App: React Native mobile application
  • πŸ”” Push Notifications: Real-time user notifications
  • πŸ“§ Email Integration: Newsletter and notifications
  • 🎨 Theme Customization: Custom blog themes and layouts

Version 2.5

  • πŸ€– AI Content Assistance: AI-powered writing suggestions
  • πŸ” Advanced Search: Elasticsearch integration
  • πŸ’° Monetization: Ad management and premium features
  • πŸ”— API Marketplace: Third-party integrations
  • πŸ“ˆ A/B Testing: Content optimization tools

🀝 Contributing

We welcome contributions from the community! Please read our contributing guidelines:

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

Development Workflow

  • Create issues for bugs and feature requests
  • Follow conventional commit message format
  • Ensure tests pass before submitting PR
  • Update documentation for new features

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Team & Credits

Project Lead: Omkar Korgaonkar
Organization: Zidio Development
Project Type: Full-Stack MERN Development

Acknowledgments

  • Tiptap team for the excellent rich text editor
  • MongoDB team for the robust database solution
  • React and Vite teams for the development framework
  • Tailwind CSS for the utility-first CSS framework

Made by the Omkar Korgaonkar

🌟 Star this repository if you found it helpful!
πŸ› Found a bug? Report it here
πŸ’‘ Have suggestions? Start a discussion

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages