Skip to content

A backend project that enables users to create posts, like and comment on content, and manage their posts and comments by deleting them.

Notifications You must be signed in to change notification settings

Zubair7102/blog_app-backend

Repository files navigation

Blog App - Backend System

Project Overview

The Blog App backend system provides a robust platform for managing blog posts and user interactions. It includes features for creating, liking, commenting on, and managing blog posts, with secure authentication and authorization mechanisms to ensure proper access control.


Features

  1. 📝 Blog Post Management:

    • Users can create, read, update, and delete blog posts.
    • Posts can be liked by authenticated users.
  2. 💬 Comment Management:

    • Users can add comments to blog posts.
    • Full CRUD (Create, Read, Update, Delete) functionality for comments.
  3. 🔒 User Authentication & Authorization:

    • Secure login and signup mechanisms using JWT-based authentication.
    • Role-based access control to restrict actions based on user permissions.
  4. ⚡ Performance Optimization:

    • API endpoints optimized for scalability and responsiveness.
    • Designed for efficient handling of large datasets and concurrent requests.

API Endpoints

Blog Posts

  • POST /api/posts - Create a new blog post.
  • GET /api/posts - Retrieve all blog posts.
  • GET /api/posts/:id - Retrieve a single blog post by ID.
  • PUT /api/posts/:id - Update an existing blog post.
  • DELETE /api/posts/:id - Delete a blog post.

Comments

  • POST /api/posts/:id/comments - Add a comment to a blog post.
  • GET /api/posts/:id/comments - Retrieve all comments for a blog post.
  • PUT /api/comments/:id - Update an existing comment.
  • DELETE /api/comments/:id - Delete a comment.

Authentication

  • POST /api/auth/signup - Register a new user.
  • POST /api/auth/login - Login an existing user.

Likes

  • POST /api/posts/:id/like - Like a blog post.

Technology Stack

  • 🖥️ Backend Framework: Node.js with Express.js
  • 🗄️ Database: MongoDB
  • 🔑 Authentication: JSON Web Tokens (JWT)
  • ⚙️ Middleware: Custom middleware for error handling and user role validation
  • 🛠️ Tools & Libraries:
    • Mongoose for database modeling
    • Bcrypt for password hashing
    • Express-validator for input validation

Installation and Setup

  1. 📂 Clone the repository:

    git clone <repository-url>
    cd blog-app-backend
  2. 📦 Install dependencies:

    npm install
  3. ⚙️ Set up environment variables: Create a .env file in the root directory and configure the following:

    PORT=5000
    MONGO_URI=<your-mongodb-connection-string>
    JWT_SECRET=<your-jwt-secret>
  4. 🚀 Start the development server:

    npm run dev
  5. 🌐 Access the API at http://localhost:5000.


Folder Structure

blog-app-backend/
├── config/
│   └── database.js
├── controllers/
│   ├── commentController.js
│   ├── likeController.js
│   └── postController.js
├── models/
│   ├── commentModel.js
│   ├── likeModel.js
│   └── postModel.js
├── routes/
│   └── blog.js
├── .env
├── index.js
├── package.json
└── package-lock.json

About

A backend project that enables users to create posts, like and comment on content, and manage their posts and comments by deleting them.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published