Skip to content

akashyadav2411/Blog-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blog Management System

A Spring Boot backend service for a blog platform with JWT authentication, PostgreSQL persistence, and Redis caching.

This repository contains the API layer, security setup, and data access logic for a blog app where users can create posts, leave comments, and search content.


Overview

The service supports:

  • user registration and login with JWT
  • role-based access control for users and admins
  • CRUD operations for posts and comments
  • text search, pageable post listings, and sorting
  • Redis caching for post retrieval
  • Swagger/OpenAPI documentation for the API

This project demonstrates backend application design using Spring Boot, Spring Security, Redis, PostgreSQL, and Docker. was built to practice secure Spring Boot architecture and API design.


Tech stack

  • Java 17
  • Spring Boot 3.3.2
  • Spring Security
  • Spring Data JPA + Hibernate
  • PostgreSQL 15
  • Redis 7
  • JWT with jjwt
  • Docker + Docker Compose
  • Springdoc OpenAPI / Swagger UI

Run the project

With Docker

git clone <repository-url>
cd Blog-management-system
cp .env.example .env
# update .env with your values

docker compose up --build

Then open:

  • http://localhost:8080 for the API
  • http://localhost:8080/swagger-ui.html for docs

Local setup

  1. Start PostgreSQL and Redis locally.
  2. Create the database:
createdb blogdb
  1. Create .env in the project root with the required values.
  2. Run the service:
mvn clean install
mvn spring-boot:run

Main endpoints

Authentication

  • POST /api/auth/register
  • POST /api/auth/login
  • POST /api/auth/refresh

Posts

  • GET /api/posts/paginated/all
  • GET /api/posts/search
  • GET /api/posts/author/{id}
  • GET /api/posts/{id}
  • POST /api/posts
  • PUT /api/posts/{id}
  • DELETE /api/posts/{id}

Comments

  • GET /api/posts/{postId}/comments
  • POST /api/posts/{postId}/comments
  • PUT /api/posts/{postId}/comments/{commentId}
  • DELETE /api/posts/{postId}/comments/{commentId}

Default admin account

A default admin user is created on first startup:


Project structure

Blog-management-system/
├── src/
│   ├── main/
│   │   ├── java/com/blog/management/
│   │   │   ├── config/
│   │   │   ├── controller/
│   │   │   ├── service/
│   │   │   ├── repository/
│   │   │   ├── entity/
│   │   │   ├── dto/
│   │   │   ├── exception/
│   │   │   ├── security/
│   │   │   └── util/
│   │   └── resources/
│   │       └── application.yml
│   └── test/
├── docker-compose.yml
├── Dockerfile
├── pom.xml
└── .env.example

Security notes

  • JWT for stateless auth
  • BCrypt for password hashing
  • Role-based access control
  • Sensitive settings loaded from environment variables

Configuration

Create a .env file with:

DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_NAME=blogdb
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=postgres
EMAIL_USERNAME=your-email@gmail.com
EMAIL_PASSWORD=your-app-password
REDIS_HOST=localhost
REDIS_PORT=6379
JWT_SECRET=your-secret-key

For Gmail email delivery, use an app password and enable 2FA on your Google account.


Documentation

The API docs are available at http://localhost:8080/swagger-ui.html.


License

MIT License.

About

A secure Blog Management System built with Spring Boot featuring JWT authentication, role-based access control, Redis caching, pagination, search, Docker containerization, and RESTful APIs.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages