Skip to content

About

A simple blog app with authentication and CRUD features using the MERN stack.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

101 Commits

Folders and files

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

Repository files navigation

πŸ“ MERN Blog App

This is a full-stack blogging application developed using the MERN stackβ€”MongoDB, Express, React, and Node.js. It allows users to securely register and log in, create blog posts, edit existing content, and delete posts when needed.

The application implements JWT-based authentication to protect user data and restrict access to authorized actions. It also features dynamic routing for seamless navigation between pages, along with a responsive and user-friendly interface.

πŸ”— Live Site URL : Click Here

πŸš€ Deployment

  • Frontend: GitHub Pages
  • Backend: Render
  • Database: MongoDB Atlas

🧠 Tech Stack

  • Frontend: React, React Router, Context API, Axios
  • Backend: Node.js, Express.js
  • Database: MongoDB (with Mongoose)
  • Authentication: JSON Web Token (JWT)

✨ Features

  • Secure user authentication with registration and login
  • Full CRUD functionality for blog posts
  • Detailed individual post view
  • JWT based Authentication and Authorization
  • Context-based state management for posts and notifications
  • Fully Responsive User Interface
  • Support for Light and Dark themes
  • Like system for posts
  • Reusable global loader component
  • Menu dropdown for quick access to profile, dashboard and logout options
  • Account deletion option with confirmation handling

πŸ“ Project Structure

Blog-Post-App/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ authController.js
β”‚   β”‚   β”œβ”€β”€ commentController.js
β”‚   β”‚   β”œβ”€β”€ dashboardController.js
β”‚   β”‚   β”œβ”€β”€ postController.js
β”‚   β”‚   └── profileController.js
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── authMiddleware.js
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ Comment.js
β”‚   β”‚   β”œβ”€β”€ Post.js
β”‚   β”‚   └── User.js
β”‚   β”œβ”€β”€ package-lock.json
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ authRoutes.js
β”‚   β”‚   β”œβ”€β”€ commentRoutes.js
β”‚   β”‚   β”œβ”€β”€ dashboardRoutes.js
β”‚   β”‚   β”œβ”€β”€ postRoutes.js
β”‚   β”‚   └── profileRoutes.js
β”‚   └── server.js
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”œβ”€β”€ AuthContext.jsx
β”‚   β”‚   β”œβ”€β”€ LoaderContext.jsx
β”‚   β”‚   β”œβ”€β”€ NotificationContext.jsx
β”‚   β”‚   β”œβ”€β”€ PostsContext.jsx
β”‚   β”‚   └── ThemeContext.jsx
β”‚   β”œβ”€β”€ eslint.config.js
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package-lock.json
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ screenshots/
β”‚   β”‚   β”œβ”€β”€ AddPostPage.png
β”‚   β”‚   β”œβ”€β”€ Comment_Section.png
β”‚   β”‚   β”œβ”€β”€ EditPostPage.png
β”‚   β”‚   β”œβ”€β”€ HomePage.png
β”‚   β”‚   β”œβ”€β”€ HomePage_Login.png
β”‚   β”‚   β”œβ”€β”€ LoginPage.png
β”‚   β”‚   β”œβ”€β”€ PostDetails.png
β”‚   β”‚   └── RegisterPage.png
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Avatar/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Avatar.css
β”‚   β”‚   β”‚   β”‚   └── Avatar.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Comment/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Comment.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ CommentList.jsx
β”‚   β”‚   β”‚   β”‚   └── CommentStyles.css
β”‚   β”‚   β”‚   β”œβ”€β”€ Loader/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Loader.css
β”‚   β”‚   β”‚   β”‚   └── Loader.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.css
β”‚   β”‚   β”‚   β”‚   └── Navbar.jsx
β”‚   β”‚   β”‚   └── Notification/
β”‚   β”‚   β”‚       β”œβ”€β”€ Notification.css
β”‚   β”‚   β”‚       └── Notification.jsx
β”‚   β”‚   β”œβ”€β”€ main.jsx
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ CreatePost/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ CreatePost.css
β”‚   β”‚   β”‚   β”‚   └── CreatePost.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.css
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx
β”‚   β”‚   β”‚   β”‚   └── StatisticCard.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ EditPost/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ EditPost.css
β”‚   β”‚   β”‚   β”‚   └── EditPost.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ HomePage/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ HomePage.css
β”‚   β”‚   β”‚   β”‚   └── HomePage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Login/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Login.css
β”‚   β”‚   β”‚   β”‚   └── Login.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PostDetails/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ PostDetails.css
β”‚   β”‚   β”‚   β”‚   └── PostDetails.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Profile/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Profile.css
β”‚   β”‚   β”‚   β”‚   └── Profile.jsx
β”‚   β”‚   β”‚   └── Register/
β”‚   β”‚   β”‚       β”œβ”€β”€ Register.css
β”‚   β”‚   β”‚       └── Register.jsx
β”‚   β”‚   β”œβ”€β”€ styles.css
β”‚   β”‚   └── utils/
β”‚   β”‚       β”œβ”€β”€ axios.js
β”‚   β”‚       β”œβ”€β”€ formatDate.js
β”‚   β”‚       └── formatTime.js
β”‚   └── vite.config.js
└── README.md

βš™οΈ Setup Instructions

1. Clone the repository

git clone https://github.com/VRYeshwanth/Blog-Post-App.git
cd Blog-Post-App

2. Install Dependencies

Backend

cd backend
npm install

Frontend

cd frontend
npm install

3. Setup Environment Variables

Create a .env file inside the backend folder with the following content:

PORT=3000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key

4. Run the Application

Start backend server

cd backend
npm run dev

Start frontend

cd frontend
npm run dev

The app will run on :

  • Frontend: http://localhost:5173
  • Backend: http://localhost:3000

πŸ”— API Endpoints

πŸ” Authentication Routes

Method Endpoint Description
POST /api/auth/register Register a new user
POST /api/auth/login Log in an existing user

πŸ‘€ User / Profile Routes

Method Endpoint Description
GET /api/profile Get the logged-in user profile
PATCH /api/profile Update the profile details of the logged-in user
DELETE /api/profile Delete the user account

πŸ“ Post Routes

Method Endpoint Description
GET /api/posts Fetch all posts
POST /api/posts Create a new post
PATCH /api/posts/:id Update an existing post
DELETE /api/posts/:id Delete a post
PATCH /api/posts/:id/like Like or unlike a post

πŸ’¬ Comment Routes

Method Endpoint Description
GET /api/comments/:postId Fetch all comments of a given post
POST /api/comments Add a comment to a post
PATCH /api/comments/:id Update an existing comment
DELETE /api/comments/:id Delete a comment

πŸ“Š Dashboard Routes

Method Endpoint Description
GET /api/dashboard Fetch dashboard overview data

πŸ“Έ App Preview

Here are some screenshots of the MERN Blog App in action:

Home Page

Before Login:

Home Page

Register Page

Register Page

Login Page

Login Page

Home Page

After Login:

HomePage - Logged In

Post Details

Post Details

Add Post Page

Add Post Page

Edit Post Page

Edit Post Page

Comment Section

Comment Section

Profile Section

Profile Section

Dashboard Section

Dashboard Section

🀝 Contributing

Contributions are welcome!

If you'd like to improve this project:

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Submit a pull request

About

A simple blog app with authentication and CRUD features using the MERN stack.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages