This repository contains the backend of a Social Media API built with Spring Boot. The project is designed to provide core functionalities for a social media platform, such as user authentication, post creation, following system, likes, comments, and city-based categorization.
- User Authentication: Support for user registration and login (currently planned for future implementation with Spring Security).
- Follow System: Allows users to follow and unfollow each other.
- Post Creation: Users can create posts, which are associated with a city.
- Likes & Comments: Users can like and comment on posts.
- City-Based Categorization: Posts are tied to a city, allowing for location-based sorting.
- API Documentation: provided on 21 December 2024
- Authentication with Spring Security: Implementing authentication and authorization features using Spring Security in collaboration with the frontend will be added soon.
- Java 21 or above
- Spring Boot
- MySQL or another preferred database
-
Clone this repository:
git clone https://github.com/your-username/social-media-api.git cd social-media-api
-
Build the project:
./mvnw clean install
-
Configure your application properties (database connection, JWT secret, etc.) in
application.properties
. -
Run the application:
./mvnw spring-boot:run
-
The API will be accessible at
http://localhost:8080
.
- Authentication: Implement user login, registration, and secure endpoints using Spring Security.
- Frontend Integration: The API will be integrated with a frontend application, which will provide a user-friendly interface for interacting with the platform.
This project is licensed under the MIT License.
This document provides details about the REST APIs available in the Social Media application.
- User Management
- Post Management
- Comment Management
- Like System
- Follow System
- Report System
- City Management
Method | Endpoint | Description |
---|---|---|
GET | /users/ |
Retrieve all users |
POST | /users/ |
Create a new user |
GET | /users/{id} |
Get user by ID |
PUT | /users/{id} |
Update user details |
DELETE | /users/{id} |
Delete a user |
GET | /users/search?keyword={keyword} |
Search users by keyword |
{
"userID": "string",
"firstName": "string",
"lastName": "string",
"userName": "string",
"address": "string",
"gender": "string",
"dob": "date",
"avatarURL": "string"
}
Method | Endpoint | Description |
---|---|---|
GET | /posts/ |
Get all posts |
POST | /posts/ |
Create a new post |
GET | /posts/{id} |
Get post by ID |
PUT | /posts/{id} |
Update a post |
DELETE | /posts/{id} |
Delete a post |
GET | /posts/users/{userId} |
Get all posts by user |
GET | /posts/users/photos/{userId} |
Get user's photo posts |
GET | /posts/photos |
Get all photo posts |
{
"postID": "integer",
"user": "User object",
"city": "City object",
"imageURL": "string",
"content": "string",
"createDay": "datetime"
}
Method | Endpoint | Description |
---|---|---|
GET | /comment/ |
Get all comments |
POST | /comment/ |
Add a new comment |
DELETE | /comment/{id} |
Delete a comment |
GET | /comment/users/{userId} |
Get user's comments |
GET | /comment/posts/{postId} |
Get post's comments |
{
"commentID": "integer",
"post": "Post object",
"user": "User object",
"content": "string",
"imageURL": "string"
}
Method | Endpoint | Description |
---|---|---|
GET | /likepost/ |
Get all post likes |
POST | /likepost/ |
Create a post like |
GET | /likepost/{likePostID} |
Get specific like |
DELETE | /likepost/{likePostID} |
Remove a like |
GET | /likepost/users/{userId} |
Get user's likes |
GET | /likepost/posts/{postId} |
Get post's likes |
Method | Endpoint | Description |
---|---|---|
GET | /likecomment/ |
Get all comment likes |
POST | /likecomment/ |
Create a comment like |
GET | /likecomment/{likeCommentID} |
Get specific like |
DELETE | /likecomment/{likeCommentID} |
Remove a like |
GET | /likecomment/users/{userId} |
Get user's likes |
GET | /likecomment/comment/{commentID} |
Get comment's likes |
GET | /likecomment/totalLikes/{commentID} |
Get total likes for comment |
Method | Endpoint | Description |
---|---|---|
GET | /follows/ |
Get all follows |
POST | /follows/ |
Create a follow |
GET | /follows/{id} |
Get specific follow |
DELETE | /follows/{id} |
Remove a follow |
GET | /follows/target/{userId} |
Get user's followers |
GET | /follows/follower/{userId} |
Get user's following |
{
"followID": "integer",
"follower": "User object",
"userTarget": "User object"
}
Method | Endpoint | Description |
---|---|---|
GET | /reports/ |
Get all reports |
POST | /reports/ |
Create a report |
GET | /reports/{reportId} |
Get specific report |
PUT | /reports/{reportId} |
Update a report |
DELETE | /reports/{reportId} |
Delete a report |
GET | /reports/users/{userId} |
Get user's reports |
{
"reportID": "string",
"content": "string",
"typeReport": "enum(POST, COMMENT, USER)",
"idTarget": "string",
"userReport": "User object"
}
Method | Endpoint | Description |
---|---|---|
GET | /city/ |
Get all cities |
POST | /city/ |
Create a city |
GET | /city/{id} |
Get city by ID |
DELETE | /city/{id} |
Delete a city |
{
"cityID": "integer",
"cityName": "string",
"cityMapURL": "string"
}
Status Code | Description |
---|---|
200 | Success |
400 | Bad Request |
404 | Not Found |
Note: Will Add Soon