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

Packages

Used by

Contributors

Languages