A full-stack MERN (MongoDB, Express.js, React.js, Node.js) blog application that allows users to create, read, update, and delete blog posts with user authentication and image uploads.
- User Registration: Create new accounts with secure password hashing
- User Login: JWT-based authentication system
- Session Management: Persistent login sessions with refresh tokens
- Protected Routes: Route protection for authenticated users only
- Create Posts: Rich text editor for creating engaging blog posts
- Read Posts: Browse and view all published blog posts
- Update Posts: Edit your own published posts
- Delete Posts: Remove posts with proper authorization
- Categories: Organize posts by categories for better navigation
- Image Upload: Upload cover images for blog posts
- Image Preview: Real-time image preview before publishing
- GridFS Storage: Efficient image storage using MongoDB GridFS
- Comments System: Users can comment on blog posts
- Responsive Design: Mobile-friendly interface
- User Profiles: Author information display
- Modern Design: Clean and intuitive user interface
- Material-UI Components: Professional UI components
- Responsive Layout: Works seamlessly on all devices
- Dark/Light Theme Support: User preference-based theming
- React 19: Latest React version with hooks
- Material-UI (MUI): Component library for beautiful UI
- React Router DOM: Client-side routing
- Axios: HTTP client for API requests
- Vite: Fast build tool and development server
- Node.js: JavaScript runtime environment
- Express.js: Web application framework
- MongoDB: NoSQL database
- Mongoose: MongoDB object modeling
- JWT: JSON Web Tokens for authentication
- Bcrypt: Password hashing
- Multer: File upload handling
- GridFS: File storage system
Blog App/
βββ blogging-app/ # Frontend React application
β βββ public/ # Static assets
β βββ src/
β β βββ components/ # React components
β β β βββ account/ # Login/Signup components
β β β βββ banner/ # Hero banner component
β β β βββ create/ # Post creation components
β β β βββ details/ # Post detail view
β β β βββ header/ # Navigation header
β β β βββ home/ # Home page components
β β β βββ common/ # Shared components
β β βββ constants/ # Configuration constants
β β βββ context/ # React context providers
β β βββ service/ # API service functions
β β βββ utils/ # Utility functions
β βββ package.json
β βββ vite.config.js
β
βββ server/ # Backend Node.js application
β βββ controller/ # Route controllers
β βββ database/ # Database configuration
β βββ middleware/ # Custom middleware
β βββ model/ # Mongoose models
β βββ routes/ # API routes
β βββ package.json
β βββ index.js # Server entry point
β
βββ README.md # Project documentation
- Node.js (v18 or higher)
- MongoDB (local installation or MongoDB Atlas)
- Git
git clone https://github.com/prachipatilcloud/Blog-Application.git
cd Blog-Application# Navigate to server directory
cd server
# Install dependencies
npm install
# Create environment file
cp .env.example .env
# Configure your environment variables in .env:
# PORT=8000
# MONGODB_URI=mongodb://localhost:27017/blogapp
# JWT_SECRET=your_jwt_secret_key
# JWT_REFRESH_SECRET=your_refresh_secret_key
# Start the backend server
npm start# Navigate to frontend directory
cd ../blogging-app
# Install dependencies
npm install
# Start the development server
npm run dev- Frontend: http://localhost:5173
- Backend: http://localhost:8000
Create a .env file in the server directory with the following variables:
PORT=your_preferred_port
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_strong_jwt_secret
JWT_REFRESH_SECRET=your_strong_refresh_secret- Never commit your
.envfile to version control - Use strong, unique secrets for JWT tokens
- Keep your MongoDB connection string secure
POST /api/signup- User registrationPOST /api/login- User loginPOST /api/logout- User logoutPOST /api/token- Refresh access token
GET /api/posts- Get all postsGET /api/post/:id- Get single postPOST /api/create- Create new postPUT /api/update/:id- Update postDELETE /api/delete/:id- Delete post
GET /api/comments/:id- Get comments for postPOST /api/comment/new- Add new commentDELETE /api/comment/delete/:id- Delete comment
POST /api/file/upload- Upload imageGET /api/file/:filename- Get uploaded file
- Register/Login to your account
- Navigate to "Create Post"
- Add a title and content
- Upload a cover image (optional)
- Select a category
- Click "Publish"
- Visit the home page
- Browse posts by category
- Click on any post to read the full content
- View comments and add your own
- View your published posts
- Click "Edit" to modify content
- Use "Delete" to remove posts
- Track engagement through comments
- Fork the repository
- Create a 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
This project is licensed under the ISC License - see the LICENSE file for details.
Prachi Patil
- GitHub: @prachipatilcloud
- LinkedIn: Prachi Patil
- Material-UI team for the amazing component library
- MongoDB team for the robust database solution
- React team for the powerful frontend framework
- Express.js team for the flexible backend framework
If you have any questions or need help with the project, please feel free to:
- Open an issue on GitHub
- Contact me through LinkedIn
β Star this repository if you found it helpful!