This project is a simple Spring Boot application (Java 21 + Spring Boot 3.5) that integrates with the GitHub REST API (v3). Its purpose is to fetch all public repositories for a given GitHub user (excluding forks) and return, for each repository, its name, owner login and a list of branches with the last commit SHA.
- Java 21
- Spring Boot 3.5
- Spring Web (MVC)
- RestTemplate (HTTP client)
- JUnit 5 / Spring Boot Test (single integration test)
- Fetch public repositories of a GitHub user using
GET /users/{username}/repos
from GitHub API. - Exclude forked repositories.
- For each repository, fetch branches using
GET /repos/{owner}/{repo}/branches
. - Return JSON with repository name,
ownerLogin
andbranches
(branch name + last commit SHA). - Single integration test covering the happy-path (real HTTP calls; minimal mocking).
- Clone repository:
git clone <your-repo-url>
cd githubapi
- Build:
./mvnw clean install
# on Windows (PowerShell/CMD):
mvnw.cmd clean install
- Run:
./mvnw spring-boot:run
# or
mvnw.cmd spring-boot:run
- The API will be available at
http://localhost:8080
by default; if logs show a random port, use that port. Example endpoint:
http://localhost:8080/api/github/octocat/repos
- There is one integration test (in
src/test/java/...
) which starts the Spring context and exercises the endpoint (happy path). - Run tests:
./mvnw test
# or on Windows:
mvnw.cmd test
- Expect
BUILD SUCCESS
andTests run: 1, Failures: 0
for the provided single test.
- No pagination support (both when consuming GitHub API and in output).
- Only public repositories are supported (no authentication / OAuth token handling).
- No WebFlux; no DDD/Hexagonal structure — minimal implementation as requested.
octocat
used as an example username for testing.
- GitHub REST API v3 documentation: https://developer.github.com/v3
- Spring Boot documentation: https://spring.io/projects/spring-boot