System Design
Building a Robust and Scalable Interactive System
- System Architecture
- Sequence Diagram
- Design Patterns
- Class Diagrams
- Data Storage
Sequence Diagram
Design Patterns
We maintained high code readability by following several proven software design patterns:
Design Pattern | Usage Description |
---|---|
Singleton | HueService ensures a single instance manages communication with the Phillips Hue bridge, avoiding redundant requests. |
Observer | AIProgressTracker updates the UI in response to console logs during AI processing, decoupling logic from presentation. |
Strategy | Used in ParticleSelector and ShaderImageSelector to switch between different visual generation techniques. |
Factory | particleSelector dynamically generates particles, whether pre-configured or user-defined. |
Command | MenuBuilder encapsulates menu commands like “Toggle Dev Tools” and “Run Gemma Test” for clean reusability. |
Template Method | ShaderVisual defines a rendering skeleton, with overridable hooks like object creation or mouse interaction. |
Chain of Responsibility | In HueService , light updates and beat detection flow through chained handlers, each processing a specific stage. |
Design Principles
- Single Responsibility Principle (SRP): Each class/component has one clear purpose.
E.g.,ParticleSettings
handles config;ShaderImageSelector
manages shader images. - Open/Closed Principle (OCP): Extensible via Strategy/Factory patterns — easily add new visuals without editing core logic.
- Don’t Repeat Yourself (DRY): Reused logic is abstracted into reusable components or methods.