System Design: Context, Containers, and Components
Decompose the system into containers and modules, define boundaries and responsibilities, and describe key runtime flows.
Introduction
With a style chosen, we shape the system: what the parts are, what each is responsible for, and how they work together at runtime. The design must be understandable, because an architecture nobody can explain cannot guide a team.
This lesson uses a layered set of views, from a high-level context down to components, plus sequence views for key scenarios.
Learning Objectives
- Decompose a system into modules or containers along sensible boundaries.
- Apply cohesion, coupling, and information-hiding principles.
- Draw context, container, and component diagrams that communicate clearly.
- Describe key runtime flows and cross-cutting concerns.
- Use AI to review a design for gaps and inconsistencies.
1. Principles of Decomposition
| Principle | Meaning |
|---|---|
| High cohesion | A module’s parts belong together and serve one purpose |
| Low coupling | Modules depend on each other as little as possible |
| Information hiding | Hide decisions likely to change behind a stable interface |
| Single responsibility | A module has one reason to change |
| Explicit dependencies | Dependencies are visible and directed, never circular |
A practical approach is to decompose by business capability or domain concept, not by technical layer. Capability-aligned modules change for business reasons together, and are easier to assign to teams and to extract later.
2. Find Boundaries Using the Domain
From the SRS glossary and requirements, identify the core concepts and their relationships. For SignalDesk:
- Workspace and Membership: tenants, users, roles.
- Ingestion: sources, import jobs, mapping, deduplication.
- Feedback: feedback items and their metadata.
- Themes and Evidence: themes, assignment of items, evidence links.
- Summaries: decision briefs assembled from themes and evidence.
- Search: retrieval across feedback and themes.
- Administration and Audit: exports, deletion, audit trail.
Ask for each boundary: Do these concepts change together? Do different roles own them? Do they have different scale or reliability needs? If a concept requires data from several modules in every operation, the boundary may be wrong.
3. Level 1: System Context
1
2
3
4
Product Manager --> +------------------+ --> Email delivery service
Support Lead --> | SignalDesk | --> Identity provider
Admin --> +------------------+
CSV files / forwarded email --> (feedback sources)
Show every external actor and system, with a label for the interaction. This matches the context diagram in the SRS; any difference is a problem to resolve.
4. Level 2: Containers
A container here is a separately runnable or deployable unit: an application, a worker, a database.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Browser
| HTTPS
v
+-----------------------+ +------------------------+
| Web application/API |<----->| Relational database |
| (modular monolith) | | (primary data store) |
+-----------+-----------+ +------------------------+
| enqueue jobs
v
+-----------------------+ +------------------------+
| Queue |------>| Background worker |
+-----------------------+ | (import, summaries) |
+-----------+------------+
|
+------------------+------------------+
v v v
Object storage Search index Email service
(uploaded files) (derived data) (external)
For each container record: responsibility, technology (when chosen), data owned, interfaces, scaling approach, and failure behavior. Technology labels are provisional until trade-offs are analyzed.
Note the search index is derived data: it can be rebuilt from the database. That choice simplifies recovery and makes the database the single source of truth.
5. Level 3: Components
Zoom into one container. For the web application, modules might be:
1
2
3
4
5
6
7
8
+----------------------- Web application -----------------------+
| API layer (controllers, authentication, authorization) |
| | | | | |
| Workspace Feedback Themes & Summaries |
| & Access & Ingestion Evidence |
| \ | | / |
| +------ Shared kernel (events, audit, errors) ------+|
+----------------------------------------------------------------+
Rules to enforce:
- Modules expose a small public interface; other modules may not reach into their internals or tables.
- Dependencies point in one direction: no cycles.
- Cross-module interaction occurs through interfaces or domain events.
These rules erode unless checked. Use automated dependency checks in the build so the architecture is enforced, not just drawn.
6. Runtime Views: Key Scenarios
Draw sequence views for the scenarios that exercise the most important drivers. Example: import of a CSV file.
1
2
3
4
5
6
7
8
9
10
11
12
User -> API: upload CSV
API -> Object storage: store file
API -> DB: create import job (status=queued)
API -> Queue: enqueue job id
API --> User: 202 Accepted, job id
Worker <- Queue: job id
Worker -> Object storage: read file
Worker -> DB: validate and insert items (in batches)
Worker -> DB: update job (imported, skipped, duplicates)
Worker -> Search index: index new items
User -> API: poll job status / receive notification
This design keeps slow work out of the request, which supports both the import reliability and responsiveness drivers. Annotate each flow with what happens on failure: if the worker crashes mid-import, the job is retried; inserts are idempotent so retries do not duplicate items.
7. Cross-Cutting Concerns
Decide these once and apply them consistently:
| Concern | Decision to make |
|---|---|
| Authentication and authorization | Where is identity verified; where are workspace and role checks enforced? |
| Tenancy isolation | How is every query scoped to a workspace? |
| Observability | Logging, metrics, tracing conventions, correlation identifiers |
| Configuration and secrets | How they are stored and rotated |
| Error handling | Common error format and retry semantics |
| Audit | What is recorded and where |
| Deployment | Environments, configuration, rollback |
Cross-cutting concerns decided late become inconsistent. Tenancy isolation in particular should be enforced centrally, not rely on every developer remembering a filter.
8. Use AI to Review a Design
AI is useful for walking a design against scenarios and finding gaps. Provide a textual description or a diagram in a text format such as Mermaid or PlantUML.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Act as a critical architecture reviewer.
Here are the quality scenarios and the design description:
[Paste top scenarios.]
[Paste containers, components, and flows.]
Tasks:
1. For each scenario, trace how the design satisfies it. State where
the design does not address it.
2. Identify single points of failure.
3. Identify inconsistent or circular dependencies.
4. Identify missing cross-cutting decisions.
5. List the three riskiest assumptions in this design.
Do not redesign. Cite the specific component or flow for each finding.
Verify each finding against your own design. AI may “find” problems based on misunderstanding, or flatter the design by assuming missing behavior.
9. Practical Exercise
For SignalDesk (or your own system):
- Draw the context, container, and component views. Use text-based diagrams (Mermaid or ASCII) so they live in version control.
- For each container, write a one-paragraph responsibility, owned data, and failure behavior.
- Write sequence views for the three scenarios that exercise your top drivers.
- Write down the module dependency rules and how you will enforce them.
- Record cross-cutting decisions in a table.
- Run the AI review and triage its findings.
Verification
You are ready to continue when:
- Every driver from Lesson 2 can be traced through at least one view.
- Module boundaries follow domain capabilities, with no circular dependencies.
- Each container has a stated responsibility and data ownership.
- Cross-cutting concerns have explicit decisions.
- The context view matches the SRS.
Key Takeaways
- Decompose by capability, aim for high cohesion and low coupling.
- Use several views; each answers a different question.
- Runtime views prove that the structure supports the key scenarios.
- Enforce boundaries with tooling, not good intentions.
What’s Next?
Data usually outlives code and constrains everything else. Next, we design the data architecture: storage choices, the data model, tenancy, retention, and consistency.