Module 02 · Lesson 2.5
Diagramming the Design
On this page
- What you will learn
- Why draw diagrams, and what Mermaid text is
- Context diagram for Tidewell: the system and its neighbours
- Component diagram for Tidewell: the parts inside
- Keeping diagrams matching your decisions
- Step-by-step workflow: draw and check your diagrams
- Using an AI assistant to draw and check diagrams
- Conclusion and your next step
- Reusable prompt
- Expected output
- Common errors and fixes
- Validation checklist
- Hands-on exercise
- Knowledge check
- Frequently asked questions
- References
A map of a city does not show every brick. It shows streets and landmarks, so a visitor can find the way. A software diagram does the same job. It shows the main parts of a system and how they connect, so everyone can talk about the same picture.
In this lesson you draw two simple diagrams for Tidewell Physiotherapy: a context diagram that shows the system and the people and services around it, and a component diagram that shows the parts inside. You write them as text, so they live in the repository, and you keep them matching your decision records.
What you will learn
- Explain what a context diagram and a component diagram show, and what each leaves out.
- Write both diagrams as Mermaid text that can be stored and reviewed in a repository.
- Check that every box and arrow in a diagram traces to an ADR, a requirement or a folder.
- Use an AI assistant to draft and review a diagram without letting it add parts that were never decided.
Before you start
- Completed Architecture Decision Records, or have decisions of your own to draw.
- Access to any capable AI assistant.
Why draw diagrams, and what Mermaid text is
Words are good at reasons. Pictures are good at structure. A decision record tells you why the system is one web application. A diagram shows you what is inside it and what sits outside. You need both, because people learn from each in a different way.
A client who is not technical can often read a simple picture faster than a page of text. An assistant can read the text form of a diagram, and it is far less likely to guess about the structure of your project when it can see one.
- Context diagram
- A picture of your system as a single box, with the people and other systems around it. It is like the front page of a map: the whole town as one dot, with the roads leading in.
- Component diagram
- A picture of the main parts inside your system and how they talk to each other. It is like a floor plan: rooms and doors, not furniture.
- Mermaid
- A way to describe a diagram as plain text. A tool then draws the picture from the text. Because the text is a file, you can store it, compare versions and review changes like code.
Pictures drawn by hand in a drawing tool go out of date quickly, because nobody wants to open the file. Text diagrams sit in the repository, in docs/architecture.md, and change in the same review as the code. Many code hosts and editors draw Mermaid text for you. Check your own tool's documentation to see whether it does.
The two diagrams in this lesson follow the first two levels of a popular approach called the C4 model, which describes software at four zoom levels. You do not need the whole approach. Two levels are plenty for a small project.
Context diagram for Tidewell: the system and its neighbours
Start with the context diagram. Draw your whole system as one box, then add every person and outside system that deals with it. Do not draw the insides yet. The question to answer is: who and what does this system talk to?
For Tidewell, the people are the patient, front-desk staff, a physiotherapist who views their day, and the practice manager. The outside systems are an email-sending service, chosen in Module 6, and the clinic's existing website, which links to the booking pages.
flowchart LR
patient(["Patient"])
frontdesk(["Front-desk staff"])
physio(["Physiotherapist"])
manager(["Practice manager"])
system["Tidewell booking system"]
email["Email-sending service (chosen in Module 6)"]
website["Clinic's existing website"]
patient -->|"books, moves and cancels"| system
frontdesk -->|"manages bookings for patients"| system
physio -->|"views their day"| system
manager -->|"uses the diary"| system
website -->|"links to the booking pages"| system
system -->|"sends emails"| emailContext diagram as Mermaid text. Checked with the Mermaid parser.
What each part does
flowchart LRstarts a diagram that reads from left to right.- Each line such as
patient(["Patient"])makes a box. The word before the bracket is a short name used in the arrows. The words in quotes are what people see. Rounded boxes are people. - Each arrow such as
patient -->|"books, moves and cancels"| systemdraws a line with a label. The label says what flows or what is done. - The email-sending service and the clinic's website are outside the system. They are drawn, but not built, by this project.
Component diagram for Tidewell: the parts inside
Now open the box. A component is a main part of the system with one clear job. ADR-001 says the system is one deployable web application, so the diagram draws one outer box. Inside it are the parts. Outside are the database and the email service.
flowchart TB
subgraph app["Tidewell booking system: one deployable web application"]
patientPages["Patient pages"]
staffPages["Staff pages (Module 6)"]
api["API route handlers"]
rules["Booking rules (src/features/bookings)"]
data["Data access (src/lib/db.ts)"]
emailAdapter["Email adapter (Module 6)"]
end
db[("PostgreSQL")]
emailService["Email-sending service"]
patientPages -->|"calls"| api
staffPages -->|"calls"| api
api -->|"asks"| rules
rules -->|"reads and writes through"| data
rules -->|"sends through"| emailAdapter
data -->|"SQL"| db
emailAdapter -->|"sends"| emailServiceComponent diagram as Mermaid text. Checked with the Mermaid parser.
What each part does
subgraph app[...] ... enddraws the outer box. Everything inside it is one deployable program, as ADR-001 says.- Patient pages and Staff pages are what people see in a browser. The staff pages arrive in Module 6.
- API route handlers are the entry points that receive requests and give back replies.
- Booking rules hold the business rules, such as the 24-hour notice period. They live in
src/features/bookings. - Data access is the one place that talks to the database, in
src/lib/db.ts. db[("PostgreSQL")]draws a database symbol outside the application box. ADR-002 says it is the system of record.- Email adapter is the part that will talk to an outside email service. It arrives in Module 6.
Trace every box to a decision
| Part in the diagram | Traces to | Reason it exists |
|---|---|---|
| One outer application box | ADR-001 | One deployable web application for pages and API. |
| PostgreSQL, drawn as the only store | ADR-002, D1, D3, D4 | One system of record with a database rule against double booking. |
| Patient pages and Staff pages | ADR-003, D2, FR-01, FR-02, FR-04 | Mobile-friendly web pages. No native app box. |
| Booking rules | FR-01 to FR-05, NFR-01 | Where the business rules live, away from the pages. |
| Data access | ADR-002 | A single place for database queries. |
| Email adapter and outside email service | Module 6 | Chosen later. Drawn so the gap is visible. |
Keeping diagrams matching your decisions
A wrong diagram is worse than none. People trust it. An assistant that reads an outdated diagram will build to it. So you treat a diagram as part of the design, and you check it against the records whenever either changes.
A drift example
Suppose a draft diagram has a box called 'Native phone app' that calls the API. ADR-003 says the patients use mobile-friendly web pages, with no native app. The diagram and the record disagree. One of them is wrong, and you must decide which.
Diagram check for docs/architecture.md
[ ] Every box traces to an ADR, a requirement or a folder.
[ ] No technology appears that no ADR chose.
[ ] Every ADR that names a part is drawn, and every drawn part has an ADR.
[ ] Arrows match the real calls: pages call the API, the API calls the rules.
[ ] Parts that arrive later are marked with the module that adds them.
[ ] The date or ADR numbers in the file match the latest accepted records.A diagram check written as a short list. Run it each time a diagram or a record changes.
The fix is usually one of two things. Remove the stray box, or write a new record that supersedes ADR-003 and then update the diagram. Never leave them disagreeing.
Step-by-step workflow: draw and check your diagrams
Step 1: List the people and outside systems
Take them from your stakeholder table and your decisions. Ask who uses the system, and what else it must talk to.
What you should see: A list of actors and external systems.
Step 2: Draw the context diagram
One box for the system, one for each actor and outside system, one labelled arrow for each connection.
What you should see: A context diagram with no insides.
Step 3: List the main parts inside
From your system-shape and technology decisions, list the parts with one clear job each. Aim for five to eight.
What you should see: A short component list.
Step 4: Draw the component diagram
Draw the outer box, the parts inside, and the stores and services outside. Mark parts that come later.
What you should see: A component diagram that matches the shape in your ADRs.
Step 5: Check it against the records
Use the diagram check. Trace every box to an ADR, a requirement or a folder.
What you should see: A diagram with no untraced box.
Step 6: Save, view and review
Save both diagrams in docs/architecture.md. Open them in a tool that draws Mermaid, and show them to the practice manager.
What you should see: Diagrams in the repository, confirmed by a person who knows the clinic.
- ADRs and drivers
What was decided
- Context diagram
System and neighbours
- Component diagram
Parts inside
- Trace check
Box to record
- Review
Owner or manager
- Saved in repo
docs/architecture.md
The records come first. The diagrams show them. The check closes the loop.
Using an AI assistant to draw and check diagrams
An assistant can write Mermaid text quickly and can compare a diagram with your records. It cannot see your project unless you give it the records. Always provide the ADRs and the folder layout as the source of truth.
| Task | Assistant's part | Your part |
|---|---|---|
| Draft a diagram | Turns your list of parts and decisions into Mermaid text. | Supplies the list, and removes any part that is not in it. |
| Check the syntax | Finds mistakes in the text that stop it drawing. | Opens it in a tool that draws Mermaid, to see the real result. |
| Compare with the ADRs | Lists boxes with no record, and records with no box. | Decides whether to fix the diagram or write a new record. |
| Explain the diagram | Describes it in plain words for a non-technical reader. | Checks the explanation says only what the diagram shows. |
Conclusion and your next step
A context diagram shows your system and its neighbours. A component diagram shows the parts inside. Write both as Mermaid text in the repository, trace every box to a decision, and update them together with your records. That finishes the architecture work for this module.
Your next step: draw both diagrams for your own capstone project and run the diagram check. Then move on to the module assignment, and continue to the next module, Project Scaffolding, where these decisions become a real repository.
For more help, try the Architecture Decision Record Draft prompt, or read Writing Architecture Decision Records (ADRs) with AI.
Reusable prompt
Diagram and decision consistency check
Drafts Mermaid text from your listed parts and then compares the diagram with your decision records, listing mismatches.
You are helping me draw and check architecture diagrams. Use only the parts and decisions I list. Do not add parts, technology or arrows that are not in my list.
Fictional clinic: Tidewell Physiotherapy.
Decisions:
- ADR-001: one deployable web application for pages and API.
- ADR-002: PostgreSQL is the system of record.
- ADR-003: mobile-friendly web pages instead of a native app.
Parts inside the application: Patient pages, Staff pages (added in Module 6), API route handlers, Booking rules (src/features/bookings), Data access (src/lib/db.ts), Email adapter (added in Module 6).
Outside the application: PostgreSQL, an email-sending service.
Tasks:
1. Write a Mermaid flowchart for the components, with one outer box for the application and labelled arrows.
2. List any box or arrow that does not trace to a decision or to my parts list.
3. List any decision that has no matching part in the diagram.
4. Explain the diagram in three sentences for a non-technical clinic owner.Show the reusable template
Replace each {{placeholder}} with your own details.
You are helping me draw and check architecture diagrams. Use only the parts and decisions I list. Do not add parts, technology or arrows that are not in my list.
Context: {{organisation_and_scope}}
Decisions:
{{adr_numbers_and_one_line_summaries}}
Parts inside the application: {{internal_parts}}
Outside the application: {{external_parts}}
Tasks:
1. Write a Mermaid flowchart for the components, with one outer box for the application and labelled arrows.
2. List any box or arrow that does not trace to a decision or to my parts list.
3. List any decision that has no matching part in the diagram.
4. Explain the diagram in three sentences for a non-technical reader.Expected output and limitations
A Mermaid flowchart that uses only your parts, a list of any untraceable boxes or arrows, a list of decisions with no matching part, and a short plain-language explanation.
flowchart TB
subgraph app["Tidewell booking system"]
patientPages["Patient pages"]
staffPages["Staff pages (Module 6)"]
api["API route handlers"]
rules["Booking rules"]
data["Data access"]
emailAdapter["Email adapter (Module 6)"]
end
db[("PostgreSQL")]
...
Untraceable: none.
Decisions with no part: ADR-003 has no box of its own; it shows in the page boxes.
Plain words: The clinic's booking system is one program. Patients and staff use web pages, which ask the program's rules to check each booking. The rules store everything in one database.Limitations to keep in mind
- The assistant may add a part such as a cache or an admin page. Check each box against your list.
- The text may not draw in your tool. Open it in a viewer that supports Mermaid before you trust it.
- Its plain-language explanation may sound more certain than the decisions are. Compare it with the ADRs.
Common errors and how to fix them
The context diagram shows databases and folders.
Why it happens: The insides were drawn before the outside was clear.
Fix: Keep the system as one box. Move the insides to the component diagram.
A diagram shows a part no decision record mentions.
Why it happens: An assistant added it, or an earlier idea was never removed.
Fix: Trace every box. Remove any untraced one, or write the record that justifies it first.
The diagram is a drawing outside the repository.
Why it happens: It was made in a drawing tool and never updated.
Fix: Keep Mermaid text in docs/architecture.md and change it in the same review as the related record.
Validation checklist
Tick each item once you have confirmed it.
Hands-on exercise
Diagrams for Ferngate Cycle Repairs
Write a context diagram and a component diagram, as Mermaid text, for Ferngate's parts and stock tool. Then run the diagram check against your ADRs and list any mismatch you found and how you fixed it.
You will need
- Your Ferngate ADRs for the system shape and the data store.
- Note: mechanics share one tablet, and the connection is often down.
- Note: the owner reorders every Friday by counting shelves, and the low-stock threshold is 'to be agreed'.
Acceptance criteria
Your work is done when every one of these is true.
Hints (2)
- Ask who else, besides the mechanics, might use the tool: the owner, for example.
- Ask what an assistant might add that no one chose, such as a customer app or supplier ordering.
Show a model answer
A strong answer draws the stock tool as one box, with the mechanic and the owner as people, and keeps any outside services separate. Its component diagram matches the system shape recorded in the ADR, for example one application box with pages, rules and data access inside and the data store outside. Each part has a note saying which ADR or requirement it comes from. The answer shows a check in which an assistant-added box, such as supplier ordering, was removed because no decision covers it. The low-stock threshold is not drawn, because it is still 'to be agreed'.
Knowledge check
Choose an answer, then check it. Nothing is recorded — this is for you.
Show the answer and explanation
Answer: B. A context diagram answers who and what the system talks to. Folders and tables are tempting to add because they feel more useful, but they belong in later diagrams. Mixing them in makes the first picture hard for a client to check.
Show the answer and explanation
Answer: B. A diagram that disagrees with a record is misleading, and people trust both. Calling it a sketch is tempting, but an assistant will build to it. Deleting the record erases the reasoning for a decision that may still be correct.
Show the answer and explanation
Answer: B. Text in the repository is versioned and visible to reviewers, so a change to a decision can carry its diagram update. Looks are not the reason, and Mermaid text can still be wrong or fail to draw, so you still check it in a viewer.
Frequently asked questions
What is a context diagram?
It is a simple picture that shows your system as one box and the people and other systems around it. It leaves out everything inside. It helps a client confirm who uses the system and what it connects to.
What is the difference between a context diagram and a component diagram?
A context diagram shows the system from outside, with its users and neighbours. A component diagram opens the box and shows the main parts inside and how they connect. You draw the context diagram first.
What is Mermaid and why use it for diagrams?
Mermaid is a way to describe a diagram in plain text, which a tool then draws. Because the diagram is text in a file, you can keep it in your repository and review changes to it like code. Check whether your editor or code host draws it.
Can an AI assistant draw my architecture diagram?
It can write the Mermaid text from a list of parts you provide, and it can compare the diagram with your decisions. It may add parts that you never chose, so check every box. Open the result in a viewer to confirm it draws.
- Written by
- PromptFable Editorial
- Last updated 19 Nov 2026
- Review
- Reviewed by Waseem Nadir, Technical Reviewer
- Last reviewed 27 Nov 2026
References
Primary sources for the technical details in this lesson. Vendor platforms change — check the official page if anything here looks different from what you see.
- Flowcharts Syntax(opens in a new tab)
Mermaid · Official documentation · The syntax for the flowchart text used in this lesson.
- C4 model(opens in a new tab)
c4model.com · A four-level approach to drawing software architecture. This lesson uses its first two levels in spirit.
- Architectural Decision Records (ADRs)(opens in a new tab)
adr.github.io · The records your diagrams must match.
PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.