Architecture Document Generator
Produce a single .docx document answering "what does this system look like
and how is it put together" — components, technology choices, code
organization, data flow, and integration points. This is the structural view;
design rationale and decision trade-offs belong in the companion
high-level-design skill, and API/database specifics belong in
api-documentation / database-design.
Sections (in this order)
Cover page, Version History, Document Approval, Revision Log, and TOC are
automatic — your sections array starts at "1. Solution Overview".
| # |
Section |
Content |
Diagram? |
| 1 |
Solution Overview |
How the system addresses the business need, conceptually |
Context Diagram — system boundary, external actors, upstream/downstream systems |
| 2 |
Overall System Architecture |
Narrative walkthrough of all major components |
System Architecture Diagram |
| 3 |
Technology Stack |
Table: Layer, Technology, Version, Notes |
|
| 4 |
Repository Structure |
Table: Repository, Purpose, Link, Primary Language |
|
| 5 |
Folder Structure |
Top-level directory layout with one-line purpose per folder |
|
| 6 |
Module Overview |
Table: Module, Purpose, Owner, Repository |
|
| 7 |
Package Structure |
How code is organized into packages/namespaces and dependency direction |
Package Diagram |
| 8 |
High-Level Data Flow |
Narrative: how data enters, moves through, and exits the system |
High-Level Data Flow Diagram |
| 9 |
External Integrations Overview |
Table: System, Type, Direction, Purpose (high-level only — detailed contracts live in the API Documentation skill) |
Integration Diagram |
| 10 |
Caching Strategy |
What's cached, where, invalidation approach |
|
| 11 |
Queue/Event Design |
Topics/queues, producers, consumers, delivery guarantees |
Queue/Event Flow Diagram |
| 12 |
Security Architecture |
High-level AuthN/AuthZ approach, data protection, compliance posture (operational secrets handling lives in Operations & Deployment Guide) |
|
| 13 |
Known Architectural Limitations |
Bullet list: what the current architecture doesn't handle well, and why |
|
| 14 |
Appendix |
ADR links, related documents |
|
Diagram Policy
Applies to the .docx path only — Markdown embeds Mermaid source
directly instead of rendering anything (see "Output Format" below).
Prefer a real Mermaid diagram — rendered via mmdc and embedded with
B.diagramImage() — over diagramPlaceholder(), but only once you have
concrete structure to draw (real names, not "TBD"). Read
references/diagram-generation.md when you're actually about to render one
— it has the full build order, the bundled config
(assets/mermaid-config.json), the exact mmdc flags, and token-saving
tips. Skip it entirely if this document ends up needing no diagrams.
Missing Information Policy
Never invent components, technologies, or integrations you have no basis
for. Use toBeCompleted("...") for sections you lack real input for,
explaining what's needed, and still generate the rest of the document. If a
real codebase is available, inspecting it directly (folder layout, package
manifests, config files) produces far better output than asking the user to
recall it from memory — prefer that when possible.
Output Format
Ask the user which output format they want, unless they've already said so in
this request (e.g., "as a docx", "in markdown," "just give me an .md file") —
a quick single-choice question is enough, don't block on it otherwise:
Word document (.docx) — the default assumption if the person hasn't
specified and their context suggests a formal deliverable. Follow "Using
the builder" below.
Markdown (.md) — no script needed, write the file directly. Use these
conventions so it stays structurally equivalent to the docx version:
Front matter: instead of a cover page, open with the title as an #
heading, the project name as an italic subtitle line, then a metadata
table instead of separate Version History / Approval / Revision Log
tables:
# Architecture Document
*Acme Order Platform*
| Field | Value |
|---|---|
| Version | 0.1 |
| Author | Jane Doe |
| Date | 2026-07-19 |
| Status | Draft |
| Approved By | Jane Doe (Tech Lead) |
Headings: #/##/###/#### matching the same section levels used in
the table above — don't flatten everything to one level, that's what
keeps the document skimmable and consistent with the docx version.
Tables: standard Markdown tables.
Diagrams — unlike the .docx path, don't render or embed an image here.
Write the actual Mermaid source directly in a fenced code block; GitHub,
GitLab, Obsidian, and most modern Markdown viewers render mermaid code
blocks natively, so this is a real diagram, not a placeholder:
```mermaid
flowchart TD
A[Client] --> B[API Gateway]
B --> C[Order Service]
C --> D[(Database)]
```
Only fall back to a text placeholder if you don't yet have concrete
enough detail to draw something real (mirrors toBeCompleted above):
> 📊 **DIAGRAM PLACEHOLDER — TO BE COMPLETED**
> Not enough detail yet to draw the System Architecture Diagram — need
> the actual component names and how they connect.
"To be completed" callout — same blockquote treatment:
> ⚠️ **TO BE COMPLETED**
> Explanation of what input is needed to fill this in.
Save as Architecture_Document.md instead of Architecture_Document.docx.
Workflow
Ask the output format first (see "Output Format" above). For Markdown, skip straight to writing the file using those conventions — the numbered steps below describe the .docx path.
- Gather what's available — ideally a codebase to inspect directly, otherwise
ask for tech stack, repo structure, and integration list.
- Draft each section as data using the builder functions below.
- Build with
scripts/docx_builder.js.
- Skip PDF conversion by default —
docx_builder.js is already tested and
hardened (table widths and text alignment are enforced at the library
level), so routine generations don't need a re-render just to confirm it
worked. Only convert to PDF and view it if the user explicitly asks for
visual verification, or if something about this generation is unusual
(e.g., a new kind of content the library hasn't handled before, or a
reported rendering problem). When you do need it: soffice --headless --convert-to pdf <file>.docx (or libreoffice --headless ...), then
pdftoppm -jpeg -r 100 <file>.pdf page and view the images.
- Save to
/mnt/user-data/outputs/Architecture_Document.docx (or .md if that's the chosen format) and present it.
Using the builder (for the .docx path)
This library requires the docx npm package. Before running any script,
check it's available with node -e "require('docx')"; if that fails, install
it with npm install docx in the working directory first — don't assume it's
pre-installed, since that varies by environment.
// Before running this script: render the diagram with mmdc, e.g.
// mmdc -i context.mmd -o context.png -t neutral -e png -w 1600 -H 900 \
// -s 2 -b white -p puppeteer-config.json
// (see "Diagram Policy" above for the full mmdc workflow and required flags)
const B = require("./scripts/docx_builder.js");
const sections = [
B.h1("1. Solution Overview"),
B.para("The platform exposes a public API consumed by the mobile app and web frontend ..."),
...B.diagramImage("./context.png", { caption: "Figure 1: System context — external actors and boundaries." }),
// Fallback if mmdc isn't available or the diagram isn't concrete enough yet:
// B.diagramPlaceholder({ name: "Context Diagram", purpose: "...", recommendedContent: [...] }),
B.h1("3. Technology Stack"),
B.table(["Layer", "Technology", "Version", "Notes"],
[["Backend", "Node.js", "20.x", "Fastify framework"]],
[2000, 3400, 1400, 2200]),
B.h1("7. Package Structure"),
B.toBeCompleted("Package/namespace layout wasn't provided — inspect the codebase's src/ directory or ask for the module dependency map."),
];
await B.buildDocument("/mnt/user-data/outputs/Architecture_Document.docx", {
docLabel: "Architecture Document",
title: "Architecture Document",
subtitle: "Acme Order Platform",
versionHistory: [["0.1", "2026-07-19", "Jane Doe", "Initial draft"]],
approvers: [["Jane Doe", "Tech Lead", "", ""]],
revisionLog: [],
sections,
});
Available functions: h1/h2/h3/h4, para, bullets, table(headers, rows, widths), pageBreak, toBeCompleted(explanation),
diagramPlaceholder({name, purpose, recommendedContent, notes}), and
buildDocument(path, options). Always use heading functions for titles so
Word's Table of Contents and Navigation Pane work correctly.
Success Criteria
A developer joining the project should be able to read this document and
understand the system's structure, technology choices, and how data and
requests move through it — well enough to know where to look in the codebase
for any given concern.
1---2name: architecture-document3description: Generate a professional Architecture Document as a formatted Word (.docx) file — solution overview, system architecture, technology stack, repository/module structure, data flow, integrations, caching, and messaging design. Use this whenever someone asks for an "architecture document," "system design doc," "solution architecture," or wants to document how a system's components fit together (as distinct from business context or database/API detail, which have their own companion skills). Part of an enterprise handover documentation suite (see also: project-overview-doc, high-level-design, operations-deployment-guide, support-runbook, api-documentation, database-design, release-maintenance-guide) but fully usable standalone.4---56# Architecture Document Generator78Produce a single `.docx` document answering "what does this system look like9and how is it put together" — components, technology choices, code10organization, data flow, and integration points. This is the structural view;11design *rationale* and decision trade-offs belong in the companion12`high-level-design` skill, and API/database specifics belong in13`api-documentation` / `database-design`.1415## Sections (in this order)1617Cover page, Version History, Document Approval, Revision Log, and TOC are18automatic — your `sections` array starts at "1. Solution Overview".1920| # | Section | Content | Diagram? |21|---|---|---|---|22| 1 | Solution Overview | How the system addresses the business need, conceptually | **Context Diagram** — system boundary, external actors, upstream/downstream systems |23| 2 | Overall System Architecture | Narrative walkthrough of all major components | **System Architecture Diagram** |24| 3 | Technology Stack | Table: Layer, Technology, Version, Notes | |25| 4 | Repository Structure | Table: Repository, Purpose, Link, Primary Language | |26| 5 | Folder Structure | Top-level directory layout with one-line purpose per folder | |27| 6 | Module Overview | Table: Module, Purpose, Owner, Repository | |28| 7 | Package Structure | How code is organized into packages/namespaces and dependency direction | **Package Diagram** |29| 8 | High-Level Data Flow | Narrative: how data enters, moves through, and exits the system | **High-Level Data Flow Diagram** |30| 9 | External Integrations Overview | Table: System, Type, Direction, Purpose (high-level only — detailed contracts live in the API Documentation skill) | **Integration Diagram** |31| 10 | Caching Strategy | What's cached, where, invalidation approach | |32| 11 | Queue/Event Design | Topics/queues, producers, consumers, delivery guarantees | **Queue/Event Flow Diagram** |33| 12 | Security Architecture | High-level AuthN/AuthZ approach, data protection, compliance posture (operational secrets handling lives in Operations & Deployment Guide) | |34| 13 | Known Architectural Limitations | Bullet list: what the current architecture doesn't handle well, and why | |35| 14 | Appendix | ADR links, related documents | |3637## Diagram Policy3839**Applies to the `.docx` path only** — Markdown embeds Mermaid source40directly instead of rendering anything (see "Output Format" below).4142Prefer a real Mermaid diagram — rendered via `mmdc` and embedded with43`B.diagramImage()` — over `diagramPlaceholder()`, but only once you have44concrete structure to draw (real names, not "TBD"). Read45`references/diagram-generation.md` when you're actually about to render one46— it has the full build order, the bundled config47(`assets/mermaid-config.json`), the exact `mmdc` flags, and token-saving48tips. Skip it entirely if this document ends up needing no diagrams.4950## Missing Information Policy5152Never invent components, technologies, or integrations you have no basis53for. Use `toBeCompleted("...")` for sections you lack real input for,54explaining what's needed, and still generate the rest of the document. If a55real codebase is available, inspecting it directly (folder layout, package56manifests, config files) produces far better output than asking the user to57recall it from memory — prefer that when possible.5859## Output Format6061Ask the user which output format they want, unless they've already said so in62this request (e.g., "as a docx", "in markdown," "just give me an .md file") —63a quick single-choice question is enough, don't block on it otherwise:6465- **Word document (.docx)** — the default assumption if the person hasn't66 specified and their context suggests a formal deliverable. Follow "Using67 the builder" below.68- **Markdown (.md)** — no script needed, write the file directly. Use these69 conventions so it stays structurally equivalent to the docx version:7071 - Front matter: instead of a cover page, open with the title as an `#`72 heading, the project name as an italic subtitle line, then a metadata73 table instead of separate Version History / Approval / Revision Log74 tables:7576 ```markdown77 # Architecture Document78 *Acme Order Platform*7980 | Field | Value |81 |---|---|82 | Version | 0.1 |83 | Author | Jane Doe |84 | Date | 2026-07-19 |85 | Status | Draft |86 | Approved By | Jane Doe (Tech Lead) |87 ```88 - Headings: `#`/`##`/`###`/`####` matching the same section levels used in89 the table above — don't flatten everything to one level, that's what90 keeps the document skimmable and consistent with the docx version.91 - Tables: standard Markdown tables.92 - Diagrams — unlike the `.docx` path, don't render or embed an image here.93 Write the actual Mermaid source directly in a fenced code block; GitHub,94 GitLab, Obsidian, and most modern Markdown viewers render `mermaid` code95 blocks natively, so this is a real diagram, not a placeholder:9697 ````markdown98 ```mermaid99 flowchart TD100 A[Client] --> B[API Gateway]101 B --> C[Order Service]102 C --> D[(Database)]103 ```104 ````105 Only fall back to a text placeholder if you don't yet have concrete106 enough detail to draw something real (mirrors `toBeCompleted` above):107 ```markdown108 > 📊 **DIAGRAM PLACEHOLDER — TO BE COMPLETED**109 > Not enough detail yet to draw the System Architecture Diagram — need110 > the actual component names and how they connect.111 ```112 - "To be completed" callout — same blockquote treatment:113114 ```markdown115 > ⚠️ **TO BE COMPLETED**116 > Explanation of what input is needed to fill this in.117 ```118 - Save as `Architecture_Document.md` instead of `Architecture_Document.docx`.119120## Workflow121122Ask the output format first (see "Output Format" above). For Markdown, skip straight to writing the file using those conventions — the numbered steps below describe the `.docx` path.1231241. Gather what's available — ideally a codebase to inspect directly, otherwise125 ask for tech stack, repo structure, and integration list.1262. Draft each section as data using the builder functions below.1273. Build with `scripts/docx_builder.js`.1284. Skip PDF conversion by default — `docx_builder.js` is already tested and129 hardened (table widths and text alignment are enforced at the library130 level), so routine generations don't need a re-render just to confirm it131 worked. Only convert to PDF and view it if the user explicitly asks for132 visual verification, or if something about this generation is unusual133 (e.g., a new kind of content the library hasn't handled before, or a134 reported rendering problem). When you do need it: `soffice --headless135 --convert-to pdf <file>.docx` (or `libreoffice --headless ...`), then136 `pdftoppm -jpeg -r 100 <file>.pdf page` and view the images.1375. Save to `/mnt/user-data/outputs/Architecture_Document.docx` (or `.md` if that's the chosen format) and present it.138139## Using the builder (for the .docx path)140141This library requires the `docx` npm package. Before running any script,142check it's available with `node -e "require('docx')"`; if that fails, install143it with `npm install docx` in the working directory first — don't assume it's144pre-installed, since that varies by environment.145146```javascript147// Before running this script: render the diagram with mmdc, e.g.148// mmdc -i context.mmd -o context.png -t neutral -e png -w 1600 -H 900 \149// -s 2 -b white -p puppeteer-config.json150// (see "Diagram Policy" above for the full mmdc workflow and required flags)151152const B = require("./scripts/docx_builder.js");153154const sections = [155 B.h1("1. Solution Overview"),156 B.para("The platform exposes a public API consumed by the mobile app and web frontend ..."),157 ...B.diagramImage("./context.png", { caption: "Figure 1: System context — external actors and boundaries." }),158 // Fallback if mmdc isn't available or the diagram isn't concrete enough yet:159 // B.diagramPlaceholder({ name: "Context Diagram", purpose: "...", recommendedContent: [...] }),160161 B.h1("3. Technology Stack"),162 B.table(["Layer", "Technology", "Version", "Notes"],163 [["Backend", "Node.js", "20.x", "Fastify framework"]],164 [2000, 3400, 1400, 2200]),165166 B.h1("7. Package Structure"),167 B.toBeCompleted("Package/namespace layout wasn't provided — inspect the codebase's src/ directory or ask for the module dependency map."),168];169170await B.buildDocument("/mnt/user-data/outputs/Architecture_Document.docx", {171 docLabel: "Architecture Document",172 title: "Architecture Document",173 subtitle: "Acme Order Platform",174 versionHistory: [["0.1", "2026-07-19", "Jane Doe", "Initial draft"]],175 approvers: [["Jane Doe", "Tech Lead", "", ""]],176 revisionLog: [],177 sections,178});179```180181Available functions: `h1`/`h2`/`h3`/`h4`, `para`, `bullets`, `table(headers,182rows, widths)`, `pageBreak`, `toBeCompleted(explanation)`,183`diagramPlaceholder({name, purpose, recommendedContent, notes})`, and184`buildDocument(path, options)`. Always use heading functions for titles so185Word's Table of Contents and Navigation Pane work correctly.186187## Success Criteria188189A developer joining the project should be able to read this document and190understand the system's structure, technology choices, and how data and191requests move through it — well enough to know where to look in the codebase192for any given concern.