Skip to content

sush1998/Blog-Management-System

Repository files navigation

๐Ÿ“ Blog Management System

Node.js Express SQLite License: MIT Status

A full-stack web application built using Node.js, Express.js, SQLite3, and vanilla HTML/CSS/JavaScript that allows users to register, log in, write blogs, and comment on posts. The system supports role-based access (authors vs. readers), blog/comment CRUD operations, and dynamic sorting of blog posts.


๐Ÿš€ Live Demo

๐ŸŒ Live Website/ Backend API on Railway


๐Ÿ“ธ Features at a Glance

  • ๐Ÿ‘ฅ User Authentication
    • Register/Login functionality
    • Secure password hashing using bcryptjs
    • JWT-based authentication
  • ๐Ÿง‘โ€๐Ÿ’ป Role-Based Access
    • Authors can create, edit, delete blogs
    • Readers can add, edit, delete comments
  • ๐Ÿ“ฐ Blog Management
    • Display blogs by all authors
    • Each blog shows title, content, timestamp, author name
  • ๐Ÿ’ฌ Commenting System
    • Readers can engage by commenting on blog posts
    • Edit/delete own comments
  • ๐Ÿ“Š Sorting
    • Sort blogs by date (ascending/descending)
    • Sort blogs by number of comments
  • ๐Ÿ“ฑ Responsive UI
    • Mobile-first design with modern layout and color palette

๐Ÿ“ Project Structure

Blog-Management-System/
โ”‚
โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ home.html
โ”‚   โ”œโ”€โ”€ login.html
โ”‚   โ”œโ”€โ”€ register.html
โ”‚   โ”œโ”€โ”€ write-blog.html
โ”‚   โ”œโ”€โ”€ styles.css
โ”‚   โ””โ”€โ”€ script.js
โ”‚
โ”œโ”€โ”€ routes/
โ”‚   โ”œโ”€โ”€ authRoutes.js
โ”‚   โ”œโ”€โ”€ blogRoutes.js
โ”‚   โ””โ”€โ”€ commentRoutes.js
โ”‚
โ”œโ”€โ”€ database.js
โ”œโ”€โ”€ server.js
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ README.md

API Endpoints Summary The Blog Management System exposes a RESTful API for user authentication, blog post management, and user role-based access control.

๐Ÿ” Authentication (/auth)

Method Endpoint Description
POST /auth/register Register a new user
POST /auth/login Authenticate user and get JWT

๐Ÿ“ Blog Management (/blogs)

Method Endpoint Description
GET /blogs/ Retrieve all blog posts
GET /blogs/:id Get a single blog post by ID
POST /blogs/ Create a new blog post (auth)
PUT /blogs/:id/ Update an existing post (auth)
DELETE /blogs/:id/ Delete a post by ID (auth)

๐Ÿ›ก๏ธ Create, update, and delete operations require a valid JWT token.

๐Ÿ’ฌ Comments API (/comments)

Method Endpoint Description
POST /comments/ Add a comment to a blog post (auth required)
GET /comments/:blog_id Fetch all comments for a specific blog post
PUT /comments/:id Update a comment(must be owner of the comment)
DELETE /comments/:id Delete a comment(must be owner of the comment)

๐Ÿ› ๏ธ Tech Stack

  • Frontend: HTML, CSS, JavaScript (Vanilla)
  • Backend: Node.js, Express.js
  • Database: SQLite3
  • Authentication: JWT, bcryptjs
  • Hosting: GitHub Pages (Frontend), Railway.app (Backend)

๐Ÿงช Test Cases

Feature Scenario Status
User Login Valid & invalid credentials โœ…
Blog Creation Author can post/edit/delete blogs โœ…
Comment System Reader can add/edit/delete comments โœ…
Sorting Blogs Toggle between time & comment-based sorting โœ…
Role-Based Access Buttons/Access change based on user role โœ…
Responsiveness Works on mobile, tablet, desktop โœ…

๐Ÿ”’ Security

  • Passwords are hashed using bcryptjs
  • Authentication is managed via JWT tokens
  • Role-based UI ensures unauthorized actions are blocked

๐Ÿ”ฎ Future Enhancements

  • Migrate from SQLite to PostgreSQL for scalability
  • Implement Admin Dashboard for moderation
  • Enhance frontend with React.js
  • Add Real-Time Notifications
  • Set up automated testing using Jest/Cypress

๐Ÿ“ท Screenshots

๐Ÿ” Login Page

Login Page

๐Ÿ“ Home Page with Blogs

Home Page

๐Ÿง‘โ€๐Ÿ’ป Write a Blog (Author Only)

Write Blog

๐Ÿ’ฌ Comments Section

Comments

๐Ÿ”ฝ Sort Feature (Time & Comments)

Sorting


๐Ÿง‘โ€๐Ÿ’ป Getting Started

โœ… Prerequisites

  • Node.js & npm installed

๐Ÿ“ฆ Installation

git clone https://github.com/your-username/Blog-Management-System.git
cd Blog-Management-System
npm install

โš™๏ธ Set Environment Variables

Create a .env file:

JWT_SECRET=your_jwt_secret
PORT=5000

โ–ถ๏ธ Run the App

node server.js

Then open public/home.html in your browser (or serve with Live Server)


๐Ÿค Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.


๐Ÿ“„ License

This project is open-source and available under the MIT License.


โœจ Acknowledgements

About

This project aims to build a web-based blog management system where authors can create blogs, and readers can post comments. The system is developed using Node.js with Express and SQLite3.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors