Over the course of the module we have gathered everything needed to decide: we know what architecture is, what neglecting it costs, what Verdalia's quality goals are, and which styles exist. The hardest part remains: choosing. In this lesson you will learn why every architectural decision means giving something up, how to compare alternatives with a reasoned method, and how to record what was decided so that the team, a year from now, understands why the system is the way it is.

In Architecture, Everything Is a Trade-off

A trade-off is a situation in which improving one aspect of the system forces you to worsen another. It is not an occasional difficulty: it is the very nature of architecture.

The reason is that quality attributes compete for the same resources and often pull in opposite directions:

If you want more You usually pay with
Availability More cost and more complexity, because pieces have to be duplicated
Security Less convenience and more operational work
Performance More cost or less maintainability, because of the optimizations
Scalability More operational complexity
Flexibility Less simplicity
Immediate delivery speed Technical debt

Two practical consequences follow from this:

  • There is no best architecture, only the least bad one for a context. Whoever presents a solution with no drawbacks has not looked for them.
  • If a decision has no cost, it is probably not a decision. It is just an obvious improvement, and it should be made without further debate.

That is why we devoted Lesson 01-03 to prioritizing: priorities are what make it possible to resolve trade-offs without arguing in circles.

What an Architectural Decision Is

An architectural decision is a choice that affects the structure of the system or its quality attributes and that is expensive to reverse.

That last trait, the cost of reversing it, is what distinguishes it from any ordinary design decision. A useful image is that of doors:

Kind of decision Image Characteristics How to handle it
Reversible Two-way door: if you do not like what is on the other side, you come back Undoing it costs hours or days and affects few people Decide fast, try, and correct
Hard to reverse One-way door: once you go through, coming back is very expensive Undoing it costs months, money, or data Analyze, consult, and put it in writing

Let us look at examples at Verdalia:

Decision Cost of reversing it Architectural?
The name of a variable Minutes No
Library for generating shipping labels as PDFs A couple of days No
Stock threshold for the “Last units” notice Minutes No
Database engine Months, with the risk of losing data Yes
Splitting the store into independent services Many months Yes
Payment gateway Weeks, plus renegotiating contracts Yes
Where the credentials are stored Days, but it affects the security of the whole system Yes

The last example teaches something important: a decision is also architectural if, even though it costs little to change, it affects a quality attribute of the whole system.

There are two symmetrical mistakes worth avoiding:

  • Treating reversible decisions as irreversible. It produces paralysis: weeks of meetings to choose something that could have been tried in an afternoon.
  • Treating irreversible decisions as reversible. It produces regret: far-reaching decisions made in a hurry in a hallway.

A good design practice consists of turning one-way doors into two-way doors, that is, organizing the system so that changing your mind is cheap. A good part of Module 2 is about that.

Typical Trade-offs

Certain trade-offs come up again and again. Knowing them helps you spot them in time.

Performance vs. Cost

You can almost always go faster by paying more. The question is how much each improvement is worth.

Lucía requested a quote for a server with twice the capacity: it would cost €240 a month instead of €120. According to her tests, the limit would go from 250 to about 400 concurrent users. Doubling the spending does not double the capacity, and it is still very far from the 1,000 users of scenario QS-1.

Option Monthly cost Concurrent users supported
Current server €120 250
Server with twice the capacity €240 400

This phenomenon, diminishing returns, is common: beyond a certain point, each additional improvement costs more than the previous one.

Consistency vs. Availability

Imagine that a single olive tree is left in the warehouse and two customers have it in their carts. At checkout time, the system cannot check the stock because that part is responding slowly. There are two options:

Option What is prioritized Consequence
Reject the purchase until the stock can be checked Consistency: the data is always correct Sales are lost while the problem lasts
Accept the purchase and check afterward Availability: the store keeps selling The same olive tree may be sold twice, and one customer will have to be apologized to

