An interactive web-based C4 modelling tool built with React that allows architects to create, edit, and visualise C4 diagrams with full interactivity. Runs completely standalone in any browser - no server, no installation, no dependencies!
Ready to use immediately:
- Download
bac4-standalone.html - Double-click to open it in any browser
- Start creating C4 diagrams!
That's it! The ~477KB file contains everything you need and works entirely offline.
- Interactive Canvas: Drag-and-drop interface for adding and positioning elements
- Pan and Zoom: Navigate large diagrams easily with mouse controls
- Visual Distinction: Different colours and icons for each element type
- Connection Lines: Auto-routing relationship lines between elements
- Click-to-Edit: Click any element to edit its properties inline
- Level-Aware Toolbar: Shows only relevant element types for current C4 level
- Context Level: Shows systems, people, and external systems
- Container Level: Shows systems, containers, people, and external systems
- Component Level: Shows containers, components, and people
- Code Level: Shows components only
- Automatic level switching when adding elements to ensure visibility
- Level selector in header for manual navigation
- Add Elements: Toolbar shows context-appropriate buttons:
- 🟦 Software System
- 🟢 Container
- 🟨 Component
- 🟣 Person
- ⚪ External System
- Edit Properties: Name, description, technology, tags, position
- Create Relationships: Drag between elements to create connections
- Delete Elements: With confirmation dialogue (auto-removes orphaned relationships)
- Export Formats:
- JSON (full model data)
- Structurizr JSON (workspace format)
- PlantUML C4 syntax
- Mermaid C4 syntax
- Markdown documentation
- HTML standalone document
- PNG image
- SVG image
- Draw.io (.drawio) for diagrams.net
- Import: Load previously exported JSON models (BAC4 or Structurizr format)
- Local Storage Auto-save: Automatically saves every 30 seconds + on page close
Four intelligent layout algorithms:
- Hierarchical: Arranges elements in layers by type (best for C4 hierarchy)
- Grid: Organises elements in a uniform grid
- Circular: Arranges elements in a circle (best for showing connections)
- Force-Directed: Physics simulation to minimise overlap
- Arrow Direction: Left (←), Right (→), Both (↔), None (—)
- Line Style: Solid, Dashed, Dotted
- Description: Custom text for each relationship
- Technology/Protocol: Document communication methods (REST, gRPC, etc.)
- Node.js 18+
- npm or yarn
# Clone the repository
git clone <repository-url>
cd bac4-standalone
# Install dependencies
npm install
# Build the standalone HTML file
npm run build:standaloneThe standalone file bac4-standalone.html will be created in the root directory.
- Check Current Level: Look at the toolbar - it shows "Context Level", "Container Level", etc.
- Click Element Button: Choose from available element types (toolbar shows only relevant options)
- Element Appears: Added to canvas and level auto-switches if needed
- Position Element: Drag to desired location
- Hover Over Element: Connection handles appear on all sides
- Click and Drag: From one element's handle to another element
- Release: Relationship arrow appears with default description
- Edit Relationship: Click the arrow to modify description/technology
- Click Element: Right panel shows properties
- Edit Fields: Name, technology, description, tags
- Auto-save: Changes save automatically when you tab out
- Delete: Use delete button with confirmation
Manual:
- Drag elements to position them precisely
- Position info shows in the properties panel
Automatic:
- Click "Layout" in the header
- Choose algorithm:
- Hierarchical (recommended for C4)
- Grid (for uniform spacing)
- Circular (for relationship emphasis)
- Force-Directed (for organic layout)
- Click "Export" in header
- Choose Format:
- JSON (BAC4): Save your work to re-import later
- Structurizr JSON: Export to Structurizr workspace format
- PlantUML: Generate C4-PlantUML code
- Mermaid: Generate Mermaid C4 diagram syntax
- Markdown: Create documentation
- HTML: Standalone document with embedded model
- PNG: Raster image for presentations
- SVG: Vector image for scaling
- Draw.io: Open in diagrams.net for further editing
- File Downloads: Automatically with descriptive name
The C4 model has 4 abstraction levels. Use the dropdown in the header to switch:
| Level | Purpose | Shows |
|---|---|---|
| Context | System landscape | Systems, People, External Systems |
| Container | System decomposition | + Containers |
| Component | Container internals | Containers, Components, People |
| Code | Implementation detail | Components only |
Tip: The toolbar automatically shows only relevant element types for your current level!
| Action | Shortcut |
|---|---|
| Zoom in/out | Mouse Wheel |
| Pan view | Click + Drag Canvas |
| Select element | Click Element |
| Deselect all | Click Canvas |
| Move element | Drag Element |
| Create relationship | Drag from Connection Handle |
bac4-standalone/
├── bac4-standalone.html # ⭐ THE STANDALONE FILE (all you need!)
├── build-standalone.js # Build script to create standalone HTML
├── src/
│ ├── components/
│ │ ├── C4Node.jsx # Custom node rendering
│ │ ├── Header.jsx # Top navigation with export/import/layout
│ │ ├── Toolbar.jsx # Level-aware sidebar with element buttons
│ │ └── PropertiesPanel.jsx # Right sidebar for editing properties
│ ├── hooks/
│ │ └── useLocalStorage.js # Auto-save hook (30s interval)
│ ├── utils/
│ │ ├── exportUtils.js # 9 export formats (JSON, PlantUML, Mermaid, etc.)
│ │ ├── structurizrUtils.js # Structurizr JSON import/export
│ │ └── layoutUtils.js # 4 auto-layout algorithms
│ ├── store.js # Zustand state management
│ ├── App.jsx # Main application with React Flow
│ └── main.jsx # Entry point
├── package.json
├── vite.config.js
└── README.md
- React 19: Modern UI framework with concurrent features
- React Flow 12: Interactive node-based diagrams
- Zustand 4: Lightweight state management
- Tailwind CSS 3: Utility-first styling
- Lucide React: Beautiful icon set
- html-to-image: Canvas-to-image export
- file-saver: Client-side file downloads
- Vite 7: Lightning-fast build tool
{
"metadata": {
"name": "Project Name",
"version": "1.0",
"author": "Author Name"
},
"systems": [...],
"containers": [...],
"components": [...],
"people": [...],
"externalSystems": [...],
"relationships": [...]
}{
"id": "system-1234567890-abc123def",
"type": "system|container|component|person|externalSystem",
"name": "Element Name",
"description": "What this element does",
"technology": "Spring Boot, PostgreSQL",
"tags": ["backend", "core"],
"position": { "x": 350, "y": 200 }
}{
"id": "rel-1234567890-abc123def",
"from": "source-element-id",
"to": "target-element-id",
"description": "Makes API calls to",
"technology": "REST/HTTPS",
"arrowDirection": "right",
"lineStyle": "solid",
"animated": false
}Full model data that can be re-imported. Use this to save your work!
C4-PlantUML syntax compatible with PlantUML rendering tools:
@startuml
!include https://raw.githubusercontent.com/.../C4_Context.puml
Person(user, "User", "End user of system")
System(app, "Application", "Main application")
Rel(user, app, "Uses", "HTTPS")
@endumlMermaid C4 diagram syntax compatible with Mermaid rendering tools (GitHub, GitLab, Confluence):
C4Context
title System Context
Person(user, "User", "End user of system")
System(app, "Application", "Main application")
Rel(user, app, "Uses", "HTTPS")
Structured documentation with tables, suitable for wikis, GitHub, or README files.
Self-contained document with:
- Model metadata
- Element documentation
- Relationship tables
- Embedded PlantUML code
- JSON model dump
Visual exports of current canvas view (excludes controls and minimap).
Export to Structurizr workspace format for use with:
- Structurizr Lite/On-Premises
- Structurizr Cloud
- Other C4 tooling that supports the Structurizr format
Import also supports Structurizr workspace JSON files.
Export to Draw.io/diagrams.net format:
- Opens directly in Draw.io desktop or web app
- Full mxGraph XML format
- Preserves element positions and relationships
- C4-appropriate colors and styling
- Edit further with Draw.io's extensive tooling
- Compatible with VS Code Draw.io extension
| Feature | BAC4 Standalone | C4-PlantUML |
|---|---|---|
| Interactive Editing | ✅ Live editing | ❌ Text-based |
| Visual Drag & Drop | ✅ Full support | ❌ No |
| Real-time Preview | ✅ Immediate | |
| Export to PlantUML | ✅ Generates syntax | N/A (is PlantUML) |
| Export to Mermaid | ✅ Generates syntax | ❌ No |
| Export to Draw.io | ✅ Full support | ❌ No |
| Export to Structurizr | ✅ Workspace format | ❌ No |
| Import from JSON | ✅ BAC4 + Structurizr | ❌ No |
| Auto-layout | ✅ 4 algorithms | ✅ Built-in |
| Relationship Styling | ✅ Arrow + Line style | |
| Local Storage | ✅ Auto-save 30s | ❌ No persistence |
| Installation | ✅ None needed | |
| Learning Curve | 🟢 Low (visual) | 🟡 Medium (syntax) |
| Offline Usage | ✅ 100% offline | ✅ Offline |
- Context Diagrams: Keep to 5-9 systems maximum for clarity
- Container Diagrams: Focus on one system at a time
- Component Diagrams: Show major structural components, not every class
- Code Diagrams: Use sparingly, only for complex areas
- Use clear, business-focused names (not technical jargon)
- Include technology stack in the technology field, not the name
- Keep descriptions concise (1-2 sentences)
- Use consistent naming conventions across diagrams
- Always add meaningful descriptions ("sends email to", not just "uses")
- Specify protocols/technologies where relevant (REST, gRPC, etc.)
- Use animated lines to indicate asynchronous communication
- Export models as JSON regularly (use version in filename)
- Commit JSON files to your repository
- Include generated PlantUML/Markdown in commits
- Tag major diagram versions
- Use descriptive commit messages
Issue: Clicked the toolbar button, but nothing shows onthe canvas Solution: Check the level dropdown - you might be at the wrong C4 level. The app auto-switches levels now, but older sessions might need manual switching.
Issue: Can't drag, zoom, or click elements Solution:
- Refresh the page
- Check browser console (F12) for errors
- Clear local storage if data seems corrupted
Issue: Export button doesn't download the file Solution:
- Disable pop-up blocker
- Check browser download permissions
- Try a different export format
- Check the browser console for errors
Issue: Too many elements in the same spot Solution:
- Use auto-layout (Layout → Hierarchical)
- Manually drag elements apart
- Zoom out for a better overview
- Consider splitting into multiple diagrams
Issue: Slow rendering or lag Solution:
- Keep diagrams under 50 elements
- Split large models into multiple C4 levels
- Use level filtering (show only what's needed)
- Avoid excessive relationships
- Try simpler auto-layout (Grid instead of Force-Directed)
Issue: "Quota exceeded" error Solution:
- Export model as JSON first (backup!)
- Clear browser local storage
- Re-import the JSON
- Consider exporting more frequently
Since this is a standalone HTML file, you can distribute it by:
✅ Email: Attach the 450KB file ✅ USB Drive: Copy and share ✅ Cloud Storage: Dropbox, Google Drive, OneDrive ✅ Intranet: Upload to shared drive ✅ Version Control: Commit to repository ✅ Wiki: Link from internal documentation
Security Note: The file contains only HTML, CSS, and JavaScript. No server communication, no data transmission, 100% client-side.
Contributions welcome! To contribute:
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Build and test:
npm run build:standalone - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
MIT License - Feel free to use, modify, and distribute this tool for any purpose.
- Built with React Flow for diagram rendering
- Inspired by C4 Model by Simon Brown
- Icons from Lucide
- Styling with Tailwind CSS
For issues, questions, or suggestions:
- Open an issue on GitHub
- Check this README and documentation
- Review existing issues/PRs
Built for Software Architects who want visual, interactive C4 diagrams without the complexity of traditional diagramming tools.