Layer

How to organize complex systems through layers and hierarchies. Breaking down big problems into manageable pieces.

Why Layers?

Layers help us manage complexity by creating clear boundaries:

  • Each layer has one job
  • Layers talk to each other through simple contracts
  • Changes in one layer don't break others
  • Systems can grow without becoming chaotic

Common Layers

  • ui — What users see and interact with
  • business — Core rules and workflows
  • data — Storage and retrieval
  • platform — Infrastructure and services

Cross-System Concerns

  • auth — Who can do what
  • logging — What's happening in the system
  • api — How systems talk to each other
  • cache — Making things faster

Design Principles

  • Keep related things together
  • Depend on abstractions, not concrete things
  • Make interfaces small and focused
  • Isolate changes within layers

Communication Patterns

  • top-down — Commands flow from UI to data
  • bottom-up — Events bubble up from data to UI
  • sideways — Services talk to each other
  • shortcuts — Direct paths for performance

In Practice

  • Organize code into folders by layer
  • Use consistent naming across projects
  • Test each layer independently
  • Test interactions between layers

Related

Works with entry patterns, value measurements, and std conventions.