Neither of the two is correct in absolute terms. For card charges, Verdalia wants consistency: a customer must never be charged twice. For the “people viewing this product” counter, it prefers availability: it does not matter if the number is approximate.

The conclusion is that this trade-off is not decided once for the whole system, but piece of data by piece of data. Its rigorous formulation is studied in Module 4, when dealing with scaling the data layer.

Simplicity vs. Flexibility

Andrés wants to be able to change the shipping cost rules. Íker sees two paths:

Option Effort Advantage Drawback
A function with the current rules written in the code 1 day Easy to understand and to test Every rule change requires a deployment
A rules system configurable from an admin panel 3 weeks The business changes the rules without technical intervention Much more code to maintain and more ways to get it wrong

Flexibility is not free: it is complexity paid upfront in exchange for a future need that may never arrive. The deciding question is how often the rules really change. If it is twice a year, the simple option is the right one.

Build vs. Buy

Aspect Build Buy or subscribe
Initial cost High, in the team's time Low
Recurring cost In-house maintenance Fees or commissions
Fit to the needs Total Limited to what the provider offers
Control Total Dependence on the provider
Responsibility Your own Shared

A rule that works well: build what differentiates you and buy the rest. Verdalia buys card processing from PagoRaíz because taking payments does not set it apart from its competitors, and doing it badly has serious consequences. On the other hand, it builds its catalog, because the information on how to care for each plant is part of its value.

A Process for Deciding

Important decisions deserve a method. It does not have to be heavy: five steps are enough.

flowchart LR
    context["1. Context"] --> options["2. Options"]
    options --> criteria["3. Weighted criteria"]
    criteria --> decision["4. Decision"]
    decision --> consequences["5. Consequences"]
    consequences -.->|"If the context changes"| context
Step What is done Result
1. Context Describe the problem, the quality scenarios affected, and the constraints A description anyone can understand
2. Options Identify at least three real alternatives, including doing nothing List of options
3. Weighted criteria Rate each option against the quality attributes, with their weights Decision matrix
4. Decision Choose and explain why A chosen and justified option
5. Consequences Note what is gained, what is lost, and when it should be revisited List of consequences and review conditions

Let us apply it to Verdalia's first big decision.

Step 1: Context

  • Problem. The store cannot withstand campaign peaks, and each change costs four times more than at the beginning.
  • Scenarios affected. Mainly QS-3, on availability, and QS-5, on maintainability.
  • Constraints. A technical team of three people, five months until the spring campaign, and a maximum of €500 a month on average for infrastructure.

Step 2: Options

Each member of the team came to the meeting with a proposal:

Option Who proposes it What it consists of
A. Upgrade the server without touching the code Andrés Rent a bigger machine. It is fast and does not distract the team
B. Keep the monolith and modularize it Marta Keep a single application, but reorganize it into modules with clear boundaries
C. Rewrite the store as microservices Íker Split the store into independent services, one per functional area

Step 3: Weighted Criteria

The criteria are the seven quality attributes, with the weights Marta and Andrés agreed on in Lesson 01-03. Each option is rated from 1 to 5 on each criterion, where 1 is very bad and 5 is very good:

Criterion Weight A. Upgrade server B. Modular monolith C. Microservices
Availability 25 2 3 4
Maintainability 20 1 4 3
Security 15 2 3 3
Performance 15 3 3 3
Scalability 10 2 3 5
Cost 10 4 4 1
Operability 5 2 4 1

As important as the rating is its justification. Some of the most debated ones were:

  • Maintainability of A, a 1. A bigger server does not change a single line of code: the problem remains intact.
  • Maintainability of C, a 3 and not a 5. Microservices make change easier when the boundaries are well drawn. Splitting tangled code without organizing it first moves the tangle onto the network.
  • Operability of C, a 1. Lucía would have to deploy and monitor seven services instead of one application, without the necessary automation.
  • Cost of C, a 1. Íker estimates between 12 and 14 months of work, during which hardly any improvements would be delivered to the business.

