Tutorial 2: Web Architecture Styles

Unit 1 · Web architecture and protocols

Objectives

Architecture is a set of decisions

Web architecture describes how clients, servers, data stores, and external services collaborate. A monolith packages many responsibilities into one deployable unit. This can be simple to develop and deploy, but unrelated changes may become coupled. A layered design separates presentation, application logic, domain rules, and persistence so each layer has a clearer responsibility.

Browser <-> HTTP API <-> Application services <-> Database
                  |              |
               JSON          External service

Client-server architecture assigns responsibilities across a network boundary. The client presents information and captures intent; the server owns authoritative rules and data. The boundary is also a trust boundary: client checks improve usability, but server checks protect the system.

REST-style thinking

REST models resources and representations. A resource might be a course, enrollment, or profile. Uniform HTTP semantics make APIs easier to understand: GET /courses/466 retrieves a representation, while POST /enrollments creates a new relationship. Stateless requests, cacheable responses, a uniform interface, and layered intermediaries are useful constraints, not mandatory decorative labels.

Exercises

  1. Place browser, API, domain service, database, and email provider into a layered diagram.
  2. Identify one responsibility that belongs on the server even if the client also checks it.
  3. Design resource paths for courses, students, and enrollments.

Self-check

  1. What is a trust boundary?
  2. What is one advantage of a monolith?
  3. Why use nouns in resource paths?

Self-Check Quiz

1. Where should authoritative business rules execute?

Answer(B) The server controls authoritative rules because clients are not trusted.

2. What does stateless mean for an HTTP request?

AnswerThe request contains the context the server needs; the server does not rely on hidden conversational state in one specific process.

3. Is REST a JavaScript library?

AnswerNo. REST is an architectural style and set of constraints for networked systems.

Homework

  1. Compare a monolithic course service with a service-oriented design.
  2. Draw the request path for creating an enrollment.
  3. Write a 250-word rationale for your chosen boundaries, including one failure scenario.
Sample answer

A small course service may start as a monolith because one deployment and one database reduce operational complexity. Its internal layers can still isolate HTTP, domain rules, and persistence. The server validates the student and course, performs the enrollment transaction, and returns 201 or a useful error. An external email provider should be treated as a dependency that can time out; enrollment success should not silently depend on an unbounded email call.

👤