DEV Community

Edwin Zamora
Edwin Zamora

Posted on

🧠 Microservice with Hexagonal Architecture using AI (Copilot + Gemini + Spring Boot)

πŸš€ 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. πŸš€

Top comments (0)