The Weighted Decision Matrix in Python

Calculating the matrix by hand is simple, but doing it with a program lets you instantly try out what happens if the weights or the ratings change.

The Data

weights = {
    "availability": 25,
    "maintainability": 20,
    "security": 15,
    "performance": 15,
    "scalability": 10,
    "cost": 10,
    "operability": 5,
}

options = {
    "A. Upgrade the server without touching the code": {
        "availability": 2, "maintainability": 1, "security": 2,
        "performance": 3, "scalability": 2, "cost": 4, "operability": 2,
    },
    "B. Keep the monolith and modularize it": {
        "availability": 3, "maintainability": 4, "security": 3,
        "performance": 3, "scalability": 3, "cost": 4, "operability": 4,
    },
    "C. Rewrite the store as microservices": {
        "availability": 4, "maintainability": 3, "security": 3,
        "performance": 3, "scalability": 5, "cost": 1, "operability": 1,
    },
}

Explanation:

  • weights is a dictionary that associates each criterion with its importance. The weights add up to 100.
  • options is a dictionary of dictionaries. The outer key is the name of the option; the inner dictionary holds its rating on each criterion.
  • The criterion names must match exactly in both structures, because they will be used to cross-reference the data.

The Calculation

def weighted_score(ratings, weights):
    """Calculate an option's score: each rating is multiplied by the
    weight of its criterion, and the total is divided by the sum of weights."""
    total = 0
    for criterion, weight in weights.items():
        total += ratings[criterion] * weight
    return total / sum(weights.values())


def rank(options, weights):
    """Return the options ordered from highest to lowest score."""
    results = []
    for name, ratings in options.items():
        score = weighted_score(ratings, weights)
        results.append((name, score))
    return sorted(results, key=lambda result: result[1], reverse=True)


for name, score in rank(options, weights):
    print(f"{score:.2f}  {name}")

Output:

3.35  B. Keep the monolith and modularize it
3.15  C. Rewrite the store as microservices
2.15  A. Upgrade the server without touching the code

Explanation:

  • weighted_score goes through the criteria. For each one, it multiplies the option's rating by the weight and accumulates it in total.
  • Dividing by the sum of the weights brings the result back onto the 1-to-5 scale, which makes it easier to interpret.
  • rank calculates each option's score and stores name-and-score pairs in a list.
  • sorted orders that list. The key parameter says to sort by the second element of each pair, the score, and reverse=True says to go from highest to lowest.

Let us check option B by hand: 3 times 25, plus 4 times 20, plus 3 times 15, plus 3 times 15, plus 3 times 10, plus 4 times 10, plus 4 times 5. The sum is 335, which divided by 100 gives 3.35.

Sensitivity Analysis

The difference between B and C is small. Would the result change with other priorities? Suppose a company that cares much more about scalability than about maintainability:

alternative_weights = dict(weights)
alternative_weights["scalability"] = 25
alternative_weights["maintainability"] = 5

for name, score in rank(options, alternative_weights):
    print(f"{score:.2f}  {name}")

Output:

3.45  C. Rewrite the store as microservices
3.20  B. Keep the monolith and modularize it
2.30  A. Upgrade the server without touching the code

Explanation:

  • dict(weights) creates a copy of the dictionary, so as not to alter the original weights.
  • The importance of two criteria is swapped, so the sum is still 100.
  • With these priorities, option C wins.

This exercise, called sensitivity analysis, teaches two things. First, that the decision depends on the priorities, which is why it was essential to agree on them with the business beforehand. Second, that when the result is close, the matrix is not enough and other factors have to be looked at.

Step 4: The Decision

The matrix is a tool for organizing the conversation, not an oracle. In this case, what definitively tips the balance is the constraints:

