Skip to content
AI360Xpert

Phase 10: High-Level Design Patterns

Explore the concepts of High-Level Design Patterns.

Microservices vs Monolith

Monolithic architecture packages an application's entire feature set into a single deployable unit, while microservices architecture splits that feature set into small, independently deployable services that communicate over the network. The choice between them shapes how a team builds, deploys, scales, and operates a system. 🧠 Mental model: A monolith is a Swiss Army knife - one tool does everything, but it's getting heavy. Microservices are a toolbox - each tool is specialized and replaceable, but now you need a bigger bag and a way to find the right tool.

Service Discovery

Service Discovery is how microservices find each other's network locations (IP addresses and ports) dynamically, without hardcoding them. Since cloud environments are ephemeral-instances spin up, crash, and scale down constantly-services need a real-time phonebook to know who to talk to. 🧠 Mental model: Think of it like DNS, but faster and specifically for internal microservices. When Service A wants to call Service B, it doesn't use a hardcoded IP. It asks the Service Registry, "Where does Service B live right now?"

API Gateway Pattern

An API gateway is a single entry point that sits in front of backend services and routes each incoming request to the right service while handling cross-cutting concerns. Service discovery is the mechanism that lets callers find the current network location of those services as instances start, stop, and move. 🧠 Mental model: The API gateway is a hotel concierge - all guests (clients) talk to one person, who routes them to the right service (restaurant, spa, room service). Service discovery is the hotel directory that tells the concierge which services are open today.

Strangler Fig Pattern

The Strangler Fig pattern is a migration strategy for incrementally replacing a legacy system (usually a monolith) with a new system (usually microservices). Instead of rewriting everything from scratch in a risky "big bang" release, you build a facade that intercepts calls to the legacy system and slowly route specific endpoints to the new microservices. 🧠 Mental model: The Strangler Fig is a tree that grows around an older, existing tree. Over time, the fig tree grows larger, taking over the sunlight and root space, until the old tree inside dies and rots away, leaving only the new tree standing.

CQRS (Command Query Responsibility Segregation)

CQRS stands for Command Query Responsibility Segregation. It is an architectural pattern that separates the data models and APIs used for reading data (Queries) from the models and APIs used for updating data (Commands). This allows you to scale and optimize read and write operations independently. 🧠 Mental model: Think of a busy restaurant. The chefs in the kitchen (Commands) are optimizing for taking raw ingredients and assembling them into meals as fast as possible. The waiters and menus (Queries) are optimized for quickly showing customers what is available. They use completely different tools and systems, even though they represent the same restaurant.

Event Sourcing

Instead of storing just the current state of data in a domain, Event Sourcing stores every change to that state as an append-only sequence of immutable events. The current state is derived by replaying these events from the beginning. 🧠 Mental model: Think of a bank account. Traditional databases store your current balance ($500). Event Sourcing stores every transaction you ever made (Deposit $1000, Withdraw $200, Withdraw $300). To find your balance, it adds up the history. The history is the source of truth.

Proxy & Reverse Proxy

Proxies act as intermediaries between clients and servers. A Forward Proxy (usually just called a Proxy) sits in front of clients and protects them from the internet. A Reverse Proxy sits in front of servers and protects them from the internet. 🧠 Mental model: Forward Proxy: A corporate personal assistant. You ask the assistant to go buy a coffee. The coffee shop only interacts with the assistant and doesn't know who you are. Reverse Proxy: A restaurant maitre d'. The customer asks for a table, and the maitre d' decides which waiter serves them. The customer doesn't know how many waiters exist in the back.