Overview
Modality is a Flutter/Rust library for building interactive educational content. It provides three modalities — Whiteboard, Worksheet, and Lesson Plan — each with template compilation, Loro CRDT sync, and AI-powered generation.
Architecture at a Glance
Section titled “Architecture at a Glance”graph TD A[modality_core] -->|pure traits + types| B[modality_session] B -->|Session orchestrator| C[modality_ai] B --> D[modality_export] C --> E[Whiteboard] C --> F[Worksheet] C --> G[Lesson Plan] D --> E D --> F D --> G E --> H[modality_rust / API] F --> H G --> H H --> I[Flutter / Dart]Three Traits, One Struct
Section titled “Three Traits, One Struct”Each modality (Whiteboard, Worksheet, LessonPlan) implements three core traits:
| Trait | Concern |
|---|---|
Reducer | State management via static reduce() + instance dispatch() |
Component | Compilation from state to rendered output |
Modality | Layout orchestration, placements, snapshots |
Key Concepts
Section titled “Key Concepts”- Element — leaf rendered primitive (things on the canvas/page)
- Component — reusable templated layout that compiles to elements
- Position — modality-specific spatial info (
WhiteboardPosition,GridPosition,SlidePosition) - ComponentPlacement<P> — a placed component instance stored in synced state
- Session<M, I> — single orchestrator that owns modality, persistence, cache, AI, and export
Tech Stack
Section titled “Tech Stack”| Layer | Technology |
|---|---|
| UI | Flutter / Dart |
| Bridge | Flutter Rust Bridge (FRB) |
| Core | Rust (traits, state, compilation) |
| Persistence | Loro CRDT |
| AI | rig-core (OpenAI compatible) |
| Export | PDF via modality_export |
Dependency Graph
Section titled “Dependency Graph”graph TD CORE[modality_core] -->|pure traits + types| SESSION[modality_session] SESSION -->|Session orchestrator| AI[modality_ai] SESSION --> EXPORT[modality_export] AI --> MOD[modality crates] EXPORT --> MOD MOD --> API[modality_rust / API]