liveBook · Manning

Domain layer

As explained in Learn Go with Pocket-Sized Projects

A domain layer is an architectural layer that contains an application's business rules and domain behavior independently of delivery and persistence concerns.

The domain layer, also called the business layer, owns business rules and domain behavior rather than transport-specific concerns. It exposes typed business concepts such as Habit, ID, Name, and WeeklyFrequency, making APIs clearer and reducing accidental argument mix-ups. section 10.3.1

A domain operation can:

  • Return domain errors without knowing that an API uses gRPC; the API layer translates invalid input into INVALID_ARGUMENT. section 10.3.1

Creating a habit

Create validates and completes a Habit, saves it to data storage, and returns the completed entity. Tests cover fully populated, partially populated, and whitespace-only names.

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Implements validation, defaults, generated fields, typed errors, persistence orchestration, and focused tests.
Examples
Uses a habit tracker, typed Habit values, validation tests, generated identifiers, and creation timestamps.
What you can do after
Builds a validated habit-creation operation and tests its complete, partial, and invalid-input behavior.
How it connects
Connects business types and input validation to the API layer, gRPC status codes, typed errors, and data storage.

Also explained in

Compare how 3 books explain domain layer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.