Constraint A. Upgrade server B. Modular monolith C. Microservices
Five months until the campaign Meets it Meets it, gradually Does not meet it: between 12 and 14 months
Team of three people Meets it Meets it Very hard to operate
€500 a month on average Meets it Meets it Doubtful

An option that violates a constraint is ruled out, whatever its score. The correct order is: first the constraints filter, then the criteria rank.

The decision is option B: keep the monolith and modularize it.

Step 5: The Consequences

Every honest decision acknowledges what it loses. Option B does not by itself solve the campaign peaks, and Íker is right that microservices would scale better. Those consequences are written down, along with the rest of the decision, in a document we will look at next.

Architecture Decision Records

An architecture decision record, known as an ADR, is a brief document that captures an architectural decision, the context in which it was made, and its consequences.

Why Write Them

A year from now, someone will ask: “why don't we use microservices?” Without a record, there are three possible endings: nobody remembers, the whole discussion is repeated, or the decision is changed without knowing the reasons that supported it.

Without ADRs With ADRs
The reasons live in the memory of whoever was in the meeting The reasons are written down and available to everyone
Discussions are repeated There is a discussion only if the context has changed
Newcomers do not understand the why of the system Newcomers read the history of the decisions
Decisions are changed out of ignorance Decisions are changed consciously

Characteristics of a Good ADR

  • Brief. One or two pages. If it is longer, nobody will read it.
  • One decision per document. They are numbered sequentially: ADR-001, ADR-002, and so on.
  • Immutable. An accepted ADR is not rewritten. If the decision changes, a new one is written that supersedes the previous one, and the old one is marked as superseded. That way the history is preserved.
  • Close to the code. At Verdalia they are stored as text files in the docs/adr/ folder of the repository, so that they evolve alongside the system.

States of an ADR

flowchart LR
    proposed["Proposed"] --> accepted["Accepted"]
    proposed --> rejected["Rejected"]
    accepted --> superseded["Superseded by another ADR"]

Template

ADR-NNN: short title describing the decision

Status: Proposed, Accepted, Rejected, or Superseded by ADR-NNN
Date: date of the decision
Participants: who decides and who was consulted

Context
    What problem has to be solved, which quality scenarios
    are affected, and which constraints exist.

Options considered
    List of alternatives, with a brief assessment of each one.

Decision
    What has been decided, written in the affirmative.

Consequences
    Positive: what is gained.
    Negative: what is lost or what becomes more complicated.
    Risks: what could go wrong.

Review conditions
    Under which circumstances the decision should be reconsidered.

The tools for documenting the architecture as a whole, including diagrams, are covered in Module 6. The ADR is only the piece that captures the why.

Verdalia's ADR-001

This is the team's first ADR, exactly as it was written.

ADR-001: Keep the monolith and modularize it before considering microservices

Status: Accepted

Date: 2026-10-05

Participants: Marta decides; Íker and Lucía consulted; Andrés informed, and he approves the budget.

Context

The store is a Flask monolith with a PostgreSQL database on a single server. It has two main problems. First, it cannot withstand campaign peaks: on the day before the last Mother's Day it was down for three hours. Second, the code is badly tangled: a typical change has gone from costing 2 days to costing 9, and one in three deployments causes an incident.

The quality scenarios most affected are QS-3, on availability, and QS-5, on maintainability.

The constraints are: a technical team of three people, five months until the spring campaign, and a maximum infrastructure spend of €500 a month on average.

Options considered

  • A. Upgrade the server without touching the code. Weighted score: 2.15. Fast and cheap, but it does not improve maintainability and only raises the limit from 250 to about 400 concurrent users.
  • B. Keep the monolith and modularize it. Weighted score: 3.35. Improves maintainability with low risk and is compatible with the deadline.
  • C. Rewrite the store as microservices. Weighted score: 3.15. The best on scalability, but it requires between 12 and 14 months and an operational maturity the team does not have.

Decision

