liveBook · Manning

Presentation layer

As explained in Grokking Software Architecture

The part of an application that displays information, captures user input, and translates user interactions into application requests.

The presentation layer is an application’s front desk: it displays information, captures input, and passes user actions along for processing. It might render a web page, accept a form submission, or return an API response. It knows how to show things, not the underlying business rules. section 4.2.3

In a common four-layer design, presentation sits above application, domain, and infrastructure. The application layer coordinates use cases; the domain holds business rules; infrastructure handles external concerns such as databases and email. Keeping those jobs separate helps prevent a controller from becoming a catch-all for application logic. section 4.2.3 section 4.7.4

Saving an order

A user submits an order through the interface. Presentation sends a “Save Order” command and its input data to the application layer, which coordinates the work. Results can travel back up for presentation to display. Commands move downward; lower layers do not initiate commands back up. section 4.6.1 section 4.2.3

Where a controller sits depends on how the layers are drawn. One arrangement treats HTTP and web concerns as presentation responsibilities; another places request-handling controllers in an application-layer folder while keeping the client UI in presentation. Make the boundary explicit, then enforce the intended dependencies with automated architectural tests. section 4.7.4 section 4.4.1

/my-project/src/
  /api/                 # Application Layer (part 1)
    controllers.js  
    routes.js           # Handles HTTP, validation, calls service 
  /app/                 # Presentation layer
    app.js              # Main UI (React/Angular/Vue, etc) code
    Index.html
  /domain/                # Domain Layer
    order.js
    widget.js           # Widget class with business logic
  /lib/                 # Infrastructure Layer (part 2)
    emailClient.js      # Other external services
  /repositories/        # Infrastructure Layer (part 1)
    widgetRepository.js # Database code
  /services/            # Application Layer (part 2)
    orderService.js     # Orchestrates the “create order” use case
    widgetService.js

This project layout shows one way to separate a client-side UI from controllers, services, domain logic, and infrastructure. section 4.4.1

Don’t confuse this application layer with the OSI presentation layer: the latter formats and translates data for communication, rather than providing an application’s user interface. section 4.8.2 section 4.2.3

How Grokking Software Architecture covers it

How deep it goes
Explains layer responsibilities and command versus data flow, with guidance on component placement and boundary enforcement.
Examples
Uses an order-saving command, a layered project folder layout, and a whiteboard exercise assigning components to layers.
What you can do after
Evaluate and understand where presentation responsibilities belong, and use automated architectural tests to protect intended boundaries.
How it connects
Connects layered architecture and separation of concerns to application, domain, and infrastructure layers and the downward dependency rule.

Also explained in

Compare how 2 books explain presentation layer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.