A Spring Boot REST service that aggregates GitHub user profile data from multiple GitHub API endpoints into a unified response.
- Java 25
- Spring Boot 4.0.1
- Spring RestClient
- Lombok (minimize boilerplate)
- springdoc-openapi (Swagger)
- JUnit 6 / Mockito (testing)
This project uses the following class structure:
ProfileController (REST API)
└── ProfileService (Business Logic)
└── GitHubClient (GitHub API Integration)
The profile service will fetch user info and a list of user repositories concurrently from GitHub (using CompletableFuture to minimize wait time), then aggregates them into a single response.
src/main/java/com/branch/service/github/
├── client/ # External API clients (GitHub client)
├── controller/ # REST controllers
│ └── advice/ # Controller advice (i.e - exception handling)
├── exception/ # Custom exception classes
├── model/
│ ├── dto/ # Response DTOs for this service's API
│ └── github/ # DTOs mapping GitHub API responses
└── service/ # Business logic
# Build
./mvnw clean compile
# Run tests
./mvnw test
# Run the application
./mvnw spring-boot:runOpen the project and run the Application class directly (click the play button in the gutter).
NOTE: The service starts on port 8080 (i.e. http://localhost:8080)
Fetches GitHub user info and repositories.
GET /api/v1/users/{username}/profile
Example Response (200 OK):
{
"user_name": "octocat",
"display_name": "The Octocat",
"avatar": "https://avatars.githubusercontent.com/u/583231",
"geo_location": "San Francisco",
"email": "octocat@github.com",
"url": "https://api.github.com/users/octocat",
"created_at": "Tue, 25 Jan 2011 18:44:36 GMT",
"repos": [
{
"name": "hello-world",
"url": "https://github.com/octocat/hello-world"
}
],
"repo_count": 1
}Possible Error Responses:
| Status | Description |
|---|---|
| 404 | User not found on GitHub |
| 502 | GitHub API error |
| 500 | Internal server error |
Once the application is running, you can view the Swagger docs here:
- Swagger UI: http://localhost:8080/swagger-ui.html
- OpenAPI spec: http://localhost:8080/v3/api-docs
GitHub API base URL can be configured in application.yaml:
github:
api:
base-url: https://api.github.com# Run all tests
./mvnw test
# Run a specific test class
./mvnw test -Dtest=ProfileControllerTestRight-click on a test class or method and select "Run", or click the play button in the gutter.
| Class Under Test | Layer | Mocking Approach |
|---|---|---|
ProfileControllerTest |
Controller | @WebMvcTest + @MockitoBean |
ProfileServiceTest |
Service | @ExtendWith(MockitoExtension.class) + @Mock |