In the previous lesson we set Verdalia's quality goals in six measurable scenarios. Now we need to know the repertoire of shapes a system can take to reach them. Those shapes are called architectural styles. In this lesson we will go through the seven most widespread ones, with their advantages, their drawbacks, and the situations they fit. It is an overview: the goal is for you to recognize each style and know when to consider it; the most important ones are studied in depth in Module 3.

What an Architectural Style Is

An architectural style is a recognizable, named way of organizing a system: it defines which kinds of components exist, how they connect, and which rules they follow. In the terms of the first lesson, a style is a family of topologies with a common set of constraints.

Before we begin, it is worth clarifying an idea that avoids a lot of confusion: styles are not mutually exclusive. They answer different questions and, therefore, they combine:

Question Styles that answer it
How is the code organized internally? Layered
In how many pieces is the system deployed? Monolithic, service-oriented, microservices, serverless
How do the pieces communicate? Client-server, event-driven

The same system can be, at the same time, client-server, monolithic, and layered. In fact, that is exactly the case at Verdalia.

Monolithic Architecture

Description

In a monolithic architecture, the whole application is built, deployed, and run as a single unit. All functional areas share the same program and, usually, the same database.

flowchart TB
    users["Users"]
    subgraph monolith["Single application"]
        catalog["Catalog"]
        orders["Orders"]
        payments["Payments"]
        shipping["Shipping"]
    end
    db[("Single database")]
    users --> monolith
    monolith --> db

Characteristics

  • A single deployable program.
  • The areas communicate through function calls within the same process.
  • One database shared by every area.
  • To scale, the whole application is replicated.

When It Fits

It fits new products, small teams, and domains that are still being understood. It is the reasonable starting point for most systems.

Advantages and Disadvantages

Advantages Disadvantages
Simple to develop, test, and deploy A serious failure in one area can bring down the whole system
Fast and reliable internal communication You cannot scale only the part that needs it
A single thing to operate and monitor Every deployment publishes everything, even if one line changed
Simple transactions, since there is a single database Without internal discipline, it tends to become a big ball of mud

An important nuance: monolith is not synonymous with disorder. A monolith that is well organized internally, called a modular monolith, keeps the operational simplicity and avoids a good part of the drawbacks.

Layered Architecture

Description

The layered architecture organizes the code into horizontal levels, each with one responsibility. Each layer only uses the services of the layer immediately below it.

flowchart TB
    presentation["Presentation layer"] --> business["Business logic layer"]
    business --> data["Data access layer"]
    data --> db[("Database")]

Characteristics

  • Separation of concerns by kind of task: displaying, deciding, storing.
  • Dependencies go in a single direction: from top to bottom.
  • A layer can be replaced without affecting the others, as long as it keeps its way of being used.

When It Fits

It fits almost any business application. It is the most widespread style for organizing code, both inside a monolith and inside each service in distributed systems.

Advantages and Disadvantages

Advantages Disadvantages
Easy to understand and to teach A functional change usually cuts across every layer
Allows testing the business logic separately It is easy to skip layers if nobody is watching
Makes it easier to divide the work It can add unnecessary steps to simple operations

Layers are studied in depth in Lesson 03-01.

Client-Server Architecture

Description

In the client-server architecture, the system is divided into two roles: the clients, which request services, and the server, which provides them. Communication is always initiated by the client.

flowchart LR
    browser["Client: web browser"] -->|"Request"| server["Server"]
    mobile["Client: mobile app"] -->|"Request"| server
    server -->|"Response"| browser
    server -->|"Response"| mobile
    server --> db[("Database")]

Characteristics

  • Asymmetric roles: the client asks, the server answers.
  • The data and the important rules are centralized on the server.
  • Many clients share the same server.
  • It is the foundation of the web: the browser is the client and the website is the server.

When It Fits

It fits whenever several users or devices need access to shared data and functions. Almost every current system is client-server at some of its levels.

Advantages and Disadvantages

Advantages Disadvantages
Centralized control of data and security The server is a single point of failure if it is not duplicated
Clients can be simple The server can become a bottleneck
The server is updated without touching the clients It depends on the network working

Service-Oriented Architecture

Description

The service-oriented architecture, known as SOA, organizes the system as a set of broad, reusable business services that several of the company's applications share. Traditionally they communicate through a central element called a service bus.

