Welcome to the Social Media RESTful API project! This API is designed as a test case for a social network, providing features such as user registration, login, post management, engagement with other users, subscriptions, and an activity feed.
Create a RESTful API for a social network that allows users to register, log in, create and handle posts, engage with other users, subscribe, and view an activity feed.
- Implement robust authentication and authorization using JWT for data security.
- Develop functionalities for managing posts, including creation, viewing, updating, and deletion, along with the capability to upload images.
- Provide user-centric features such as messaging, subscription options, and an activity feed to showcase recent posts from person whom the user is following.
- Ensure effective error handling mechanisms are in place, and thoroughly document the API for clarity and ease of use.
- Java 17
- Spring Boot (REST, Web, Security)
- Hibernate
- JSON Web Token (JWT)
- PostgreSQL
- Flyway
- Testcontainers
- Docker Compose
- OpenAPI Documentation
Explore the interactive API documentation and endpoints using the OpenAPI specification, hosted with Swagger UI on GitHub Pages.
Configure the behavior of JWT access tokens using the following properties:
| Property Name | Description | Default Value | Allowed Values |
|---|---|---|---|
jwt.access.secret |
Secret key for JWT signatures | random generated | String (> 32 characters) |
jwt.access.ttl |
Token expiration time | 1 hour |
Duration |
Token expiration time in hours. For duration conversion details, see the Spring Converting Durations Guide.
Secret key for JWT signatures (base64 encoded). Custom secret should be ≥ 32 bytes as per the JWT JWA Specification (RFC 7518, Section 3.2).
Get the latest version of the application from the release page.
Ensure you have Maven, Docker, and Docker Compose installed. Exercise caution when initiating the application; it employs spring-boot-docker-compose under the hood.
The API is equipped with a suite of 57 integration tests that cover various endpoints and scenarios. These tests are designed to ensure that the API functions as expected, handling different input cases and returning the correct responses. To run the integration tests, follow these steps:
- Make sure the application is cloned and Docker is running.
- Open a terminal and navigate to the
social-media-api/directory. - Run the integration tests using Maven:
mvn -Dtest=*IT testThe test results will be displayed in the terminal, allowing you to verify the correctness of the API's behavior.
- Clone the repository
- Navigate to the project directory:
git clone https://github.com/qwonix/social-media-api.git
cd social-media-api/- Build App, Docker images and start the containers using Docker Compose:
mvn package
docker build -t qwonix/social-media-api:1.0.1 .
docker-compose -f compose.yml up -dDownload compose.yaml and use Docker Compose
docker-compose -f compose.yaml up -d