This is the backend API of the Full Stack Blog Application. It handles user authentication, blog and community post management, comments, likes, notifications, and role-based access control using Spring Boot, Spring Security (with JWT), and Hibernate (JPA).
The backend follows a clean layered architecture:
Controller → Service → Repository → Entity
- Controller: Handles HTTP requests & routes
- Service: Business logic, authentication, authorization, validation
- Repository: Data access using Spring Data JPA
- Entity: Mapped to DB tables via Hibernate annotations
- Upon login, the user receives a JWT token.
- JWT is passed in the
Authorizationheader withBearer <token>. - Used to secure protected endpoints.
-
Signup (
/auth/signup)- Stores user details securely (password hashed)
- Profile picture upload supported
-
Login (
/auth/login)- Validates credentials
- Returns JWT on success
-
Spring Security Config:
- Custom
JwtAuthFilterextracts and validates tokens - Access granted based on roles (
ROLE_USER,ROLE_ADMIN) - Stateless session (RESTful)
- Custom
- Sign up / Login
- Create, edit, delete own blog posts
- Like / unlike posts
- Comment on posts
- Join / leave communities
- Create / delete community posts
- View notifications
- Search blogs and communities
- View and delete any blog, comment, or community
- Moderate community content
- View all users, posts, and metadata
- Java 17
- Spring Boot
- Spring Security (JWT)
- Hibernate (JPA)
- PostgreSQL
- Lombok
- Postman (for API testing)
POST /blogs– Create a blogGET /blogs– View all blogsGET /blogs/user– View own blogsPUT /blogs/{id}– Update own blogDELETE /blogs/{id}– Delete own blogGET /blogs/search?title=xyz– Search by title
POST /posts/{postId}/comment– Add commentGET /posts/{postId}/comments– View commentsPUT /posts/comments/{commentId}– Edit own commentDELETE /posts/comments/{commentId}– Delete own commentDELETE /posts/admin/comments/{commentId}– Admin delete comment
POST /posts/{postId}/like– Like a postDELETE /posts/{postId}/like– Unlike a post
- Triggered when a blog or community post is liked or commented on
GET /api/notifications– View user notificationsPUT /api/notifications/{id}/read– Mark as read- Delivered as toast popups in frontend via Observer pattern
POST /communities– Create a community (auto-joins creator)DELETE /communities/{id}– Delete owned communityPOST /communities/{id}/join– Join communityPOST /communities/{id}/leave– Leave communityGET /communities– View all communitiesGET /communities/joined– View joined communitiesGET /communities/{id}/members– View membersGET /communities/search?name=xyz– Search by name
POST /community-posts– Create community postGET /community-posts/by-community/{communityId}– View community postsGET /community-posts/by-user– View own community postsPUT /community-posts/{id}– Edit postDELETE /community-posts/{id}– Delete own postDELETE /community-posts/admin/{id}– Admin delete
- Manual testing via Postman
- All endpoints tested for:
- Unauthorized access
- Role-based restrictions
- Edge cases (e.g. deleting non-owned posts)
✅ Full implementation of JWT + Spring Security
✅ All entities properly mapped using JPA annotations
✅ Validation, error handling, and custom exceptions
✅ REST APIs follow best practices (HTTP verbs, status codes)
✅ Roles & permissions respected throughout all routes
✅ Notifications system built using Observer Pattern
✅ Clean architecture & well-separated concerns
- Create PostgreSQL DB and configure in
application.properties - Run the project with:
./mvnw spring-boot:run