flowchart TB
    store["Store application"] --> bus["Service bus"]
    warehouse["Warehouse application"] --> bus
    accounting["Accounting application"] --> bus
    bus --> customers["Customer service"]
    bus --> billing["Billing service"]
    bus --> stock["Stock service"]

Characteristics

  • Large services, aligned with company-wide business functions.
  • Formal contracts that define how each service is used.
  • A central bus that routes, transforms, and coordinates messages.
  • Designed to integrate different applications, often built with different technologies.

When It Fits

It fits large organizations with many applications that need to share functions and data, such as banks, insurers, or public administrations.

Advantages and Disadvantages

Advantages Disadvantages
Reuse of functions across applications The central bus concentrates complexity and risk
Integrates systems built with different technologies Requires strong coordination between teams
Clear contracts between the parties Expensive to implement and to govern

Microservices Architecture

Description

The microservices architecture divides the system into small, independent services. Each one handles a specific business capability, has its own data, and is deployed separately.

flowchart TB
    client["Client"] --> gateway["API gateway"]
    gateway --> catalog_svc["Catalog service"]
    gateway --> orders_svc["Orders service"]
    gateway --> payments_svc["Payments service"]
    catalog_svc --> db1[("Catalog data")]
    orders_svc --> db2[("Orders data")]
    payments_svc --> db3[("Payments data")]

Characteristics

  • Small services, each with one business responsibility.
  • Each service owns its data; no other service accesses it directly.
  • Independent deployment and scaling.
  • Communication over the network, with no central bus containing logic.
  • Each service can belong to a different team.

Difference From SOA

Aspect SOA Microservices
Size of the services Large Small
Scope The whole company One application or product
Communication Central bus with logic Simple connections; the logic lives in the services
Data Often shared Owned by each service
Main goal Reuse and integrate Deploy and evolve independently

When It Fits

It fits large systems, with several teams that need to work and deploy without waiting for one another, and with parts that have very different scaling needs.

Advantages and Disadvantages

Advantages Disadvantages
Each part is deployed and scaled separately Far higher operational complexity
A failure can stay contained within one service The network introduces slowness and new kinds of failure
Autonomous teams Keeping data consistent across services is hard
Technological freedom per service Requires mature automation and observability

The detailed comparison between monoliths and microservices is the subject of Lesson 03-02.

Event-Driven Architecture

Description

In an event-driven architecture, components do not call each other directly. Instead, a component announces that something has happened, an event, and the interested components react. Whoever emits the event does not know who will receive it.

flowchart LR
    orders["Orders - producer"] -->|"Event: order confirmed"| channel["Event channel"]
    channel --> inventory["Inventory - consumer"]
    channel --> shipping["Shipping - consumer"]
    channel --> notifications["Notifications - consumer"]

Characteristics

  • Three roles: producers, which emit events; a channel, which transports them; and consumers, which react.
  • Asynchronous communication: the producer does not wait for the consumers to finish.
  • Low coupling: consumers can be added without modifying the producer.

When It Fits

It fits when the same fact triggers several independent reactions, when peaks of work have to be absorbed, or when not everything needs to happen immediately.

Advantages and Disadvantages

Advantages Disadvantages
Highly decoupled components The full flow is harder to follow and debug
Absorbs peaks: the work waits in the channel Data takes a while to become consistent across the whole system
Easy to add new reactions The channel is one more critical piece to operate
A consumer's failure does not stop the producer Duplicate or out-of-order events have to be handled

In the first lesson we saw that, when an order is confirmed, Verdalia's customer waits while the email is sent. This style offers an alternative, which we will develop in Lesson 03-04.

Serverless Architecture

Description

In a serverless architecture, the team writes small functions and a cloud provider takes care of running them when they are needed. The servers do exist, but the provider manages them entirely. You pay for each execution, not for keeping machines switched on.

flowchart LR
    request["Request or event"] --> platform["Cloud provider's platform"]
    platform --> f1["Function: resize image"]
    platform --> f2["Function: generate invoice"]
    f1 --> storage[("Managed storage")]
    f2 --> storage

Characteristics

  • Short-lived functions that are triggered by a request or an event.
  • Automatic scaling, even down to zero when there is no activity.
  • No servers to administer.
  • Pay per use.

When It Fits

It fits sporadic tasks or tasks with a highly variable load, such as processing an image when it is uploaded or generating a nightly report.

Advantages and Disadvantages

Advantages Disadvantages
No server administration Strong dependence on the chosen provider
Zero cost when not in use The first execution after a period of inactivity can be slow
Automatic scaling Hard to test and debug locally
With a high and constant load it can turn out more expensive

