LESSON 03 / 15·2 min readIntermediate

What are layered, clean and hexagonal architecture?

01 Understand02 Recall03 Prepare

Understand the concept

Layered architecture separates responsibilities such as HTTP handling, business rules and persistence. Clean and hexagonal architecture emphasize keeping core business decisions independent of frameworks and external systems. Ports describe what the core needs, and adapters implement those contracts for a particular database or service.

Important ideas

  • Layered: separate HTTP, business logic and data access.

  • Clean: core business rules do not depend on framework details.

  • Hexagonal: adapters connect the core to databases, APIs and other external systems.

  • Dependency direction matters more than the number of folders: business logic should not require an HTTP request object just to calculate a result.

PAUSE & RECALL

Can you explain it without the notes?

What are layered, clean and hexagonal architecture?

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

Layered architecture separates responsibilities such as HTTP handling, business rules and persistence. Clean and hexagonal architecture emphasize keeping core business decisions independent of frameworks and external systems. Ports describe what the core needs, and adapters implement those contracts for a particular database or service.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

  • Show how you could replace a provider or test a business rule without booting the entire framework.
Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: What are DDD, SOLID and dependency inversion?

Adapted from 07_SYSTEM_DESIGN_ARCHITECTURE.md · “What are layered, clean and hexagonal architecture?”. Examples are study fragments; framework behavior can depend on your version.