Software Architecture for Productive "Vibe Coding"

Software Architecture for Productive "Vibe Coding"

AI has become an indispensable part of day-to-day software development. Studies show that, at low complexity, AI can deliver up to 25% greater productivity in popular languages.

However, AI becomes less efficient as the context window grows. For example, at 32,000 tokens, GPT-4o achieves only 75% of its performance compared with 1,000 tokens.

(Source: https://www.youtube.com/watch?v=tbDDYKRFjhk)

Conclusion: We need to structure software in a way that allows AI to work efficiently.

Big Ball of Mud vs. Structure

If you put a junior developer on a blank-slate project without guidance, chaos quickly follows—a Big Ball of Mud. The same thing happens when AI agents set up projects without structure. The result is unscalable architecture that is only suitable for small “Hello World” examples.

An AI’s context window is very similar to a human’s. You can keep only a limited part of the system in mind at any one time.

That is why architecture with manageable complexity and clear boundaries is also essential in AI projects.

My Experience with Hexagonal Architecture

I have had the opportunity to work on several projects with services built using Hexagonal Architecture, with very positive results—including when working alongside AI.

The domain forms the core and keeps business logic independent of technology. Ports and interfaces precisely define how the domain interacts with the outside world. Clearly separating controllers, adapters, and domain logic reduces cognitive load.

This also makes it easier for AI agents to implement individual parts cleanly. For example, AI can readily generate or replace a database adapter through clearly defined ports.

Downside: Hexagonal Architecture produces a lot of boilerplate code. Upside: That is exactly where AI is exceptionally strong.

“Lazy AI” and How to Tame It

I often observe GPT models choosing lazy solutions. Classic examples include comments such as “// rest of the code.” Particularly in architectures with domains, use cases, ports, adapters, mappers, and so on, you have to be strict about ensuring that AI does not take shortcuts.

The Solution: Instruction Files

These files let you provide the AI with architecture rules, naming conventions, and responsibilities. With a few examples in the project, AI follows them very effectively.

My Workflow

Create an instruction file (architecture rules, examples) Have AI agents generate use cases Manually check and adjust Implement domain logic Have AI generate adapters and controllers Intervene as needed and review everything

This makes it possible to create a great deal of functional software very quickly when building new services—cleanly structured and AI-friendly.

Conclusion

Hexagonal Architecture and AI are a powerful combination. Architecture reduces complexity, while AI handles the legwork. The result is more productive developers and more efficient AI.

How do you use AI in your software projects? Do you also use architectures such as Hexagonal or Clean Architecture together with AI?

More technical insights

Read more practical project insights on the blog.