We will come back to this model when discussing cloud platforms, in Module 6.

Comparison Table and Criteria for Choosing

Comparison

Style Operational complexity Scaling by parts Ease of change Initial cost Suitable team
Monolithic Low No High at first; low if it gets disorganized Low Small
Layered Low Not applicable Medium Low Any
Client-server Low Limited Medium Low Any
SOA High Partial Medium High Large, several teams
Microservices Very high Yes High, if well divided High Several autonomous teams
Event-driven Medium or high Yes High for adding reactions Medium Mid-sized, with experience
Serverless Medium Yes, automatic Medium Low Small, with dependence on the provider

This table is a guide, not a verdict. Each rating depends on how the style is applied.

Criteria for Choosing

There is no best style, only the most suitable one for a context. The main criteria are:

Criterion Question to ask yourself
Priority quality attributes Which scenarios do we have to meet, and in what order of importance?
Team size and organization How many people are we, and how many teams need to work independently?
Operational maturity Do we know how to deploy, monitor, and recover a system with many pieces?
Domain knowledge Do we already know where the natural boundaries of the business are?
Load differences Are there parts that need much more capacity than others?
Constraints What do the budget, the calendar, and the technology we master allow?

The following diagram summarizes a prudent way of reasoning:

flowchart TB
    start["New system or system under review"] --> q1{"Several teams that need to deploy separately?"}
    q1 -->|"No"| modular["Layered modular monolith"]
    q1 -->|"Yes"| q2{"Sufficient operational maturity?"}
    q2 -->|"No"| modular
    q2 -->|"Yes"| micro["Microservices"]
    modular --> q3{"Tasks that can be done later, or peaks to absorb?"}
    micro --> q3
    q3 -->|"Yes"| events["Add event-based communication where it adds value"]
    q3 -->|"No"| finish["Keep direct communication"]

The idea the diagram sums up is: start with the simplest thing that meets your quality scenarios and add complexity only when a specific problem justifies it.

Where Verdalia Stands and Which Styles We Will See in the Course

The Current Style

Verdalia combines three styles:

  • Client-server: the customer's browser makes requests to the server verdalia-prod-01.
  • Monolithic: the whole store is a single Flask application with a single database.
  • Layered, on paper: in theory there is a separation between presentation, business logic, and data access. In practice, the layers are mixed together.

This fragment, simplified from the store's real code, shows what “mixed layers” means:

@app.route("/product/<int:product_id>")
def view_product(product_id):
    # Data access: connection and SQL query written right here
    connection = psycopg2.connect(
        host="localhost", dbname="verdalia",
        user="store", password=config.DB_PASSWORD,
    )
    cursor = connection.cursor()
    cursor.execute(
        "SELECT name, price, stock FROM products WHERE id = %s",
        (product_id,),
    )
    name, price, stock = cursor.fetchone()

    # Business logic: pricing and stock rules
    final_price = round(float(price) * 1.21, 2)
    notice = "Last units" if stock < 5 else ""

    # Presentation: the HTML is built in the same function
    return f"<h1>{name}</h1><p>€{final_price}</p><p>{notice}</p>"

Explanation:

  • @app.route(...) is Flask's way of indicating that this function handles requests to a product's address.
  • The first block opens a connection to PostgreSQL and runs an SQL query. That is the data access layer's job. The password comes from the config.py file, which, as we know, is stored in the repository.
  • The second block applies business rules: it adds the tax to the price and decides whether to warn that few units are left. That is the business logic layer's job.
  • The third block builds the page the customer will see. That is the presentation layer's job.

The three responsibilities live together in a single function. The consequences are the ones we already know:

  • The “last units” rule cannot be reused on another screen without copying it.
  • The price calculation cannot be tested without a running database.
  • A change to a column name forces a review of functions across the whole codebase.

You do not need to understand every detail of Flask. What matters is recognizing the pattern: when one function queries data, decides, and presents, there are no layers, whatever the diagram says.

The Styles Throughout the Course

Module Style or idea applied Purpose
2 Modular monolith Organize the code internally and separate concerns
3 Layers, services, and events Separate components and decide how they communicate
4 Several copies of the application Withstand the spring campaign
6 Cloud and containers Deploy without downtime and add capacity quickly
7 Complete design and gradual migration See the final result and the path to get there

