Subscription Service — is a REST API microservice for managing users and their subscriptions to digital services (such as Netflix, YouTube Premium, etc.).
Component | Version | Purpose |
---|---|---|
Spring Boot | 3.4.5 | Backend framework |
Spring Data JPA (Hibernate ORM) | 6.6.13 | ORM framework for Java data handling |
Maven (wrapper) | 3.9.9 | Project build tool |
PostgreSQL | 17+ | Database management system |
Liquibase | 4.31.1 | Database migrations |
MapStruct | 1.6.3 | DTO/Entity object mapping |
JUnit 5 | 5.11.4 | Test framework for unit tests |
Mockito | 5.14.2 | Test framework for mocking in unit tests |
JaCoCo | 0.8.13 | Test coverage reports |
Springdoc OpenAPI | 2.8.6 | API documentation (Swagger UI for Spring) |
Spring Cloud Netflix | 2024.0.1 | Integration with Eureka (Service Discovery) |
Source code structure (branch: dev):
├── main/
│ ├── java/com/github/tennyros/subscription_service/
│ │ ├── dto/ # Data Transfer Objects
│ │ │ ├── request/ # Request DTOs
│ │ │ └── response/ # Response DTOs
│ │ ├── exception/ # Custom exceptions
│ │ ├── http/
│ │ │ ├── advice/ # Exception handlers
│ │ │ └── rest/ # REST controllers
│ │ ├── mapper/ # MapStruct mappers
│ │ ├── model/ # JPA entities
│ │ ├── repository/ # Spring Data JPA repositories
│ │ └── service/ # Business logic
│ │ └── impl/ # Service implementations
│ └── resources/
│ ├── db/changelog/ # Liquibase SQL migrations
│ ├── application.yml # Main configuration
│ └── application-dev.yml # Development configuration
├── test/ # Tests
│ ├── java/
│ │ └── com/github/tennyros/subscription_service/
│ │ ├── controller/ # Controller layer unit/integration tests
│ │ ├── mapper/ # Mapper unit tests
│ │ └── service/ # Service layer unit tests
│ └── resources/
│ └── application-test.yml # Test configuration
pom.xml
Built artifacts:
target/
├── generated-sources/
│ ├── annotations/ # MapStruct auto-generated classes
│ │ └── com.github.tennyros.subscription_service.mapper/
├── reports-report/ # JaCoCo coverage reports
- Java 17+
- Docker and Docker-compose
1. Clone the repository:
git clone https://github.com/tennyros/subscription-service.git
cd subscription-service
2. Copy the .env:
cp .env.example .env
3. Start the application and PostgreSQL using Docker:
# Copy docker-compose.yml file
cp docker-compose.example.yml docker-compose.yml
# Start containers
docker-compose up -d
4. After that, the API will be available at:
http://localhost:8088/swagger-ui.html
POST /users - Create a new user
GET /users/{id} - Retrieve user by ID
PUT /users/{id} - Update user by ID
DELETE /users/{id} - Delete user by ID
POST /users/{id}/subscriptions - Add a subscription to user
GET /users/{id}/subscriptions - Get user's subscriptions
DELETE /users/{id}/subscriptions/{sub_id} - Remove a specific subscription
GET /subscriptions/top - Get top 3 most popular subscriptions
The project is configured with CI to automatically build and test
on pull requests using GitHub Actions.