๐Ÿง  Microservice with Hexagonal Architecture using AI (Copilot + Gemini + Spring Boot)

Edwin ZamoraEdwin Zamora
3 min read

๐Ÿš€ Introduction

This article explores how to build a back-end microservice using only free AI tools through custom instructions. The goal is to demonstrate how convenient and powerful it can be to use AI to generate professionally structured projects, without manually writing every line of code.


๐Ÿ‘๏ธ What do I want to prove?

How far can we go building a professional microservice with AI as our co-pilot? In this case, we used Gemini and Copilot for the development and implementation of the software.

This experiment shows that AI, when properly guided, can assist technical development without replacing the programmer. It works as a "technical assistant" that responds to our custom instructions, helping to apply best practices and maintain design quality.


๐Ÿ“– Core Reference: Hexagonal Architecture Explained

For a foundational understanding of hexagonal architecture, this project is based on the excellent article by Arho Huttunen: ๐Ÿ”— Hexagonal Architecture with Spring Boot โ€“ arhohuttunen.com


๐Ÿงก What's included in this POC?

  • ๐Ÿงน Hexagonal architecture: decoupled inputs/outputs, clean domain.

  • โ˜• Spring Boot 3 with professional dependencies.

  • ๐Ÿณ Containers with Docker Compose and MySql.

  • ๐Ÿ” DTO โ†” Entity mapping with MapStruct.

  • ๐Ÿงช Unit tests with JUnit and Mockito.

  • ๐Ÿ“˜ Documentation with Swagger/OpenAPI.

  • ๐Ÿค– Generated using AI: GitHub Copilot and Gemini.

๐Ÿ”— View the repository: github.com/edzamo/coffee-shop-hexagonal-con-IA


๐Ÿง  How to generate structured code with AI

Using AI to code isn't just about asking for code. It's about teaching it the context of your project, guiding it with clear prompts, and reviewing each response critically.

During this development, I discovered that AI can:

  • Understand complex patterns like hexagonal architecture.

  • Generate coherent and well-named classes.

  • Suggest effective unit tests.

  • Validate project designs and structures.

๐Ÿ’ก Tip: if you define your own prompts and folder structures (like in .heHexaBarista), you can turn AI into a real technical co-pilot.


โœจ The deep benefit of using AI in software development

Tools like Copilot and Gemini not only speed up work, but also help maintain code consistency and quality.

They become constant technical assistants that:

  • ๐Ÿง  Reduce repetitive effort.

  • โš™๏ธ Respect your style and conventions.

  • ๐Ÿš€ Let you focus on business logic and architecture decisions.

The key is to use custom instructions and provide technical context. This way, AI stops being generic and becomes a highly productive tool.

๐Ÿ›‘ AI doesn't replace the developer, it empowers them.


๐Ÿ› ๏ธ How to practice with AI while coding

Personal recommendations to take advantage of AI in real projects:

  • ๐Ÿ’ก Start with simple projects and apply real patterns (like MVC or hexagonal architecture).

  • ๐Ÿคญ Provide context: class names, folder structure, conventions.

  • โœ๏ธ Use clear and step-by-step prompts, as if explaining to a junior.

  • ๐Ÿงช Review everything the AI generates. Learn from its mistakes and successes.

  • ๐Ÿ“ Define a clear structure (adapters, ports, domain) so AI can understand it easily.


๐Ÿงพ Conclusion

This project not only demonstrates a functional architecture, but also how to integrate AI into a professional development workflow. When properly guided, AI allows you to develop faster without sacrificing design or quality.

If you want to try it yourself:

  1. Explore the .heHexaBarista folder.

  2. Install GitHub Copilot or Gemini.

  3. Build with AI as your technical ally. ๐Ÿš€

0
Subscribe to my newsletter

Read articles from Edwin Zamora directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Edwin Zamora
Edwin Zamora