This guide explains how to maintain and update the architectural diagram in the README.md.
The architecture diagram is located in README.md under the "🏗️ Architecture" section. It uses Mermaid syntax, which GitHub renders automatically.
Update the diagram when:
- Adding new components: New services, handlers, or modules
- Changing data flows: Modified communication patterns or APIs
- Adding integrations: New external services or APIs
- Removing components: Deprecated or removed functionality
- Major refactoring: Significant architectural changes
The diagram is organized into logical layers:
- Web UI (browser-based interface)
- Mobile App (future planned feature)
- FastAPI Server (main API)
- MQTT Event Handler (real-time event processing)
- Icon Service (image management for Yoto Mini displays)
- Audio Manager (upload, conversion, streaming)
- Script Engine (CYOA interactive logic)
- Card Manager (MYO card management)
- Database (SQLite/PostgreSQL for metadata)
- File Storage (audio files and icons)
- Yoto REST API (yoto.dev)
- Yoto MQTT Broker (mqtt.yoto.io)
- Physical Yoto Players and Yoto Mini devices
The diagram uses Mermaid's graph TB (top-bottom) syntax. Basic structure:
graph TB
Node1[Label]
Node2[Label]
Node1 --> Node2
To add a new component:
- Decide which subgraph it belongs to
- Add the node definition with a descriptive label
- Add connections to/from related components
- Optionally add a style for visual distinction
Example:
subgraph "Application Layer"
NewService[New Service<br/>Description]
end
API --> NewService
NewService --> DB
Connection types:
-->: Solid arrow (direct connection)-.->: Dashed arrow (future/optional connection)<-->: Bidirectional (two-way communication)-->|Label|: Arrow with label
Example:
API -->|REST Calls| YotoAPI
MQTT_Handler <-->|Real-time Events| YotoMQTT
Colors are defined at the bottom using the style keyword:
style NodeName fill:#e1f5ff
Current color scheme:
- Client Layer:
#e1f5ff(light blue) - Application Layer:
#fff3e0(light orange) - External Services:
#f3e5f5(light purple) - Yoto Devices:
#e8f5e9(light green) - Data Layer:
#fce4ec(light pink)
Use one of these tools to preview Mermaid diagrams locally:
- VS Code: Install the "Markdown Preview Mermaid Support" extension
- Online Editor: Mermaid Live Editor
- CLI Tool: Install
@mermaid-js/mermaid-cli
GitHub automatically renders Mermaid diagrams in markdown files. Check the preview after committing:
- Commit and push changes
- View the README on GitHub
- Verify the diagram renders correctly
- Check that all connections and labels are visible
- Focus on major components and data flows
- Don't include implementation details
- Show logical groupings using subgraphs
- Component name + brief description
- Use
<br/>for line breaks in labels - Keep labels concise but informative
- Group related components in subgraphs
- Use consistent arrow styles
- Add labels to connections for clarity
- Keep the layout clean and organized
- When updating the diagram, also update:
docs/ARCHITECTURE.mdfor detailed explanations- Component-specific documentation
- API documentation if interfaces change
- Include diagram updates in the same PR as code changes
- Mention diagram updates in commit messages
- Document significant architectural changes in PR descriptions
DB[(Database Name<br/>Description)]
Component --> DB
style DB fill:#fce4ec
subgraph "External Services"
NewAPI[New API<br/>api.example.com]
end
API -->|HTTP Requests| NewAPI
style NewAPI fill:#f3e5f5
subgraph "Application Layer"
Worker[Background Worker<br/>Async Tasks]
end
API --> Worker
Worker --> DB
style Worker fill:#fff3e0
FutureFeature[Feature Name<br/><i>future</i>]
Component -.->|Planned| FutureFeature
- Check Mermaid syntax is valid (use Mermaid Live)
- Ensure code block is marked with
```mermaid - Check for unescaped special characters
- Verify all node names are consistent
- Try different graph directions:
TB(top-bottom),LR(left-right) - Reorder node definitions
- Simplify complex subgraphs
- Use line breaks in long labels
- Verify node names match exactly (case-sensitive)
- Check style definitions are at the end
- Use valid CSS color codes
- Test styles in Mermaid Live Editor
If you have questions about updating the architecture diagram:
- Check the Architecture Documentation
- Open a GitHub Discussion
- Review previous PRs that modified the diagram