π https://the-blog-hub-xi.vercel.app/
A modern, feature-rich blogging platform built with the MERN stack
Features β’ Tech Stack β’ Installation β’ Environment Variables β’ Usage β’
- Overview
- Features
- Tech Stack
- Prerequisites
- Installation
- Environment Variables
- Usage
- Project Structure
- API Endpoints
- Contributing
WriteStack is a comprehensive blogging platform that empowers users to create, share, and engage with blog content. Built with modern web technologies, it offers a seamless experience for both content creators and readers.
- π Rich Text Editing - CKEditor 5 for professional content creation
- π₯ User Authentication - Secure JWT-based authentication with Google OAuth
- π Real-time Notifications - Stay updated with likes and comments
- π Admin Dashboard - Comprehensive analytics and user management
- π¨ Modern UI - Beautiful, responsive design with Tailwind CSS
- πΎ Auto-save Drafts - Never lose your content with automatic draft saving
- π± Responsive Design - Perfect experience across all devices
- JWT Authentication - Secure token-based authentication
- Google OAuth - One-click social login
- User Profiles - Customizable user profiles with avatars
- Password Reset - Email-based password recovery
- Role-based Access - Admin and user role separation
- Rich Text Editor - Powerful CKEditor 5 with extensive formatting options
- Auto-save Drafts - Automatic saving prevents content loss
- Image Upload - Cloudinary integration for optimized image hosting
- Category Organization - Organize blogs into categories
- Slug Generation - SEO-friendly URLs
- Featured Images - Eye-catching blog covers
- Smart Updates (PUT & PATCH) - Full updates with PUT and efficient partial updates with PATCH
- Like System - Express appreciation for blogs
- Comments - Rich commenting system with replies
- Real-time Notifications - Instant updates on interactions
- Comment Counts - Track engagement metrics
- Advanced Search - Find blogs instantly
- Category Filtering - Browse by topics
- Related Blogs - Discover similar content
- Dashboard Analytics - Comprehensive statistics and insights
- User Management - Full user administration
- Report Generation - Download reports in PDF, Excel, and Word formats
- Category Management - Create and manage blog categories
- Charts & Graphs - Visual data representation
- User Trend Analysis - Track growth metrics
- Modern Design - Clean and intuitive interface
- Responsive Layout - Mobile-first approach
- Dark Mode Ready - Easy theming support
- Loading States - Smooth user experience
- Toast Notifications - User-friendly feedback
- Static About & Contact Pages - Header links that load backend-rendered pages without a full reload
| Technology | Version | Purpose |
|---|---|---|
| React | 18.3.1 | UI Framework |
| Vite | 6.3.5 | Build Tool |
| React Router | 7.1.0 | Routing |
| Redux Toolkit | 2.5.0 | State Management |
| CKEditor 5 | 44.1.0 | Rich Text Editor |
| Tailwind CSS | 3.4.17 | Styling |
| Radix UI | Latest | Component Library |
| React Hook Form | 7.54.2 | Form Management |
| Zod | 3.24.1 | Schema Validation |
| Recharts | 2.15.2 | Data Visualization |
| React Toastify | 11.0.2 | Notifications |
| Date-fns | 4.1.0 | Date Formatting |
| Moment.js | 2.30.1 | Date Utilities |
| Technology | Version | Purpose |
|---|---|---|
| Node.js | Latest | Runtime Environment |
| Express.js | 4.21.2 | Web Framework |
| Morgan | Latest | HTTP request logging |
| MongoDB | Latest | Database |
| Mongoose | 8.9.2 | ODM |
| JWT | 9.0.2 | Authentication |
| Bcrypt | 2.4.3 | Password Hashing |
| Cloudinary | 1.30.0 | Image Storage |
| Multer | 2.0.2 | File Upload |
| Nodemailer | 6.10.1 | Email Service |
| PDFKit | Latest | PDF Generation |
| XLSX | 0.18.5 | Excel Export |
| Docx | 9.3.0 | Word Export |
- Firebase - Google Authentication
- Lodash - Utility functions
- Entities - HTML entity decoding
- Slugify - URL slug generation
- Cookie Parser - Cookie management
- CORS - Cross-origin resource sharing
- HTTP PATCH - Partial blog updates for edit flows
- Static HTML pages - About/Contact pages served from the backend and injected into the React app
Before you begin, ensure you have met the following requirements:
- Node.js (v16 or higher)
- MongoDB (local or cloud instance)
- npm or yarn package manager
- Cloudinary account (for image storage)
- Google Cloud Console project (for OAuth)
- Email SMTP credentials (for password reset)
git clone https://github.com/your-username/MERN_BLOG.git
cd MERN_BLOGcd api
npm installcd ../client
npm installCreate a .env file in the api directory:
# Server Configuration
PORT=5000
# MongoDB Configuration
MONGODB_CONN=your_mongodb_connection_string
# JWT Configuration
JWT_SECRET=your_jwt_secret_key
# Frontend URL
FRONTEND_URL=http://localhost:5173
# Cloudinary Configuration
CLOUDINARY_APP_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
# Email Configuration (Optional)
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_email_passwordCreate a .env file in the client directory:
# API Base URL
VITE_API_BASE_URL=http://localhost:5000/api
# Firebase Configuration (Optional, for Google OAuth)
VITE_FIREBASE_API_KEY=your_firebase_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain
VITE_FIREBASE_PROJECT_ID=your_firebase_project_idcd api
npm run devThe server will start on http://localhost:5000
cd client
npm run devThe application will be available at http://localhost:5173
cd client
npm run buildcd api
npm startMERN_BLOG/
βββ api/ # Backend API
β βββ config/ # Configuration files
β β βββ cloudinary.js # Cloudinary setup
β β βββ multer.js # File upload config
β βββ controllers/ # Route controllers
β β βββ Admin.controller.js # Admin operations
β β βββ Auth.controller.js # Authentication
β β βββ Blog.controller.js # Blog CRUD
β β βββ Category.controller.js
β β βββ Comment.controller.js
β β βββ Draft.controller.js
β β βββ Notification.controller.js
β β βββ User.controller.js
β βββ middleware/ # Custom middleware
β β βββ auth.middleware.js
β β βββ authenticate.js
β β βββ onlyadmin.js
β β βββ upload.middleware.js
β βββ models/ # MongoDB models
β β βββ ban.model.js
β β βββ blog.model.js
β β βββ category.model.js
β β βββ comment.model.js
β β βββ draft.model.js
β β βββ like.model.js
β β βββ notification.model.js
β β βββ resetToken.model.js
β β βββ user.model.js
β βββ routes/ # API routes
β β βββ Admin.route.js
β β βββ Auth.route.js
β β βββ Blog.route.js
β β βββ Category.route.js
β β βββ Comment.route.js
β β βββ Draft.route.js
β β βββ notification.routes.js
β β βββ User.route.js
β βββ helpers/ # Helper functions
β βββ utils/ # Utility functions
β β βββ email.js
β βββ index.js # Server entry point
β
βββ client/ # Frontend React App
β βββ public/ # Static assets
β βββ src/
β β βββ assets/ # Images and static files
β β βββ components/ # React components
β β β βββ ui/ # Reusable UI components
β β β βββ AppSidebar.jsx
β β β βββ AuthRouteProtechtion.jsx
β β β βββ BlogCard.jsx
β β β βββ Comment.jsx
β β β βββ CommentList.jsx
β β β βββ Editor.jsx
β β β βββ NotificationDropdown.jsx
β β β βββ Topbar.jsx
β β β βββ ...
β β βββ helpers/ # Helper functions
β β βββ hooks/ # Custom React hooks
β β βββ Layout/ # Layout components
β β βββ pages/ # Page components
β β β βββ Admin/ # Admin pages
β β β β βββ Dashboard.jsx
β β β βββ Blog/ # Blog pages
β β β βββ Category/ # Category pages
β β β βββ Index.jsx
β β β βββ Login.jsx
β β β βββ Profile.jsx
β β β βββ SearchResult.jsx
β β β βββ ...
β β βββ redux/ # Redux store
β β βββ App.jsx # Main app component
β β βββ main.jsx # App entry point
β βββ package.json
β
βββ README.md # This file
POST /api/auth/signup # User registration
POST /api/auth/signin # User login
POST /api/auth/logout # User logout
POST /api/auth/google # Google OAuth
POST /api/auth/forgot-password # Request password reset
POST /api/auth/reset-password # Reset password
GET /api/blog/blogs # Get all blogs
GET /api/blog/get-blog/:slug # Get single blog by slug
POST /api/blog/add # Create blog
PUT /api/blog/update/:blogid # Full update (all fields)
PATCH /api/blog/patch-update/:blogid # Partial update (only changed fields)
DELETE /api/blog/delete/:blogid # Delete blog
GET /api/category/all-category # Get all categories
GET /api/category/:id # Get single category
POST /api/category/add # Create category (Admin only)
PUT /api/category/update/:id # Update category (Admin only)
DELETE /api/category/delete/:id # Delete category (Admin only)
GET /api/comment/get/:blogid # Get comments for blog
POST /api/comment/add # Add comment
PUT /api/comment/update/:id # Update comment
DELETE /api/comment/delete/:id # Delete comment
GET /api/drafts # Get user's draft
POST /api/drafts # Save draft
PUT /api/drafts # Update draft
DELETE /api/drafts # Delete draft
GET /api/notifications # Get notifications
PATCH /api/notifications/:id/read # Mark a single notification as read
PATCH /api/notifications/read-all # Mark all notifications as read
GET /api/admin/dashboard # Get dashboard data
GET /api/admin/download-report/:type/:format # Download reports
GET /api/admin/users # Get all users
PUT /api/admin/ban-user/:id # Ban user
PUT /api/admin/unban-user/:id # Unban user
Contributions are always welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Your Name
- GitHub: @WriteStack
- Email: harshwadhani268@gmail.com
- CKEditor team for the amazing rich text editor
- Tailwind CSS for the utility-first CSS framework
- All the open-source contributors
- MongoDB for the robust database solution
- Cloudinary for seamless image hosting
Made with β€οΈ using the MERN Stack
β Star this repo if you found it helpful!