The same pieces can be used to build very different systems. An architecture model or style is a recognizable way of organizing components and their relationships: how many units are deployed, how they communicate, and who owns which data. Choosing the model is probably the structural decision with the greatest impact, because it shapes scalability, speed of change, operating cost, and even how the teams are organized. In this lesson we will walk through the most important styles, from the monolith to serverless, with their structure, advantages, drawbacks, and selection criteria, and we will finish by reasoning about where RouteManager should evolve.
- What an architecture model is
An architecture model or style is a large-scale organizational pattern. It defines three things:
- The units: what parts the system is divided into and which ones are deployed separately.
- The communication: how those parts talk to one another (direct calls, messages, events).
- The data: whether it is shared or each part has its own.
Three warnings before we start:
- The styles are not mutually exclusive. A real system combines several: a monolith is usually organized in layers and is, at the same time, the server in a client-server model.
- No style is better in the abstract. Each one solves some problems and creates others.
- The more distributed styles are not "more modern and therefore better": they are more capable and also more expensive to operate.
- Monolith
Structure. All the functionality forms a single unit that is built, deployed, and run together, usually against a single database.
flowchart TB
U["Users"]
subgraph M["A single deployable application"]
A["Shipments"]
B["Delivery"]
C["Billing"]
D["Remaining functions"]
end
DB[("Single database")]
U --> M
M --> DB
Advantages.
- Simple to develop, test, and deploy: there is only one thing.
- Calls between functions are internal, fast, and reliable.
- Transactions that span several areas are trivial, because everything is in the same database.
- Low operating cost.
Drawbacks.
- It can only be scaled as a whole, even if just one part is under load.
- A failure or excessive resource consumption in one function affects all of them.
- Over time and without discipline, the internal boundaries blur.
- All the teams deploy at the same time, which slows down releases.
When to choose it. New products, small teams, domains that are still poorly understood. It is the reasonable starting point for most systems. RouteManager is a monolith, and for years that was the right decision.
- Layered (n-tier) architecture
Structure. The system is divided into horizontal layers according to their technical responsibility. Each layer talks only to the one immediately below it. The most common variant has three:
flowchart TB
P["Presentation layer: screens and API"]
N["Business layer: rules and processes"]
D["Data layer: access and storage"]
P --> N --> D
When the layers are deployed on different machines they are called tiers, hence the name n-tier.
Advantages.
- It clearly separates technical responsibilities.
- It allows teams to specialize and one layer to be replaced without touching the others.
- Each physical tier can be protected and sized separately.
Drawbacks.
- It divides by technology, not by business: a new feature forces you to touch every layer.
- On its own, it does not prevent business areas from getting mixed up within each layer.
- It tends to end up as a monolith with layers.
When to choose it. As the internal organization of almost any application. It is rarely sufficient as the only structuring criterion in large systems.
- Client-server
Structure. There are two roles: the clients, which make requests, and the server, which responds and safeguards the data and the shared logic.
flowchart LR
C1["Client: browser"] -->|"request"| S["Server"]
C2["Client: mobile app"] -->|"request"| S
C3["Client: a merchant system"] -->|"request"| S
S -->|"response"| C1
S --> DB[("Data")]
Advantages.
- Centralized data and rules: a single source of truth.
- A variety of clients (web, mobile, other systems) reuse the same server.
- A simple, universally understood model.
Drawbacks.
- The server is a single point of failure and a bottleneck if it is not replicated.
- Clients depend on the connection.
When to choose it. It is the basis of practically every web and mobile system. Rather than being chosen, it is assumed. The real decision is how much logic to put in the client: the courier app, for example, needs to store data locally in order to keep working in a parking garage with no coverage.
- Service-oriented architecture (SOA)
Structure. The company's functionality is exposed as reusable business services, of considerable size, that different applications consume. Traditionally they communicate through an enterprise service bus (ESB) that routes and transforms the messages.
flowchart TB
A1["Sales application"] --> ESB
A2["Logistics application"] --> ESB
A3["Customer portal"] --> ESB
ESB["Enterprise service bus"]
ESB --> S1["Customer service"]
ESB --> S2["Order service"]
ESB --> S3["Billing service"]
Advantages.
- Reuse: a capability is implemented once and used by many.
- It integrates heterogeneous systems, including legacy ones.
- Formal contracts between services.
Drawbacks.
- The bus easily becomes a bottleneck and a single point of failure.
- Business logic tends to migrate into the bus, where it is hard to maintain.
- Services often share databases, so the coupling persists.
- It requires heavy centralized governance.
When to choose it. Large organizations with many existing applications that need to be integrated. For new systems, lighter approaches are preferred today.
- Microservices
Structure. The system is divided into small services, each focused on one business capability, with its own database, independently deployable, and owned by one team. They communicate through lightweight APIs or messages, with no smart central bus.
flowchart TB
U["Clients"] --> G["API gateway"]
G --> S1["Shipments service"]
G --> S2["Tracking service"]
G --> S3["Billing service"]
S1 --> B1[("Shipments data")]
S2 --> B2[("Tracking data")]
S3 --> B3[("Billing data")]
S1 -.->|"messages"| S2
The essential difference from SOA lies in two points: each service is the exclusive owner of its data, and the intelligence is in the services, not in the channel that connects them.
Advantages.
- Each service scales separately, according to its load.
- Teams deploy independently and frequently.
- A failure is contained within one service, if it has been designed for that.
- Each service can use the technology that suits it best.
Drawbacks.
- It is a distributed system: the network fails, calls are slower, and errors are partial.
- Keeping data consistent across services is hard; there is no longer a single transaction.
- Operations multiply: dozens of deployments, databases, and things to monitor.
- It demands mature automation and observability from day one.
- If the boundaries are chosen badly, you get a "distributed monolith": the worst of both worlds.
When to choose it. Organizations with many teams that get in each other's way in a monolith, with parts of the system that have very different scaling needs, and with a real ability to operate distributed systems.
- Event-driven architecture
Structure. Components do not call one another; instead they publish events: facts that have already happened, such as "shipment delivered." Other components subscribe to the events they are interested in and react. An intermediary, the event channel or broker, distributes them.
flowchart LR
P["Delivery: publishes delivery confirmed"] --> B["Event channel"]
B --> C1["Notifications: sends the SMS"]
B --> C2["Tracking: updates the status"]
B --> C3["Billing: records the service"]
The producer does not know who is listening or how many listeners there are. Adding a fourth consumer does not require touching Delivery.
Advantages.
- Very low coupling between producers and consumers.
- The producer does not wait: peaks are absorbed in the channel.
- It is easy to add new reactions to the same fact.
Drawbacks.
- The complete flow of an operation is harder to follow and to debug.
- Data is not up to date everywhere at the same instant, but a moment later. This is called eventual consistency.
- You have to plan for duplicated, lost, or out-of-order events.
When to choose it. When a single fact triggers several independent reactions and an immediate response is not needed. It is usually combined with other styles rather than replacing them. The specific techniques are covered in Module 2.
- Serverless
Structure. The logic is split into functions that the cloud provider runs on demand, combined with managed services (storage, databases, queues). No server is administered.
flowchart LR
E1["Web request"] --> F1["Function: get status"]
E2["File uploaded"] --> F2["Function: generate thumbnail"]
E3["Timer"] --> F3["Function: daily report"]
F1 --> D[("Managed database")]
F2 --> O[("Object storage")]
F3 --> D
Advantages.
- No server management and automatic scaling, even down to zero.
- You pay per execution: ideal for sporadic or highly variable workloads.
- Very fast to get up and running.
Drawbacks.
- Strong dependence on the provider.
- Limits on duration and resources per execution.
- Additional latency on the first call after a period of inactivity, the so-called cold start.
- With a high, constant load it can turn out more expensive than having servers.
- Many small functions are hard to test and to follow as a whole.
When to choose it. Event-driven tasks, irregular workloads, automations, and auxiliary functions. Less suitable for a transactional core with a constant load.
- Modular monolith: the intermediate step
Structure. It is still a single deployable application, but divided internally into business modules with strict boundaries: each module publishes an interface, hides its internals, and is the exclusive owner of its tables, which live in a schema of their own within the same database.
flowchart TB
U["Users"]
subgraph M["A single deployable application"]
A["Shipments module"]
B["Delivery module"]
C["Billing module"]
A -->|"only through the interface"| B
B -->|"only through the interface"| C
end
U --> M
A --> SA[("Shipments schema")]
B --> SB[("Delivery schema")]
C --> SC[("Billing schema")]
Compare it with the monolith diagram in section 2: there, everything shared a single database with no boundaries; here, each module accesses only its own schema and talks to the others only through an interface.
Advantages.
- It keeps the operational simplicity of the monolith: one deployment, one database.
- It provides much of the clarity of microservices: boundaries, owners, contracts.
- If one day a module needs to live on its own, extracting it is feasible because its boundary already exists.
- It lets you discover the right boundaries at low cost, before getting them wrong becomes expensive.
Drawbacks.
- It still scales as a unit.
- The boundaries depend on the team's discipline and on tools that enforce them; nothing physical prevents anyone from bypassing them.
- All the modules still share a deployment and resources.
When to choose it. When a monolith has lost its internal order but the organization does not yet have the need or the maturity to operate many services. It is also the safest path to microservices, if they are ever needed.
- Comparison table
| Style | Deployment units | Data | Scaling | Operational complexity | Team autonomy | Best for |
|---|---|---|---|---|---|---|
| Monolith | One | Shared | All together | Low | Low | Early stages, small teams |
| Layered | One or a few | Shared | Per tier | Low | Low | Internal organization |
| Client-server | Server and clients | Centralized | Of the server | Low | Low | Basis of web and mobile |
| SOA | Several, plus the bus | Often shared | Per service, limited by the bus | High | Medium | Integrating many existing applications |
| Microservices | Many | One per service | Independent | Very high | High | Many teams and uneven scale |
| Event-driven | Variable | Usually per component | Independent | High | High | Multiple, asynchronous reactions |
| Serverless | Many functions | Managed services | Automatic | Medium, delegated to the provider | High | Irregular workloads, event-triggered tasks |
| Modular monolith | One | One schema per module | All together | Low | Medium | Tidying up a monolith and preparing for the future |
- Which model suits Rutaverde
Marta calls a working session to reason about the destination. The aim is not yet to make the formal decision, but to understand the options.
What we know about Rutaverde.
- The technology department has about 35 people: 22 developers in three teams, 6 operations people with Íñigo, 2 security people with Clara, and the architecture team.
- Operations are almost entirely manual, and nobody has ever operated a distributed system.
- The load is not uniform. Tracking receives far more queries than any other function: each recipient checks the status of their package about 4 times, which means about 160,000 queries a day on a normal day and close to 800,000 in peak season.
- Notifications depend on an external provider and, as we saw, currently slow the couriers down.
- The business cannot stop during the transformation.
Three possible paths.
| Path | For | Against |
|---|---|---|
| Keep the monolith and upgrade the server | Fast, cheap, no transition risk | It does not eliminate the single points of failure or the domino effect; the limit will be reached again |
| Rewrite everything as microservices | Maximum scaling capacity and autonomy | A multi-year project, very high risk, the team has no experience, and the current boundaries are unknown |
| Modular monolith and gradual extraction of a few services | Tackles the real problems in order, with contained risk | Requires discipline and a long period in which old and new coexist |
The reasoning. The second path is tempting, but it clashes with two things. With Rutaverde's principle P3, simple first: going from one piece to thirty multiplies the operational work for a team that deploys by hand. And with the reality that nobody knows today where the right boundaries are, because the code is tangled together. Dividing a system along the wrong boundaries produces a distributed monolith.
The third path makes it possible to discover the boundaries inside the monolith, where corrections are cheap, and to extract only what solves a specific problem by being extracted. Two modules stand out as candidates:
- Tracking: it concentrates most of the reads, it is almost read-only, and its load soars in peak season. If it lived on its own, it could scale by itself, and a flood of queries would not affect shipment creation.
- Notifications: it depends on a slow external provider, it does not need an immediate response, and it fits naturally with an event-driven style.
flowchart TB
U["Merchants, couriers, recipients"] --> ENTRY["Entry point"]
ENTRY --> TRK["Tracking service"]
subgraph M["RouteManager as a modular monolith"]
M1["Customers"]
M2["Shipments"]
M3["Planning"]
M4["Delivery"]
M5["Billing"]
M6["Reports"]
end
ENTRY --> M
M -.->|"events"| TRK
M -.->|"events"| NOTIF["Notifications service"]
M --> DB[("Database with one schema per module")]
TRK --> TD[("Tracking data")]
NOTIF --> PR["SMS and email provider"]
The diagram shows the destination that is taking shape: six modules remain in a tidy monolith, and Tracking and Notifications move out as independent services fed by events. It is a combination of three styles (modular monolith, services, and events), which is perfectly normal.
For now, this is a reasoned hypothesis. Turning it into a decision requires two things we do not have yet: the quality requirements expressed in numbers, and a method for comparing options and recording the choice. Those are the two remaining lessons of the module.
Common Mistakes and Tips
- Choosing microservices for prestige. Above all they solve an organizational problem, that of many teams getting in each other's way. With three teams, the cost far outweighs the benefit.
- Believing the monolith is the problem. RouteManager's problem is not that it is a single piece, but that it has no internal boundaries and no redundancy.
- Splitting before knowing the boundaries. Extracting services from tangled code moves the tangle onto the network, where it is slower and more fragile.
- Sharing the database between services. If two services read the same tables, they are not independent, whatever they are called. This is principle P1.
- Approaching the migration as a total rewrite. Complete rewrites usually fail: they take years and the business does not wait. Gradual evolution delivers value in stages.
- Tip: before extracting a service, state in one sentence what specific problem its extraction solves. If you cannot, leave it where it is.
Exercises
Exercise 1
State which style or combination of styles you would recommend in each situation, and why:
- A newly founded company, with four developers, launching a product whose market it does not yet know well.
- A banking group with forty applications from different eras that need to share customer information.
- A process that resizes images a few times a day, with some very busy days and some days with no activity at all.
- A platform with three hundred developers in forty teams, whose deployments block one another.
Solution
- Monolith, ideally organized as a modular monolith. The team is small and the domain is going to change a lot: it pays to be able to reorganize the code at low cost.
- SOA, or an integration layer with APIs and events. The problem is integrating many existing, heterogeneous systems, which is what this style was born for.
- Serverless. A sporadic, irregular load, and a short task triggered by an event: you pay only when it is used.
- Microservices. This is the case they are designed for: many teams that need deployment autonomy, in an organization that can presumably take on the operational complexity.
Exercise 2
Explain in your own words three differences between a modular monolith and a microservices architecture, and one thing they have in common.
Solution
Differences:
- Deployment: the modular monolith is deployed as a single unit; each microservice, separately.
- Communication: in the modular monolith the modules call one another within the same process, quickly and reliably; microservices communicate over the network, with latency and possible failures.
- Data: the modules have separate schemas within a single database; each microservice has its own database.
- It is also valid to mention scaling (as a whole versus independent) or operational complexity.
In common: both divide the system by business capabilities, with explicit boundaries, published interfaces, and a single owner for every piece of data.
Exercise 3
A Rutaverde developer proposes extracting the Billing module as an independent service as well, "while we're at it." Argue for or against using what you know about the case.
Solution
With the information available, against. Billing has none of the reasons that justify extracting Tracking and Notifications: its load is low and predictable, it is used by internal staff, it runs mostly in a nightly process, and it does not need to scale separately. Extracting it would add one more service to deploy, monitor, and protect, and would also complicate consistency between shipment data and invoice data, which today is handled with a single transaction. That contradicts principle P3. What Billing does need is to stop reading the Shipments tables directly, and that can be achieved within the modular monolith. If a specific reason appeared in the future, for example a dedicated team with a different release pace, the boundary would already be in place to extract it.
Conclusion
We have walked through the main architecture models: the monolith and its organization in layers, the client-server model that underlies almost everything, SOA and its central bus, microservices with their independent data, event-driven architecture, serverless, and the modular monolith as an intermediate stage. None is superior in the abstract; each one trades simplicity for capability in a different proportion. For Rutaverde, a gradual evolution is taking shape: tidying up RouteManager as a modular monolith and extracting only Tracking and Notifications. But a hypothesis is not a decision. To decide rigorously we need to know exactly how much load has to be handled, what availability is required, and what response times are acceptable. Those are the non-functional requirements, and learning to define them precisely is the goal of the next lesson.
