Skip to content
EduVerse

You’re reading the free preview.Unlock every conversation for €2.99

FreeFree previewChapter 6

Chapter 6 · Free preview

Backend Architecture

The Code Behind the Contract

Illustration from the book

What you will understand

  • Apply the three-layer architecture (controller, service, repository)
  • Explain dependency injection and how it improves testability
  • Explain each SOLID principle in your own words with an example
  • Weigh a monolith against microservices
  • Design a DTO to move data between layers

Written by EduVerse for this preview; the slides below are the book’s own words.

Slides from the chapter

Each slide is a passage from the book with the figure or listing it talks about. Swipe, use the arrow keys or the buttons.

Slide 1 of 3

Separation of Concerns

6.2.1 · pp. 132–133

Conversation from The Software Realm, Decoded

Chapter 6 · 6.2.1 Separation of Concerns · pp. 132–133

The Senior developer, from the book cover

Senior developer

Your code does five things: HTTP handling, validation, business logic, database access, email sending. When email provider changes, you touch the same function that handles HTTP. One change, five potential breaking points.

Peter, from the book cover

Peter

So... separate them?

The Senior developer, from the book cover

Senior developer

Exactly. Three layers. Each with one job.

The pattern:

  • Controller: Handles HTTP only
  • Service: Handles business logic only
  • Repository: Handles database only
Peter, from the book cover

Peter

Why three? Why not two or five?

The Senior developer, from the book cover

Senior developer

Three is the sweet spot. Two is too mixed. Five is over-engineered. Think of it like a restaurant:

The restaurant analogy:

  • Controller = Waiter: Takes orders, serves food. Doesn’t cook. Doesn’t decide recipes.
  • Service = Chef: Decides what to cook, coordinates preparation. Doesn’t take orders. Doesn’t manage pantry.
  • Repository = Pantry: Stores and retrieves ingredients. Doesn’t cook. Doesn’t serve.

Each person has one job. Waiter doesn’t need to know pantry organization. Chef doesn’t need to know table numbers.

What the book shows with it

Figure from The Software Realm, Decoded

Chapter 6 · 6.2.2 Controller: The HTTP Boundary · p. 133

That’s it.

Inspect
Table · Controller ResponsibilitiesFrom the book, p. 133
Try it interactively: One request through three layers

Explore this table

Pick one to highlight it and read what the book says about it.

Other cells in the table (14)
Description

Table: 'Controller Responsibilities'. 'Does': extract data from the HTTP request, call the service layer, convert results to HTTP responses, map errors to HTTP status codes. 'Does NOT Do': business logic, direct database access, complex validation rules, long-running or heavy processing.

Description written by EduVerse; the figure itself is from the book.

Slide 1 of 3

Try it yourself

A simulation built by EduVerse around this chapter. It runs in your browser; nothing is sent anywhere.

Full book

The full chapter

This preview shows 5 of the chapter’s 27 passages. The full chapter has:

  • 8 sections
  • 14 conversations
  • 5 figures and tables
  • 3 What They Say boxes
  • 7 knowledge-check questions
Sections in this chapter
  1. 6.1Peter's Architecture Journey Begins
  2. 6.2The Three-Layer Architecture
  3. 6.3The Dependency Problem
  4. 6.4SOLID Principles Through Peter's Refactoring
  5. 6.5The Security Disaster: Entities vs DTOs
  6. 6.6Monolith vs Microservices: Peter's Growing App
  7. 6.7Scaling: API Gateway and Beyond
  8. 6.8Peter's Takeaways