Academy

Layered Architecture

Stack the code by technical role. Every layer only talks to the one below it.

PresentationBusiness logicData accessOrderControllerOrderServiceOrderRepoUserControllerUserServiceUserRepoPayControllerPayServicePayRepo

Play a scenario

A request enters at the top and travels straight down: the controller parses it, the service decides, the repository stores. Each step only knows the next one.

Or test a dependency

Click a component in the diagram, then a second one. You will see whether that import is allowed in this architecture, and why.

An arrow means "depends on" (imports).

The oldest and most common way to organize an application: group code by what it does technically. Everything that handles HTTP goes in one layer, the business rules in the next, the database access at the bottom.

The one rule

Dependencies point down. A layer may use the layer directly below it and nothing above it.

What it buys you

  • Everyone already knows it, so new team members find their way quickly
  • Technical concerns are cleanly separated: swap the database or the UI in one layer
  • The rule is simple to state and simple to check

What it costs

  • Every feature touches every layer
  • Features are not isolated: services in the same layer tend to grow into each other
  • The business logic depends on the database layer, so it is hard to test without it

When to pick it

Small to medium applications, CRUD-heavy systems, and teams that want one convention everybody understands on day one.

Keeping it that way

A diagram like the one above only holds as long as nobody adds the one import that breaks it. TangleGuard reads your real code, shows it as this kind of graph, and checks every dependency against the rule you drew: while you or your agent write, and again before a pull request merges.

Architecture Verification

Protect your codebase now

Two minutes to set up: the CLI, the hook for your agent, and the GitHub Action for every pull request. It runs locally, so your code never leaves your machine.