Blog App Backend is a Spring Boot-based RESTful application that provides a secure, scalable, and role-based API for managing blogs. It supports user registration, authentication, blog creation, retrieval, and deletion with role-based access control.
The application uses MySQL for persistent storage, Redis caching for performance, and includes Swagger API documentation along with unit tests using JUnit and Mockito.
- User registration and login with secure password handling.
- JWT-based authentication for stateless security.
- Role-based authorization:
USERandADMIN.
- Create your own blog posts.
- View blogs created by others.
- Delete only your own blogs (enforced by security rules).
- Spring Security integration with JWT authentication.
- Fine-grained role-based access control for sensitive operations.
- Redis caching for frequently accessed blog data to improve performance.
- Swagger UI for easy API testing and documentation.
- Unit tests using JUnit.
- Mockito for mocking dependencies in service and controller layers.
| Layer | Technology |
|---|---|
| Backend | Spring Boot |
| Security | Spring Security, JWT |
| Database | MySQL (local) |
| Caching | Redis |
| ORM | Spring Data JPA / Hibernate |
| API Docs | Swagger |
| Testing | JUnit, Mockito |
| Build Tool | Maven |
- Clone the repository:
git clone <your-repo-url>
- Configure MySQL database:
- Create a database (e.g.,
blog_db). - Update
application.propertieswith your MySQL credentials.
- Create a database (e.g.,
- Run Redis locally or via Docker:
docker run --name redis -p 6379:6379 -d redis
- Start the application:
mvn spring-boot:run
- Access Swagger UI:
http://localhost:8080/swagger-ui/index.html