We will keep the store as a single deployable application and gradually reorganize it into modules with explicit boundaries, one for each functional area: catalog, cart, orders, payments, inventory, shipping, and notifications. For now we will keep a single database. We will not start any migration to microservices until the review conditions are met.

Consequences

Positive:

  • The team keeps delivering improvements to the business while it reorganizes the code.
  • Operational simplicity is maintained: a single application to deploy and monitor.
  • Well-delimited modules will make it easier to extract services in the future if it ever becomes necessary.

Negative:

  • This decision does not by itself solve the campaign peaks. Additional decisions on scaling and availability will be needed.
  • It will not be possible to scale one functional area separately from the others.
  • A serious failure in one module can still affect the whole store.

Risks:

  • That day-to-day pressure leaves the modularization half done. To mitigate it, 30% of each month's development time will be reserved.

Review conditions

This decision will be reviewed if any of these circumstances arises: the technical team exceeds eight people or splits into several teams; one area needs a capacity very different from the rest and cannot be served by the single application; or the store exceeds 10,000 orders a month. In any case, it will be reviewed in June, at the end of the spring campaign.

Notice several details of the document:

  • The title already contains the decision. Reading the list of titles is enough to know the history of the architecture.
  • It acknowledges what it loses. The negative consequences take up as much space as the positive ones. An ADR with no drawbacks is not credible.
  • It does not close the door. The review conditions make clear that microservices are not ruled out forever, only for this context. That also helped Íker accept the decision.
  • It points to future decisions. Still pending are, among others, how to scale for the campaign, where to store the credentials, how to deploy without downtime, and how to guarantee the backups. Each will have its own ADR over the course of the course.

Common Mistakes and Tips

  • Looking for the option with no drawbacks. It does not exist. The goal is to choose which drawbacks you prefer to take on.
  • Comparing a single option. If there is only one alternative on the table, you are not deciding, you are justifying. Always include the option of doing nothing.
  • Adjusting the ratings until the favorite wins. The matrix is only useful if it is rated honestly and, if possible, by several people.
  • Confusing the matrix with the decision. A difference of two tenths is not significant. When the result is close, the constraints and the risks rule.
  • Forgetting the constraints. An excellent option that does not arrive in time or that the team cannot operate is not an option.
  • Writing the ADR weeks later. By then the discarded alternatives, which are precisely the most valuable part, will have been forgotten.
  • Modifying an accepted ADR. The history is lost. If the decision changes, write a new ADR that supersedes the previous one.
  • Practical tip. If you are unsure whether a decision deserves an ADR, ask yourself whether someone will want to know the why a year from now. If the answer is yes, write it: it takes twenty minutes.

Exercises

Exercise 1: Identify the Trade-off

For each situation, state which typical trade-off is at play and which question would have to be answered to resolve it:

  1. Lucía proposes renting a second server that stays on standby in case the first one fails.
  2. Andrés asks whether it would not be better to develop an in-house email sending system, instead of paying the external service.
  3. Íker wants the catalog to accept any future kind of product, with fully configurable fields.
  4. During a traffic peak, the stock number shown in the catalog might be a few seconds out of date.

Exercise 2: Extend the Decision Matrix

Andrés proposes a fourth option: replacing the store with a commercial e-commerce platform, paying a monthly fee. The team rates it like this:

Criterion D. Commercial platform
Availability 4
Maintainability 1
Security 4
Performance 4
Scalability 4
Cost 2
Operability 5

Maintainability gets a 1 because the platform does not allow programming custom functions, such as the “Plant of the Month” subscription. Calculate the weighted score of option D with Verdalia's weights, state which position it ends up in, and reflect on which factors the matrix does not capture.

Exercise 3: Write an ADR

Following the template, write a brief ADR for this Verdalia decision: keep using PagoRaíz for payments instead of building an in-house payment system. Number it as a practice ADR, without assigning it a number from the real series.

Solutions

