Skills101

AdvancedSoftware Engineering · Lesson 13 of 13 · Updated ·

Software Architecture Styles — Layered, Client-Server, MVC, Pipe-and-Filter, Event-Driven and Microservices

Design has two levels. Detailed design decides classes and functions — the SOLID principles and design patterns work here. Architecture decides the big parts of the system and how they communicate: is it one program or twenty? Does the browser talk to the database directly? Where do the business rules live? These decisions are the most expensive to change later, so they are made early and written down.

An architectural style is a named, proven shape for a whole system, the way a design pattern is a proven shape for a few classes. This lesson covers the styles that BCA, MCA and B.Tech syllabi and interviews ask about.

1. Layered (n-tier) architecture

The system is split into horizontal layers. Each layer offers services to the layer above and uses only the layer directly below it.

Layered architecture of a college portal: the presentation layer (web pages, mobile app) calls the business layer (fee rules, attendance rules), which calls the data access layer (SQL queries), which talks to the database; each layer only calls the one below

LayerJobCollege portal example
Presentationshow data, take inputweb pages, mobile app screens
Business (domain)rules and decisions"a student below 75% attendance cannot sit the exam"
Data accessread and write storageSQL queries, ORM code
Databasestore dataMySQL / PostgreSQL
  • Good: separation of concerns; each layer can be changed or tested alone (replace MySQL with PostgreSQL by changing only data access); easy for a team to understand.
  • Bad: a simple request passes through every layer; if layers are skipped "just this once", the structure decays.

Tier vs layer: layers are a logical split of code; tiers are physical machines. A 3-tier system runs presentation (browser), application server and database server on separate machines.

2. Client-server

Clients (browsers, apps) send requests; a server processes them and replies. The server holds the shared data and rules, so many clients see the same state. Web applications, email, and database systems themselves (a SQL client talking to a database server) all use it.

  • Thin client: almost all logic on the server (a classic server-rendered website).
  • Thick (fat) client: much logic on the client (a desktop app, or a large React single-page app).
  • The server is a single point of failure and a bottleneck unless it is replicated — this is where system design (load balancing, scaling) begins.

Peer-to-peer (P2P) is the alternative: every node is both client and server, as in BitTorrent file sharing.

3. Model-View-Controller (MVC)

MVC splits an interactive application into three roles:

PartResponsibility
Modelthe data and business rules (a Student with marks, the result rule)
Viewwhat the user sees (HTML page, screen); it only displays
Controllerreceives user input, calls the model, chooses the view

MVC request flow: the user sends a request to the controller, the controller asks the model for data, the model returns it, the controller passes it to the view, and the view renders the response for the user

A tiny MVC program for a results page:

# Model: data and rules, knows nothing about screens
class ResultModel:
    def __init__(self):
        self.marks = {'101': [78, 91, 85], '102': [35, 42, 30]}
    def result(self, roll):
        m = self.marks.get(roll)
        if m is None:
            return None
        avg = sum(m) / len(m)
        return {'roll': roll, 'avg': round(avg, 1), 'status': 'PASS' if min(m) >= 33 else 'FAIL'}

# View: only formats what it is given
def result_view(r):
    return f"Roll {r['roll']}: average {r['avg']} -> {r['status']}"

def not_found_view(roll):
    return f'No result for roll {roll}'

# Controller: input -> model -> view
def result_controller(model, roll):
    r = model.result(roll)
    return result_view(r) if r else not_found_view(roll)

model = ResultModel()
for roll in ['101', '102', '999']:
    print(result_controller(model, roll))
Roll 101: average 84.7 -> PASS
Roll 102: average 35.7 -> FAIL
No result for roll 999

To make an Android app for the same results, you write a new view; the model and its pass/fail rule are reused unchanged. Frameworks built on MVC or close variants include Spring MVC (Java), Django (Python, which calls it MTV — model, template, view) and Ruby on Rails. Mobile apps often use MVVM (Model-View-ViewModel), a variant suited to data binding.

4. Pipe-and-filter

Data flows through a chain of independent processing steps (filters) connected by pipes; each filter reads input, transforms it and passes it on. A Unix command line is the classic example:

cat results.csv | grep CSE | sort -t, -k3 -nr | head -5 — read, keep CSE rows, sort by marks, take the top 5.

Compilers (lexer → parser → optimiser → code generator) and data pipelines (extract → clean → transform → load) are pipe-and-filter systems. Good: filters are reusable and can be rearranged. Bad: poor for interactive systems, and every step may re-parse the data.

5. Event-driven architecture

Components communicate by publishing events ("OrderPlaced", "PaymentFailed") to an event bus or message broker (for example Kafka or RabbitMQ). Other components subscribe and react. The publisher does not know who listens — this is the Observer pattern at system scale.

  • Good: loose coupling; new features subscribe without changing the publisher (an "OrderPlaced" event can trigger the invoice, the SMS and the warehouse, each in its own service).
  • Bad: the flow is harder to follow and debug; events may arrive late or twice, so handlers must cope with that.

6. Monolith vs microservices

MonolithMicroservices
Structureone deployable applicationmany small services, each owning one business capability and its own data
Deployall at onceeach service independently
Scalingcopy the whole appscale only the busy service
Complexitylow at first, grows inside the codemoved to the network: service discovery, failures, monitoring
Good forsmall teams, new productslarge teams, parts that change or scale at different rates

Many successful products start as a well-layered monolith and split out services only when a clear need appears. Microservices with a small team often add more operational work than they save. (The System Design course covers gateways, queues and scaling in depth.)

7. Choosing a style

Real systems combine styles: a microservice is often internally layered; its web part is MVC; services talk through events; the whole thing is client-server from the user's point of view. Choose by quality attributes (the non-functional requirements from the SRS): performance, scalability, maintainability, availability, security. Record the decision and the reason in a short Architecture Decision Record (ADR) so future developers know why.

Common mistakes

  • Treating "layer" and "tier" as the same thing. Layers are logical; tiers are separate machines.
  • Putting business rules in the view or the controller. Rules belong in the model / business layer.
  • Saying microservices are always better. They trade code complexity for operational complexity.
  • Calling every system with a database "client-server" without saying what the client and server are.
  • Confusing MVC (structure of one interactive application) with layered architecture (structure of a whole system). They are often used together.

Quick recap

  • Architecture = main parts + how they communicate; costly to change, decided early.
  • Layered: each layer uses only the one below. Client-server: clients request, a server responds.
  • MVC: model (data + rules), view (display), controller (input → model → view).
  • Pipe-and-filter: chained transformation steps. Event-driven: publish and subscribe to events.
  • Monolith vs microservices is a trade-off; real systems mix styles, chosen by quality attributes.

Practice what you learned

📝 Quiz: Software Architecture Styles5 questions · instant answers & explanations · +10 XP · counts towards your free certificateTake the quiz →