Social Media Project is a Spring Boot backend application implementing core social media functionalities such as user management, posts, likes, and comments. The project follows a layered architecture and uses REST APIs, JPA (Hibernate), JWT-based authentication, and PostgreSQL for data persistence.
- User registration and login
- JWT-based authentication and authorization
- Create, update, and delete posts
- Like and unlike posts
- Add and manage comments
- Secure APIs using Spring Security
- Global exception handling
- Database operations using Spring Data JPA and Hibernate
Controller → Service → Repository → Database
- Controller Layer: Handles REST API requests and responses
- Service Layer: Contains business logic
- Repository Layer: Performs database operations using JPA
- Model Layer: Defines entity classes mapped to database tables
- Java 21
- Spring Boot
- Spring Security
- JWT (JSON Web Token)
- Spring Data JPA
- Hibernate
- PostgreSQL
- Maven
- User logs in using
/auth/login - Server validates credentials
- JWT token is generated and returned
- Client sends token in the Authorization header
- JwtFilter validates the token for secured endpoints
Example header:
Authorization: Bearer <JWT_TOKEN>
- AuthController
- UserController
- PostController
- LikeController
- CommentController
- SecurityConfig
- JwtFilter
- JwtUtil
- CustomUserDetailsService
- GlobalExceptionHandler
- ResourceNotFoundException
- ErrorResponse
- User
- Post
- Comment
- Like
- Clone the repository:
git clone <repository-url>
-
Open the project in IntelliJ IDEA or Eclipse.
-
Configure PostgreSQL database settings in
application.properties. -
Run:
SocialMediaProjectApplication.java
Use Postman to test APIs.
Sample endpoints:
- POST /auth/login
- POST /posts
- GET /posts
- POST /likes
- POST /comments
- Pagination for posts
- Image upload support
- Notification system
- Role-based admin access
- Microservice architecture
Developed as a backend project to implement real-world social media functionality using Spring Boot.