Enhance Productivity with a Repository Template

Enhance Productivity with a Repository Template

From Repetitive Boilerplate to Rapid Prototyping in a Snap!

Table of contents

A long time ago, a colleague of mine interviewed someone for a position at our company. He was impressed by the person's setup, which allowed them to quickly create projects. This setup included a database connection, REST controllers, and a fast starting process.

Inspired by this story, I realized that I could improve my own workflow. I often found myself skipping projects because of the repetitive boilerplate code I had to add each time.

After some thinking and research, I discovered Template Repositories on GitHub. The concept is simple: create a repository that serves as a foundation for other repositories.

In my case, I identified the following key features that were important to me:

  • An easy-to-use script to customize each new clone of the project.

  • A web framework skeleton with REST controllers.

  • Dockerizing the application and providing a docker-compose setup for dependencies.

  • A comprehensive README file with information on the purpose of the service and how to run it.

  • Code quality assurance and security scans for the codebase.

  • Automatic dependency upgrades to ensure projects are up-to-date.

  • Database setup.

  • Test containers for testing the integration between my service and its database.

With these requirements in mind, I embarked on my journey.

golden hour photography of racing bicycle in middle of road

To centralize my work, I decided to manage everything in a single place: my GitHub repository. I created issues in the repository to track each requirement, ensuring that no good ideas were forgotten over time.

After careful consideration, I settled on the following implementation:

  • A multi-module Gradle project that allows multiple apps in one repository if needed.

  • Spring Boot as the web framework, chosen for its popularity.

  • SonarCloud and CodeQL for security scans and static code analysis (both free for open-source projects).

  • GitHub Actions for CI tooling.

  • Dependabot for dependency upgrades, with the added benefit of auto-merging Dependabot's pull requests after passing CI.

  • PostgreSQL with Flyway as the migration tool and JOOQ as the query library.

  • Spotless for code-style linting. I was delighted with the results.

I was delighted with the results.

man sitting on mountain cliff facing white clouds rising one hand at golden hour

A few months passed, and I used my template for several small projects. However, one day at work, I noticed that we were falling into the same repetitive patterns I had resolved for myself. Every new project meant creating a new repository, setting up a new deployment, and spending days on work that had minimal impact on our users.

I discussed this with my manager and took it upon myself to fork my template into the organization. Forking alone wasn't sufficient; I needed to tailor it to the organization's specific setup and requirements.

It took a few days of effort, but in the end, I had a fully functional template repository. It enabled me to deploy a new service to production within 1-2 hours of work.

That's what I call a significant improvement!

closeup photography of gray audio mixer

However, our story doesn't end there. When generative AIs started becoming prevalent in our lives, I had an idea for a game. The game involved guessing the prompt that was used to generate an AI-generated image.

The concept sounded fun, but I wanted to validate it quickly. I didn't want to spend weeks building something that might not be enjoyable as I anticipated.

Using my template, I managed to create a complete project in just one weekend. I even deployed it to a production environment, allowing me to share it with friends and colleagues to confirm my assumptions about the project's appeal.

P.S. - The game POC is still available at https://beat-the-machine.yonatankarp.com/.

Conclusion

the final result of my work is available on my GitHub account at https://github.com/yonatankarp/spring-boot-app-template.

Did you find this article valuable?

Support Yonatan Karp-Rudin by becoming a sponsor. Any amount is appreciated!