This project is a full-featured blog web application built using the MERN stack (MongoDB, Express, React, Node.js). It allows users to create, read, update, and delete blog posts. The application also includes user authentication and authorization, enabling users to manage their own posts securely.
- Features
- Demo
- Installation
- Usage
- API Endpoints
- Technologies Used
- Folder Structure
- Contributing
- License
- User authentication (signup, login, logout)
- Create, read, update, and delete blog posts
- View a list of all blog posts
- View individual blog post details
- Responsive design for mobile and desktop
Check out the live demo: MERN Blog Web App Demo
Follow these steps to set up the project locally:
-
Clone the repository:
git clone git@github.com:rohitkumar4826/mern-blog.git cd mern-blog -
Install backend dependencies:
cd api npm install -
Install frontend dependencies:
cd ../client npm install -
Set up environment variables:
Create a
.envfile in thebackenddirectory and add the following variables:PORT=3000 MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret
-
Run the development server:
Start the backend server:
cd api npm startStart the frontend development server:
cd client npm start -
Open the app:
Navigate to
http://localhost:3000in your browser to see the application in action.
- Register a new user or log in with an existing account.
- Create a new blog post using the "New Post" button.
- View a list of all blog posts on the home page.
- Click on a blog post to view its details.
- Edit or delete your own blog posts.
POST /api/auth/signup: Register a new user.POST /api/auth/signin: Log in an existing user.POST /api/auth/google: Log in user with google authentications.
GET /api/posts/getposts: Get all blog posts.POST /api/posts/create: Create a new blog post (authenticated).PUT /api/posts//updatepost/:postId/:userId: Update a blog post by ID (authenticated).DELETE /api/posts//deletepost/:postId/:userId: Delete a blog post by ID (authenticated).
-
Frontend:
- React
- Redux
- Fetch
- Tailwind CSS
- Flowbite CSS
-
Backend:
- Node.js
- Express
- MongoDB
- Mongoose
- JSON Web Tokens (JWT)
mern-blog/
├── api/
│ ├── controllers/
│ ├── models/
│ ├── routes/
| ├── utils/
│ ├── .env
│ ├── index.js
│ └── package.json
├── client/
│ ├── public/
│ ├── src/
│ │ ├── components/
│ │ ├── pages/
│ │ ├── redux/
│ │ ├── App.jsx
│ │ ├── firebase.js
│ │ ├── index.css
│ │ └── main.js
│ ├── .env
│ └── package.json
├── README.md
└── package.json