A modern, full-stack blog application built with the MERN stack (MongoDB, Express.js, React.js, Node.js) featuring a beautiful UI, real-time interactions, and comprehensive admin dashboard.
- Modern UI/UX: Beautiful, responsive design with dark/light theme support
- Blog Reading: Browse and read blog posts with rich text formatting
- Search & Filter: Advanced search functionality with category filtering
- User Authentication: Secure sign-up/sign-in with JWT tokens
- Comments System: Interactive commenting system with real-time updates
- User Profiles: Personalized user profiles and settings
- Dashboard: Comprehensive admin dashboard with analytics
- Post Management: Create, edit, and delete blog posts with rich text editor
- User Management: Manage users, roles, and permissions
- Comment Moderation: Moderate and manage user comments
- Content Analytics: Track post views, engagement, and user activity
- Rate Limiting: API rate limiting to prevent abuse
- Helmet Security: Enhanced security headers
- Input Validation: Comprehensive input validation and sanitization
- Error Handling: Robust error handling and logging
- Compression: Gzip compression for better performance
- React 18 - Modern React with hooks and functional components
- Vite - Fast build tool and development server
- Tailwind CSS - Utility-first CSS framework
- Material-UI - React component library
- Redux Toolkit - State management
- React Router - Client-side routing
- React Quill - Rich text editor
- React Icons - Icon library
- Node.js - JavaScript runtime
- Express.js - Web application framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- JWT - JSON Web Tokens for authentication
- bcryptjs - Password hashing
- Multer - File upload handling
- ESLint - Code linting
- Nodemon - Development server with auto-reload
- Morgan - HTTP request logger
- CORS - Cross-origin resource sharing
- Node.js (v18 or higher)
- MongoDB (local or Atlas)
- npm or yarn
-
Clone the repository
git clone https://github.com/engmaryamameen/mern_blog cd mern-blog
-
Install dependencies
# Install server dependencies npm install # Install client dependencies cd client npm install cd ..
-
Environment Configuration
Create a
.env
file in theapi
directory:MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret_key NODE_ENV=development CLIENT_URL=http://localhost:5173 PORT=3000
-
Database Setup
- Set up a MongoDB database (local or MongoDB Atlas)
- Update the
MONGODB_URI
in your.env
file
npm run dev
npm run build
npm start
# Start backend only
npm run dev
# Start frontend only (in client directory)
cd client
npm run dev
mern-blog/
βββ api/ # Backend server
β βββ controllers/ # Route controllers
β βββ models/ # MongoDB models
β βββ routes/ # API routes
β βββ utils/ # Utility functions
β βββ index.js # Server entry point
βββ client/ # Frontend React app
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ redux/ # Redux store and slices
β β βββ App.jsx # Main app component
β βββ package.json
βββ package.json
POST /api/auth/signup
- User registrationPOST /api/auth/signin
- User loginGET /api/auth/signout
- User logout
GET /api/user/profile
- Get user profilePUT /api/user/update/:userId
- Update user profileDELETE /api/user/delete/:userId
- Delete user (admin only)
GET /api/post/getposts
- Get all postsGET /api/post/getpost/:slug
- Get single postPOST /api/post/create
- Create new post (admin only)PUT /api/post/updatepost/:postId
- Update post (admin only)DELETE /api/post/deletepost/:postId
- Delete post (admin only)
POST /api/comment/create
- Create commentGET /api/comment/getcomments/:postId
- Get post commentsPUT /api/comment/editcomment/:commentId
- Edit commentDELETE /api/comment/deletecomment/:commentId
- Delete comment
- Uses React Quill for creating and editing blog posts
- Supports formatting, images, and embedded content
- Real-time preview and auto-save functionality
- JWT-based authentication with secure token storage
- Protected routes for admin and user areas
- Password hashing with bcryptjs
- Mobile-first approach with Tailwind CSS
- Dark/light theme support
- Optimized for all device sizes
- Comprehensive analytics and user management
- Post creation and editing interface
- Comment moderation tools
- User role management
- Fork the repository
- Create a feature branch (
git checkout -b feature/feature_branch
) - Commit your changes (
git commit -m 'Add some Feature'
) - Push to the branch (
git push origin feature/feature_branch
) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
- React - Frontend framework
- Express.js - Backend framework
- MongoDB - Database
- Tailwind CSS - CSS framework
- Material-UI - Component library
If you have any questions or need help, please open an issue on GitHub or contact the maintainers.
β Star this repository if you found it helpful!