Notice that the course does not jump straight to microservices. We will analyze the reason rigorously in the next lesson.

Common Mistakes and Tips

  • Choosing the style because it is fashionable. The fact that a big technology company uses microservices does not mean they are suitable for a team of three. Their problems are not yours.
  • Believing that monolith means outdated. A well-organized modular monolith is a fully valid architecture and, for many teams, the best one.
  • Thinking that styles are mutually exclusive. The usual thing is to combine them: a microservices system in which each service is organized in layers and some communicate through events.
  • Splitting a disorganized system hoping it will become organized. If the monolith is a big ball of mud, splitting it yields a distributed ball of mud, with all the previous problems plus those of the network.
  • Forgetting the operational cost. Every new piece has to be deployed, monitored, updated, and protected. Ask yourself who will do it.
  • Practical tip. Faced with any proposal to change style, ask: “which quality scenario improves and which one gets worse?” If nobody can answer, the proposal is not mature.

Exercises

Exercise 1: Recognize the Style

State which style or styles best describe each situation:

  1. An accounting application installed on a server in the office, which employees access from their computers.
  2. A system in which, when a sensor detects a high temperature, the fact is announced and the alarm system, the logging system, and the climate control system react separately.
  3. A platform with 40 services, each with its own database, maintained by eight teams that deploy several times a day.
  4. A small program that runs only when someone uploads a photo, to generate a reduced version, and for which you pay per execution.

Exercise 2: Choose With Good Judgment

Two people are going to create a booking application for hair salons. They do not know yet which functions customers will value most, and they have savings for six months. An acquaintance recommends starting with microservices “so they don't have to redo it when they grow.” Which style would you recommend to them, and why?

Exercise 3: Analyze Verdalia's Code

Look again at the lesson's view_product function. The business wants to show the “Last units” notice on the cart page as well, and to change the threshold from 5 to 10 units. Explain what problem Íker will run into with the current code and what a real separation into layers would give him. No code is required.

Solutions

Solution to Exercise 1

  1. Client-server, and very probably monolithic. The employees' computers are clients of a central server.
  2. Event-driven. There is one producer, the sensor, and three independent consumers that react to the same fact.
  3. Microservices. The clues are each service's own data, the autonomous teams, and the independent deployments.
  4. Serverless. It is triggered by an event, it is short-lived, and it is paid per use.

Solution to Exercise 2

The reasonable recommendation is a modular monolith organized in layers. The reasons, following the lesson's criteria:

  • Team: they are two people. There are not several teams that need to deploy separately, which is the main problem microservices solve.
  • Domain knowledge: they do not know yet which functions will matter. Splitting into services requires knowing the boundaries of the business, and getting them wrong is very expensive.
  • Constraints: with six months of runway, every week spent on infrastructure is a week not spent learning from customers.
  • Operational maturity: operating many services requires automation they do not have yet.

The “so they don't have to redo it” argument is misleading. If the monolith is well modularized, extracting a service later on is a manageable job. And if the business does not work out, there will be nothing to scale.

Common mistake: answering “it depends” without specifying on what. The answer always depends on the context, but the exercise gives enough context to decide.

Solution to Exercise 3

With the current code, the rule is written inside the function that displays the product page. To show it in the cart, Íker will have to copy the condition into the cart function. From that moment on, the threshold will exist in two places. When the business changes it again, someone will have to remember to modify both, exactly the same problem that happened with the shipping cost.

With a real separation into layers:

  • The rule would live in a single place in the business logic layer, for example, in a function that receives the stock and returns the notice.
  • Both the product page and the cart page would call that function.
  • Changing the threshold from 5 to 10 would mean modifying a single value.
  • The rule could be tested automatically without needing a database or a browser.

This is the kind of improvement we will tackle in Module 2.

Conclusion

In this lesson you have met the seven most widespread architectural styles: monolithic, layered, client-server, service-oriented, microservices, event-driven, and serverless. You have seen that they answer different questions and that is why they combine, that none is the best in absolute terms, and that the choice depends on the quality attributes, the team, the operational maturity, and the constraints. You have also placed Verdalia: a client-server, monolithic system whose layers only exist on paper.

Knowing the options is necessary, but not sufficient. Marta now has several alternatives on the table, and each one improves some things at the expense of others. How do you choose in a reasoned way, and how do you record that choice? That is what the last lesson of the module is about: “Architectural Decisions and Trade-offs.”

© Copyright 2026. All rights reserved