Solution to Exercise 1

Situation Trade-off Question to answer
1. Standby server Availability vs. cost Which costs more, the additional server or the outages it prevents?
2. In-house email Build vs. buy Does sending emails differentiate Verdalia from its competition?
3. Configurable catalog Simplicity vs. flexibility How often do genuinely new kinds of product appear?
4. Out-of-date stock Consistency vs. availability What harm does showing slightly old data cause?

In situation 4, the harm is small if the stock is checked again at checkout time. That is why approximate data is usually accepted in the catalog and exact data is required at payment.

Solution to Exercise 2

options["D. Replace the store with a commercial platform"] = {
    "availability": 4, "maintainability": 1, "security": 4,
    "performance": 4, "scalability": 4, "cost": 2, "operability": 5,
}

for name, score in rank(options, weights):
    print(f"{score:.2f}  {name}")

Output:

3.35  B. Keep the monolith and modularize it
3.25  D. Replace the store with a commercial platform
3.15  C. Rewrite the store as microservices
2.15  A. Upgrade the server without touching the code

The calculation by hand: 4 times 25, plus 1 times 20, plus 4 times 15, plus 4 times 15, plus 4 times 10, plus 2 times 10, plus 5 times 5. The sum is 325, which divided by 100 gives 3.25. It ends up in second place, just one tenth behind option B.

With such a close result, you have to look at what the matrix does not capture:

  • The cost of the migration. Moving 15,000 products, the customers, and the order history.
  • Dependence on the provider. If it raises its prices or changes its terms, leaving will be hard. It is a one-way door.
  • Differentiation. If Verdalia's value lies in custom functions, giving them up affects the business strategy, not just the technology.

Option D is legitimate. For a store with no special needs, it would probably be the best one. What rules it out at Verdalia is a specific business goal, and that must be written down.

Common mistake: accepting the winning option without looking at the distance to the runner-up. A tenth of difference means, in practice, a tie.

Solution to Exercise 3

One possible wording:

Practice ADR: Keep using PagoRaíz for payments

Status: Accepted

Participants: Marta decides; Andrés and Íker consulted.

Context: Verdalia takes card payments for about 2,000 orders a month. Handling card data entails very demanding security obligations. The technical team is three people, and taking payments does not differentiate Verdalia from its competitors.

Options considered: build an in-house payment system; continue with PagoRaíz; switch to another gateway.

Decision: We will keep delegating payments to PagoRaíz. Card data will not pass through Verdalia's servers.

Positive consequences: the obligations of safeguarding card data are not taken on; the team focuses on what differentiates the store.

Negative consequences: a commission is paid on every charge; if PagoRaíz is down, the store cannot take payments; there is dependence on a third party.

Review conditions: if the commissions exceed the estimated cost of an alternative, or if PagoRaíz accumulates outages that violate the 99.9% availability target.

Check that your version meets these points: the title expresses the decision, there are at least two alternatives, negative consequences are listed, and review conditions exist. If any is missing, the ADR is incomplete.

Conclusion

In this lesson you have learned that in architecture everything is a trade-off and that what distinguishes an architectural decision is the cost of reversing it. You have seen four recurring trade-offs, a five-step process for deciding, a weighted decision matrix that turns business priorities into a reasoned comparison, and architecture decision records, which preserve the why of each choice.

This lesson closes the first module. Verdalia has gone from having a system inherited through inertia to having a solid starting point: a description of its architecture, an estimate of what its problems cost, six quality scenarios, QS-1 through QS-6, priorities agreed with the business, and a first recorded decision, ADR-001: keep the monolith and modularize it.

That decision opens an immediate question: what exactly does modularizing mean, and how do you know whether a module is well delimited? In Module 2 we will go into the store's code to answer it, starting with the two concepts that measure the quality of any division: we will see them in the lesson “Coupling, Cohesion, and Modularity.”

© Copyright 2026. All rights reserved