Software Guidebook: remark-kroki-a11y
This Software Guidebook follows the structure defined by Simon Brown in his book Software Architecture for Developers. It provides a comprehensive overview of the remark-kroki-a11y plugin architecture.
1. Context
The remark-kroki-a11y plugin operates in the intersection of:
- Static Site Generators (Docusaurus, mdBook, etc.) that use the unified/remark ecosystem
- Diagram-as-Code tools (Kroki, PlantUML, Mermaid) that render diagrams from text
- Web Accessibility requirements (WCAG, European Accessibility Act) that mandate alternatives for visual content
For detailed context including stakeholders and external systems, see the README.
2. Functional Overview
The plugin provides the following core functionality:
Use Cases
Configuration Options
| Option | Use Case | Default |
|---|---|---|
showSource | Display source code tab for all diagrams | true |
hideA11y | Per-diagram flag to hide the natural language description | false |
locale | Set language for generated descriptions ('en' or 'nl') | 'en' |
a11yDescriptionOverride | Per-diagram manual description override | - |
Extended use cases: configuration options
3. Quality Attributes
The key quality attributes for this plugin are:
Accessibility (Primary)
- All diagrams must have alternative text descriptions
- Generated descriptions must be screen reader friendly
- UI components must be keyboard navigable
Determinism
- Descriptions are generated by parsers, not AI (see ADR-0000)
- Same input always produces same output
- No external API calls for description generation
Extensibility
- New diagram types can be added via new parsers
- Support for multiple diagram-as-code formats (PlantUML, Mermaid)
Performance
- No runtime API calls (build-time only)
- Minimal impact on build performance
4. Constraints
Technical Constraints
- Must work within the unified/remark ecosystem
- Must be compatible with Docusaurus (primary target)
- Browser support limited by native
<details>element support
Organizational Constraints
- Plugin used in educational context
- Student contributions welcome for new diagram parsers
External Constraints
- Depends on Kroki service for diagram rendering
- PlantUML/Mermaid syntax defines what can be parsed
5. Principles
Core Architectural Principles
-
Deterministic over AI-generated - Descriptions are generated by parsers that understand diagram syntax, not by LLMs (see ADR-0000)
-
PlantUML as Internal Representation - PlantUML data structures serve as the canonical format, with adapters for other formats (see ADR-0006)
-
Build-time processing - All work happens during static site generation, not at runtime
-
Progressive enhancement - Diagrams work without the plugin; plugin adds accessibility layer
Development Principles
- BDD Testing - Features defined in Gherkin, tested with Cucumber
- Single Source Documentation - README/CONTRIBUTING maintained in one place (see ADR-0007)
- Eating our own dog food - This documentation site uses the plugin to render its diagrams
6. Software Architecture
High-Level Architecture
The plugin operates as a remark plugin in the unified.js processing pipeline:
Markdown → remark-kroki-a11y → remark-kroki-plugin → rehype → HTML
↓
Parse diagram source
Generate description
Add tabs/details HTML
Processing Flow
7. Code
Source Code Structure
src/
├── index.js # Main plugin entry point
├── parsers/
│ ├── classDiagramParser.js # PlantUML/Mermaid class diagrams
│ ├── stateDiagramParser.js # PlantUML state diagrams
│ └── sequenceDiagramParser.js # Sequence diagram parsing
├── diagramTabs.js # Client-side tab switching
└── diagram-tabs.css # Styling for tabs UI
Parser Architecture
Each parser:
- Receives raw diagram source code
- Parses it into a structured representation
- Generates natural language description in the requested locale
For implementation details, see the source files on GitHub.
8. Containers
As a remark plugin, remark-kroki-a11y is an npm package that runs within the static site generator's build process. In a local development setup, the Docusaurus dev server runs on the host machine and communicates with a local Kroki service running in Docker containers.
The plugin interacts with:
- remark-kroki-plugin (peer dependency) - Handles Kroki API calls for diagram rendering
- rehype-raw (required) - Enables raw HTML in MDX output
- Kroki service - Can be local (Docker) or remote (kroki.io)
9. Components
10. Deployment
npm Package
The plugin is published to npm:
npm install remark-kroki-a11y
GitHub Pages
The documentation site is deployed automatically via GitHub Actions on push to main:
- Run tests
- Build Docusaurus site
- Deploy to GitHub Pages
See .github/workflows/ for pipeline configuration.
Local Development
# From repository root
./start-docs.sh
# Or manually
cd test-docusaurus-site
npm install
npm run start:strict # Recommended: validates broken links
11. Views and Perspectives
Diagram Type Support Matrix
| Diagram Type | PlantUML | Mermaid | A11y Status |
|---|---|---|---|
| Class diagrams | ✅ Full | ⚠️ To test | Partial |
| State diagrams | ✅ Full | ❌ | Partial |
| Sequence diagrams | ⚠️ Beta | ⚠️ Beta | Partial |
| Activity diagrams | ⚠️ Beta | ❌ | Partial |
| C4 diagrams | ⚠️ Beta | N/A | Partial |
Accessibility Compliance
The plugin contributes to WCAG 2.1 compliance:
- 1.1.1 Non-text Content (A) - Provides text alternatives for diagrams
- 2.1.1 Keyboard (A) - Tab/details UI is keyboard accessible
- 4.1.2 Name, Role, Value (A) - Proper ARIA attributes on diagram images
12. Decisions
Architecture decisions are recorded as ADRs (Architecture Decision Records):
| ADR | Title | Status |
|---|---|---|
| ADR-0000 | Deterministic Parsing vs Live LLM | Accepted |
| ADR-0001 | Ondersteuning relatie richtingen | Accepted |
| ADR-0002 | Plugin architectuur | Accepted |
| ADR-0003 | Project language | Accepted |
| ADR-0004 | Integrated test Docusaurus site | Accepted |
| ADR-0005 | Navigeerbare A11y beschrijvingen | Accepted |
| ADR-0006 | PlantUML als interne standaard | Accepted |
| ADR-0007 | Single source documentation | Accepted |
| ADR-0012 | Integrate remark-kroki-plugin | Accepted |
| ADR-0013 | i18n framework | Accepted |
For the complete list, see the ADR index.
This Software Guidebook follows the structure from Simon Brown's book "Software Architecture for Developers".