Software Engineering Principles and Practices / Software Design

Architectural Designs

Software Architecture is the set of principal design decisions about a system. It defines the "style" of the house before you start picking out the furniture.


🏠 Common Architectural Styles

Different types of software require different architectures. Here are the most common patterns used in the industry:

1. Layered (N-Tier) Architecture

The most common architecture for business applications. It organizes the system into layers, where each layer has a specific responsibility and only communicates with the layer directly below it.

  • Presentation Layer: The UI (User Interface).

  • Business Layer: The logic and rules.

  • Data Access Layer: How we talk to the database.

2. Client-Server Architecture

The foundation of the Internet. The system is divided into Clients (who request services) and Servers (who provide them).

  • Example: Your web browser (Client) requesting a page from Google's servers.

3. Microservices Architecture

Instead of one giant application (a Monolith), the system is broken into small, independent services that communicate over a network.

  • Pros: Each service can be written in a different language and scaled independently.

  • Example: Netflix uses thousands of microservices (one for "Recommendations," one for "Billing," one for "Video Streaming").

4. Model-View-Controller (MVC)

A pattern used to separate the representation of information from the user's interaction with it.

  • Model: Manages the data and logic.

  • View: Displays the data (The UI).

  • Controller: Connects the two, handling user input.


🧩 Key Architectural Decisions

When designing the architecture, engineers must consider Non-Functional Requirements (Quality Attributes):

  • Performance: Should we use a "Pipe-and-Filter" architecture for high-speed data processing?

  • Security: Should we put the database in a private layer that is inaccessible to the public?

  • Availability: Do we need redundant servers to ensure the site never goes down?

  • Maintainability: Is the system modular enough that we can swap out a component easily?


⚖️ Monolith vs. Microservices: The Choice

Feature

Monolithic

Microservices

Complexity

Simple to develop and deploy initially.

Highly complex to manage and coordinate.

Scaling

Must scale the entire app.

Can scale only the service that is busy.

Fault Tolerance

If the app crashes, everything goes down.

If one service fails, others keep working.

Best For

Small teams and new startups.

Large, complex systems with many teams.


🔍 Why does Architecture matter?

You cannot "fix" a bad architecture with good code. If you build a skyscraper on a foundation meant for a shed, it will eventually collapse.

  1. Enables Communication: Stakeholders can understand the system without looking at code.

  2. Facilitates Reuse: You can reuse architectural patterns across different projects.

  3. Risk Management: It identifies potential bottlenecks (e.g., "The database will be a single point of failure").