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 Website/ Backend API on Railway
- ๐ฅ 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
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) |
- Frontend: HTML, CSS, JavaScript (Vanilla)
- Backend: Node.js, Express.js
- Database: SQLite3
- Authentication: JWT, bcryptjs
- Hosting: GitHub Pages (Frontend), Railway.app (Backend)
| 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 | โ |
- Passwords are hashed using
bcryptjs - Authentication is managed via
JWTtokens - Role-based UI ensures unauthorized actions are blocked
- 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
- Node.js & npm installed
git clone https://github.com/your-username/Blog-Management-System.git
cd Blog-Management-System
npm installCreate a .env file:
JWT_SECRET=your_jwt_secret
PORT=5000
node server.jsThen open public/home.html in your browser (or serve with Live Server)
Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.
This project is open-source and available under the MIT License.




