Welcome to the githubconnector application, it is responsible for grabbing information from github and mapping it to our customers expected object.
I am using gradle as my build tool. Included in this repo is the gradle wrapper, so all the following commands are able to run without gradle as a local dependency.
To build the program:
./gradlew clean buildThe build command also runs:
./gradlew detektto enforce code formatting, syntax, and many other rules. Detekt Repo./gradlew testto run all the tests, test output will be shown during thebuildandtesttasks
To run the application:
./gradlew clean bootRunExample request:
curl "http://localhost:8080/github_connector/v1/users/octocat"
Example Response:
{
"user_name": "octocat",
"display_name": "The Octocat",
"avatar": "https://avatars.githubusercontent.com/u/583231?v=4",
"geo_location": "San Francisco",
"email": null,
"url": "https://github.com/octocat",
"created_at": "2011-01-25 18:44:36",
"repos": [
{
"name": "boysenberry-repo-1",
"url": "https://github.com/octocat/boysenberry-repo-1"
}
]
}- Application architecture is pretty simple with a controller endpoint, and a couple of services to handle the mapping logic / API call.
- Retrofit is used to make the API call to github.
- Jackson is responsible for the mapping of json<>models to avoid a bunch of by-hand json parsing.
- The
ObjectMapperwe use turns offFAIL_ON_UNKNOWN_PROPERTIES. The github API call fails without it since we aren't using all the fields. I personally think this defaulting totrueis not a great decision. - The
ObjectMapperalso uses thekotlinModule()to play nicely with kotlin. - When a user is not found in github, we return a
404with an appropriate error message to our user. This happens before the repo call is made, so we don't end up making two bad API calls.
- Kotlin / Spring Boot - I am quite comfortable in both, and are generally scalable technologies. They are both well-supported / maintained, and there are many docs on how to do things. It is easy to expand upon and there are countless libraries/plugins for additional technologies.
- Retrofit - Used for easy API calls, because
RestTemplateis not fun to use. It also has great coroutine support. - OkHttp - The underlying library for Retrofit, I pull in some extra OkHttp stuff for logging.
- Kotest / mockk / kluent - Test frameworks and verification matching library.
- Detekt - Static Analysis tool for good practices and consistent formatting.
- I would talk with the client about receiving the
created_atfield in the standard ISO-8601 datetime format. - Additionally, the requested datetime format by the client doesn't have any time zone information. Since this is a bad pattern, I will be making the assumption they want UTC time. Unfortunately, their requested pattern has no way to tell them this.
- I would also work with the client on consistent naming, they want to send in a
usernamebut in the response they would like auser_name. Normally username is a single word, so I'd advise them to useusername. - I personally didn't run into any issues with the default github rate-limiting.
- The initial build took me roughly 2 hours, including some debugging. I spent another 30 minutes writing some test cases, and a final 30 minutes doing some cleanup, documentation, and this writeup.
- Add a proper auth solution to avoid rate limiting. This could be done by adding parameters to our API call, which would be used to generate a github auth token. This token would then be sent along during the github API call.
- Add externalized configuration for things like github api url, token information, api logging, etc.
- Add proper functional tests where the Application Context starts, endpoints are hit, and results are expected. Maybe add a mock api call to github.
- Add CI/CD for automated testing during PRs and simplified releases/deployments.
- Add a bunch of stuff to the github API call to make it better:
- More robust error handling
- Retry logic
- Self rate limiting?
- Containerize the application for easy deployments.
- Use coroutines and/or webflux for improved non-blocking performance .