KAHIBARO
Discord Login Register

25.9. Choosing an Architecture

Table of Contents

Big Picture: What “Architecture” Really Means

When people say “backend architecture,” they are talking about how you organize your code and services so that:

You have already seen different styles like monoliths, modular monoliths, microservices, layered architecture, service layer, repository pattern, and domain driven design basics. This chapter is about how to choose between these options for a real project.

Architecture is never “one size fits all.” It always depends on your project context.

Important rule: There is no “best architecture” in general. There is only “best architecture for this specific problem, with these constraints, at this time.”

In this chapter you will learn how to think about those constraints and turn them into a clear decision.

Key Criteria When Choosing an Architecture

The main dimensions to evaluate

When you choose an architecture, you are trading between several qualities:

QualityWhat it means in practice
SimplicityEasy to understand, develop, and debug
Development speedHow fast you can build and ship features
ScalabilityHow well the system handles more users and data
ReliabilityHow well the system handles failures
MaintainabilityHow easy it is to change code over time
TestabilityHow easy it is to write and run automated tests
PerformanceSpeed of responses and resource usage
Team fitFits team skills, size, and experience
Operational overheadHow much effort it takes to deploy, monitor, and operate in production
FlexibilityHow easily you can add new features or change existing ones
CostMoney and time required to build and run the system

You cannot maximize everything at once. For a small project, simplicity and speed usually win. For a big company with millions of users, scalability and reliability become more important.

Matching Architecture to Project Size and Complexity

A simple rule of thumb

You can often start with a rule like this:

Project size / complexityRecommended starting architecture
Small toy apps, prototypes, personal toolsSimple monolith, minimal layers
Small startup product, early MVPMonolith, light layering
Growing product, many features, multiple devsModular monolith with clear boundaries
Very large product, many independent teamsMicroservices or hybrid architecture

Heuristic: Start simple. Only move to more complex architectures when the pain of your current design is clearly higher than the cost of moving.

Example: Personal to-do list app

Best fit: Monolithic app with a simple layered structure. Microservices would only add complexity without benefit.

Example: Growing B2B SaaS with 10 developers

Best fit: Modular monolith at first, with clear modules like billing, projects, users. Maybe split out 1 or 2 services later if needed.

Example: Global marketplace with hundreds of developers

Best fit: Microservices or service oriented architecture, because team boundaries and scale dominate the decision.

When to Use a Monolithic Architecture

Characteristics of a monolith

A monolith is usually:

Monoliths are often the best starting point.

Advantages

Disadvantages

When a monolith is a good choice

Use a monolith when:

Example:

When to Use a Modular Monolith

What makes a monolith “modular”?

A modular monolith is still:

But inside, you enforce strong module boundaries. For example:

Each module has its own:

The rest of the app can only use these through public interfaces.

Advantages

Disadvantages

When a modular monolith is a good choice

Use a modular monolith when:

Example:

When to Use Microservices

What microservices really buy you

Microservices turn your system into:

Microservices give you:

But this comes with cost.

Costs of microservices

Rule: Do not choose microservices to fix bad code organization. Fix your design in a monolith first. Microservices amplify both good and bad design.

When microservices are a good choice

Use microservices when:

Example:

Incremental Migration: From Monolith to Microservices

Why incremental change matters

Most systems do not start as microservices. They evolve.

Common path:

  1. Simple monolith.
  2. Modular monolith with clearer boundaries.
  3. Selected modules extracted into microservices.

This migration should be gradual, not “big bang”.

Example migration path

Imagine your modular monolith has modules:

You notice that:

A reasonable plan:

  1. Keep the core as a modular monolith.
  2. Create a Notification Service microservice.
  3. Extract message sending logic into this service.
  4. Let the monolith call the service through HTTP or publish messages into a queue.

Over time, you might also extract billing into its own service if it needs special compliance or scaling.

Alignment with Teams and Organization

Conway’s Law

Conway’s Law says:

“Any organization that designs a system will produce a design whose structure is a copy of the organization’s communication structure.”

In practice:

Good alignment

Bad alignment

When choosing architecture, always ask:

Non-Functional Requirements and Architecture

Translating requirements into choices

Non functional requirements are things like:

These influence architecture heavily.

Examples of requirement driven choices

  1. High uptime and isolation
    • A payment subsystem must be very reliable and certified.
    • You may isolate it as a separate service with its own database and stricter controls.
  2. Read heavy analytics
    • You might add separate read models or even separate services dedicated to reporting, so that heavy analytics queries do not affect the main transactional database.
  3. Low latency realtime features
    • Chat or trading systems might use WebSockets and specialized services for state and messaging, instead of putting everything into the same REST API monolith.

Whenever you see a strong non functional requirement, ask:

Technology and Team Skills

Do not ignore what your team can actually do

The best theoretical architecture fails if:

Consider:

Choosing microservices with Kubernetes, advanced messaging, and complex observability for a 2 person team that just learned Docker is usually a bad idea.

Rule of thumb:

Choose the simplest architecture that your team can operate well, given the business needs.

Decision Framework: Simple Step-by-Step Process

A concrete checklist

When picking an architecture for a new backend project, you can follow a small process.

Step 1: Understand the context

Write down:

Example:

Step 2: Choose base style

Using the earlier table:

Step 3: Identify main domains

List core domains, for example:

Keep them as modules inside a monolith at first. Name them clearly in your project structure.

Step 4: Evaluate special cases

Ask:

These might be candidates for early extraction into separate services.

Step 5: Validate against constraints

Check:

If you are unsure, lean toward simpler.

Step 6: Reevaluate over time

Architecture is not a one time decision. Every few months:

Example Scenarios and Decisions

Scenario 1: Early stage SaaS

Decision:

Scenario 2: Growing product with 3 squads

Decision:

Scenario 3: Large marketplace

Decision:

How to Avoid Common Architecture Mistakes

Overengineering

Avoid by:

Underengineering

Avoid by:

Ignoring evolution

Avoid by:

Putting It All Together

Choosing an architecture is about matching:

You have tools:

For an absolute beginner backend developer, the most important habits are:

If you consistently choose the simplest architecture that satisfies your current needs, and you keep refactoring as your system grows, your architecture decisions will age well.

Views: 9

Comments

Please login to add a comment.

Don't have an account? Register now!