Senior · Architecture and systems

Layered, hexagonal, vertical or services?

How would you choose an architecture for a growing Go product?

Try explaining this aloud before opening the answer. State your assumptions and trace a boundary case.

Reveal a strong answer
  1. Begin with deployment and team constraints. A modular monolith keeps transactions and operational work simple; vertical slices group a feature's changes; layered or hexagonal boundaries can isolate business decisions from transports and storage.

  2. Microservices buy independent deployment and failure isolation only when boundaries and operations support them. They add network failures, compatibility, observability and data consistency work. CQRS separates read/write models; event sourcing retains events as the authority and introduces evolution/replay obligations.

  3. Rate suitability against a concrete scenario rather than declare a universal winner. For a small CRUD service, a simple modular design may rate higher than event sourcing. For audit-heavy workflows, the replay cost may be justified. Record the tradeoff and revisit it as evidence changes.

Common trap

Naming folders domain/application/infrastructure does not by itself create a clean dependency boundary.

Try it

Two developers need an admin CRUD API next month. Rank simple modular monolith, microservices and event sourcing.

Worked solution

Usually start with the modular monolith: fewer deployments and local transactional invariants. Score the other options lower unless independent team ownership or immutable event history is a real requirement. This is a scenario-specific judgment, not a language-wide ranking.

Change the constraint

What observable change would justify extracting the first service?

How did you do?

Self-assessment, not a compiler pass or interview score. Explain the reasoning unaided before marking understood.

Not marked. Progress stays on this browser, separate from course completion.

Primary references

Checked 2026-10-20. Use documentation for your pinned runtime, driver and tool version.