Software Architecture Decision Sheet
Pick the architecture at project start based on criteria, not trends. One page, three layers, one flowchart.
1. Three layers2. Styles compared3. Criteria
4. Flowchart5. Inside a service6. Principles7. AI apps8. Record it
1. First: these are three different decisions
Common confusion: SOLID is not an alternative to microservices. They live at different levels. You choose one deployment style, one internal structure, and you apply principles everywhere.
| Level | Question it answers | Options | Decided when | Cost to change later |
|---|---|---|---|---|
| A. Architectural style (system level) | How many deployable units? How do they talk? | Monolith · Modular monolith · Microservices · Serverless · Event-driven | Project start | High |
| B. Internal structure (codebase level) | How is code inside one unit organized? | Layered (N-tier) · Hexagonal (ports & adapters) · Clean / Onion · CQRS · Vertical slices | Project start, per service | Medium |
| C. Design principles (class / module level) | How do I write each piece so it stays changeable? | SOLID · DRY · KISS · YAGNI · Separation of concerns · High cohesion / low coupling | Always, every PR | Low (refactor) |
2. Architectural styles compared
| Criterion | Monolith | Modular monolith | Microservices | Serverless (FaaS) | Event-driven |
|---|---|---|---|---|---|
| What it is | One codebase, one deploy | One deploy, strict internal module boundaries | Many small services, each deployed and owning its data | Functions triggered by events, managed infra | Components react to events via a broker (Kafka, Service Bus) |
| Time to first release | Fastest | Fast | Slow | Fast | Medium |
| Team size fit | 1–8 devs | 3–30 devs | Several teams (20+) | Any, small apps | Medium–large |
| Independent deploy | No | No | Yes | Yes, per function | Yes |
| Independent scaling | Whole app | Whole app | Per service | Automatic | Per consumer |
| Ops / DevOps maturity needed | Low | Low | High (K8s, tracing, CI/CD per service) | Medium | High |
| Data consistency | Easy (one DB, ACID) | Easy | Hard (sagas, eventual) | Medium | Eventual |
| Debugging | Easy | Easy | Hard (distributed) | Medium | Hard |
| Latency | In-process calls | In-process | Network hops | Cold starts | Async by nature |
| Infra cost at small scale | Low | Low | High | Very low | Medium |
| Main risk | Becomes a "big ball of mud" | Boundaries erode without discipline | "Distributed monolith" | Vendor lock-in, timeouts | Hard to trace flows |
| Best when | MVP, PoC, unclear domain | Default for most new products | Clear domains, many teams, different scaling needs | Spiky / low traffic, glue jobs | Async workflows, integrations, audit trails |
Styles combine: e.g. a modular monolith + a few serverless functions + an event bus is very common.
3. Decision criteria — answer these first
| # | Criterion | Ask yourself | Points toward simpler (monolith) | Points toward distributed |
|---|---|---|---|---|
| 1 | Domain clarity | Do we know the business boundaries well? | New / changing domain | Stable, well-understood domains |
| 2 | Team structure | How many teams will work on it in parallel? (Conway's Law) | One team | Several autonomous teams |
| 3 | Scaling profile | Do parts need very different scale / hardware (e.g. GPU)? | Uniform load | One part 100× the others |
| 4 | Release cadence | Must parts ship independently? | Release together is fine | Different release cycles |
| 5 | Ops maturity | Do we have CI/CD, containers, monitoring, tracing, on-call? | Limited | Strong platform team |
| 6 | Consistency | Do transactions span many entities? | Strong ACID needed | Eventual consistency acceptable |
| 7 | Time-to-market | How fast must v1 ship? | Weeks | Months, long-lived platform |
| 8 | Budget | Infra + people cost limits? | Tight | Comfortable |
| 9 | Tech diversity | Need different languages / runtimes? | One stack | Python ML + Java core + Node UI, etc. |
| 10 | Compliance / isolation | Must some data or failures be isolated? | No | PII / payment / tenant isolation |
Rule of thumb: if 7+ answers are in the left column → monolith / modular monolith. Only go distributed when you can name the specific criteria (3, 4, 9, 10) that force it. "It's modern" is not a criterion.
4. Decision flowchart
flowchart TD
S([Start: new project]) --> Q1{Is it a PoC / MVP
or is the domain unclear?} Q1 -- Yes --> M1[Monolith
+ layered or hexagonal inside] Q1 -- No --> Q2{More than one team
working in parallel?} Q2 -- No --> Q3{Do parts need very different
scaling or hardware? e.g. GPU} Q3 -- No --> MM[Modular monolith
clear module boundaries] Q3 -- Yes --> HY[Modular monolith
+ extract only the hot part
as a separate service] Q2 -- Yes --> Q4{Strong DevOps?
CI/CD, containers, tracing, on-call} Q4 -- No --> MM2[Modular monolith first
build platform maturity] Q4 -- Yes --> Q5{Can each domain own its data
and accept eventual consistency?} Q5 -- No --> MM3[Modular monolith
shared DB, separate schemas] Q5 -- Yes --> MS[Microservices
one service per bounded context] M1 --> Q6{Mostly event-triggered,
spiky or low traffic tasks?} MM --> Q6 HY --> Q6 MS --> Q6 Q6 -- Yes --> SV[Add serverless functions
for those tasks] Q6 -- No --> Q7{Async workflows, integrations,
long-running jobs?} SV --> Q7 Q7 -- Yes --> EV[Add event bus / queue
event-driven between parts] Q7 -- No --> D([Pick internal structure: section 5
Apply principles: section 6
Write an ADR: section 8]) EV --> D MM2 --> D MM3 --> D
or is the domain unclear?} Q1 -- Yes --> M1[Monolith
+ layered or hexagonal inside] Q1 -- No --> Q2{More than one team
working in parallel?} Q2 -- No --> Q3{Do parts need very different
scaling or hardware? e.g. GPU} Q3 -- No --> MM[Modular monolith
clear module boundaries] Q3 -- Yes --> HY[Modular monolith
+ extract only the hot part
as a separate service] Q2 -- Yes --> Q4{Strong DevOps?
CI/CD, containers, tracing, on-call} Q4 -- No --> MM2[Modular monolith first
build platform maturity] Q4 -- Yes --> Q5{Can each domain own its data
and accept eventual consistency?} Q5 -- No --> MM3[Modular monolith
shared DB, separate schemas] Q5 -- Yes --> MS[Microservices
one service per bounded context] M1 --> Q6{Mostly event-triggered,
spiky or low traffic tasks?} MM --> Q6 HY --> Q6 MS --> Q6 Q6 -- Yes --> SV[Add serverless functions
for those tasks] Q6 -- No --> Q7{Async workflows, integrations,
long-running jobs?} SV --> Q7 Q7 -- Yes --> EV[Add event bus / queue
event-driven between parts] Q7 -- No --> D([Pick internal structure: section 5
Apply principles: section 6
Write an ADR: section 8]) EV --> D MM2 --> D MM3 --> D
5. Inside each deployable unit — internal structure
| Pattern | Idea | Use when | Avoid when |
|---|---|---|---|
| Layered (N-tier) | API → Service → Repository → DB | CRUD apps, small teams, simple logic | Complex business rules (logic leaks across layers) |
| Hexagonal (Ports & Adapters) | Core logic in the middle; DB, LLM, APIs plug in via interfaces | Many external integrations, need to swap providers (OpenAI ↔ Azure), testability | Tiny scripts / throwaway PoCs |
| Clean / Onion | Dependencies point inward to the domain | Long-lived, rich domain logic | Short projects — more boilerplate |
| CQRS | Separate read model and write model | Reads ≫ writes, different query shapes | Simple CRUD — doubles complexity |
| Vertical slices | Organize by feature, not by layer | Feature teams, fast iteration | Heavy shared domain rules |
6. Design principles — apply in any architecture
| Principle | Meaning (plain) | Smell when violated |
|---|---|---|
| SSingle Responsibility | A module has one reason to change (one actor/owner) | One class handles parsing, DB, and email |
| OOpen / Closed | Add behavior by extending, not editing existing code | Every new provider = edit a big if/elif |
| LLiskov Substitution | A subtype must work anywhere the parent works | Subclass throws "not supported" for a parent method |
| IInterface Segregation | Small, specific interfaces over one fat one | Classes implement methods they don't use |
| DDependency Inversion | Depend on abstractions; inject concrete ones | Business logic does OpenAI() directly |
| Separation of concerns | Keep UI, logic, data, infra apart | SQL inside API handlers |
| High cohesion / low coupling | Related things together; few links between modules | Change in one module breaks five others |
| DRY | One source of truth for each piece of knowledge | Same rule copied in 4 places |
| KISS / YAGNI | Simplest thing that works; don't build for imagined needs | Kafka + K8s for 50 users |
| 12-Factor | Config in env, stateless processes, logs as streams | Secrets in code, local file state |
7. Applied to AI / LLM projects (RAG, agents)
Start here
- Modular monolith (FastAPI)
- Hexagonal inside: ports for LLM, vector store, tools
- Background worker + queue for ingestion
Split out when…
- Ingestion / embedding load differs from query load
- Self-hosted model needs GPU scaling
- Eval pipeline runs on its own schedule
Don't
- One microservice per agent "because agents"
- Call the LLM SDK directly from route handlers
- Share one DB across "independent" services
8. Record the decision (ADR — 5 lines)
Title · Context (criteria answers from section 3) · Decision (style + internal structure) · Consequences (what gets easier / harder) · Revisit trigger (e.g. "2nd team joins" or "ingestion > 10× query load")Bottom line: start with a modular monolith with clean module boundaries and SOLID inside. It keeps you fast now, and good boundaries let you extract microservices later — when a real criterion forces it, not before.