|
| 1 | +--- |
| 2 | +title: 'Architecture Overview' |
| 3 | +--- |
| 4 | + |
| 5 | +{{< toc >}} |
| 6 | + |
| 7 | +Sprotty is a diagramming framework that provides a robust foundation for building interactive, web-based diagram editors. At its core, Sprotty follows a clear architectural pattern that ensures maintainability, testability, and extensibility. |
| 8 | + |
| 9 | +## Introduction to Sprotty's Architecture |
| 10 | + |
| 11 | +The foundation of Sprotty's architecture is built around three main components that work together in a unidirectional flow: |
| 12 | + |
| 13 | +1. **Action Dispatcher**: The central hub that receives and processes all diagram operations |
| 14 | +2. **Command Stack**: The state manager that maintains the diagram's history and current state |
| 15 | +3. **Viewer**: The renderer that transforms the internal model into a visual representation |
| 16 | + |
| 17 | +These components form a cyclic flow of information that prevents feedback loops and ensures predictable behavior. |
| 18 | + |
| 19 | +{{< mermaid class="text-center">}} |
| 20 | +flowchart TD; |
| 21 | + ActionDispatcher[Action Dispatcher] |
| 22 | + CommandStack[Command Stack] |
| 23 | + Viewer[Viewer] |
| 24 | + ActionDispatcher -->|Command| CommandStack |
| 25 | + CommandStack -->|SModel| Viewer |
| 26 | + Viewer -->|Action| ActionDispatcher |
| 27 | +{{< /mermaid>}} |
| 28 | + |
| 29 | +This architecture provides several key benefits: |
| 30 | + |
| 31 | +- **Predictable State Management**: The unidirectional flow makes it easy to track and debug state changes |
| 32 | +- **Testability**: Each component has a clear responsibility and can be tested in isolation |
| 33 | +- **Extensibility**: New features can be added by extending any of the core components |
| 34 | +- **Performance**: The architecture minimizes unnecessary updates and optimizes rendering |
| 35 | + |
| 36 | +## What You'll Learn |
| 37 | + |
| 38 | +This documentation series will guide you through Sprotty's architecture in logical steps: |
| 39 | + |
| 40 | +1. **[Core Components]({{< relref "core-components" >}})**: Deep dive into the three main architectural components |
| 41 | +2. **[Data Flow]({{< relref "data-flow" >}})**: Understanding how information moves through the system |
| 42 | +3. **[Extension Points]({{< relref "extension-points" >}})**: How to customize and extend Sprotty's functionality |
| 43 | +4. **[Best Practices]({{< relref "best-practices" >}})**: Guidelines for building robust Sprotty applications |
| 44 | + |
| 45 | +Each section builds upon the previous ones, providing a comprehensive understanding of how to build effective diagramming applications with Sprotty. |
| 46 | + |
| 47 | +## Next Steps |
| 48 | + |
| 49 | +Start with the [Core Components]({{< relref "core-components" >}}) section to understand the fundamental building blocks of Sprotty's architecture, then progress through each section to build a complete understanding of the framework. |
0 commit comments