Riffle: Reactive Relational State for Local-First Applications
Authors
Document Title
Rifle: Reactive Relational State for Local-First Applications
Document Information
- Subject Area: Reactive data management combining user interface development and local-first architecture
- Keywords: Local-first software, UI state management, reactive programming, relational database, incremental view maintenance, synchronized transactional updates
Research Background and Problem
-
Identified Problems or Challenges:
- UI frameworks often compromise between simplicity and scalability.
- Developers need to handle complex cross-layer state management (e.g., ORM, databases, caches, views, etc.).
- State management in web applications often involves asynchronous operations, increasing complexity and potential inconsistencies.
- Existing frameworks mostly provide partial support for reactive development and fail to cover the full process from UI to data layers.
-
Significance:
- Efficient state management can significantly enhance productivity in developing complex applications.
- Incrementally complex state management is better suited to real-world application needs, especially in scenarios with large data volumes and high-performance requirements.
-
Research Motivation and Related Work:
- Drawing inspiration from the reactive data model of traditional spreadsheets while overcoming their performance and complexity limitations.
- The rise of local-first architectures facilitates offline use and asynchronous synchronization.
- Incremental view maintenance (IVM) in relational databases offers the potential for high-performance state updates.
Solution
-
Proposed Method:
- Introduce a reactive relational architecture:
- Data transformations are defined using relational queries with a DAG (Directed Acyclic Graph), providing a "declarative programming" interface.
- UI and domain state are unified and stored in a local relational database, enabling transactional synchronized updates.
- Design and implement the Rifle system:
- Built using a TypeScript library, integrating React.js and the SKDB database to support fast incremental updates and network synchronization.
- Implement a case study application: Overtone, a music management app, to explore Rifle's applicability in complex data and high-performance scenarios.
- Introduce a reactive relational architecture:
-
Innovations in the Solution:
- Unified reactive relational queries support synchronized updates between data and UI states.
- The local-first model avoids inconsistencies caused by asynchronous operations, significantly improving user experience.
- The introduction of declarative models like SQL allows developers to efficiently design data transformation logic, enhancing development intuitiveness.
-
Implementation Steps and Techniques:
- Store all application states in a locally persistent relational database (e.g., SKDB).
- Use transaction-level reactive control for UI and business state updates, ensuring full synchronization.
- Optimize update costs using incremental view maintenance techniques and incorporate a dynamic query generation mechanism.
- For large datasets, combine custom GraphQL and SKDB's incremental update capabilities to provide high-performance support.
Research Outcomes
-
Specific Results:
- Developed the Overtone music management application using Rifle, successfully simplifying UI and data state management.
- Overtone demonstrated fast UI responsiveness and flexible data view support, performing well even with a large number of tracks and complex relationships.
- Achieved support for reactive write transactions, enabling more efficient and reliable offline-first operations.
- Developers can write declarative queries with Rifle, simplifying and clarifying the handling of data dependencies.
-
Comparative Advantages:
- Compared to traditional web frameworks:
- Eliminates inconsistencies and latency issues introduced by network boundaries.
- Integrates UI state management with business-layer state management.
- Avoids requiring developers to write cumbersome state propagation logic.
- Compared to raw database support:
- Enhances reactive capabilities in relational queries, optimizing performance.
- Provides a complete development toolchain, particularly for UI and data integration scenarios.
- Compared to traditional web frameworks:
-
Experimental and Evaluation Results:
- Performance tests show that using an incremental relational database (e.g., SKDB) can achieve data update times of <3ms for datasets with millions of tracks, whereas traditional SQLite requires hundreds of milliseconds for full view recomputation.
- In the music management application, the UI exhibited near-instantaneous response (e.g., selecting playlists) even with tens of thousands of data entries, meeting the interaction standard of under 100ms.
- Replacing single SQL with GraphQL provided greater expressiveness, allowing the UI to more easily generate nested data structures.
-
Limitations and Future Directions:
- Limitations:
- Local-first software has limited applicability and is unsuitable for applications requiring frequent state updates, such as social networks or e-commerce platforms.
- The current relational data model cannot efficiently represent complex hierarchies and sequences.
- Unavoidable asynchronous operations (e.g., network requests, slow queries) still require additional logic from developers.
- Future Improvements:
- Design new declarative models (e.g., DIEL for handling network boundaries) to address more complex user scenarios.
- Develop more efficient mechanisms for cross-device data synchronization and collaboration support.
- Become part of a cross-application data interoperability platform, such as integration with customized analytics tools.
- Limitations:
Conclusion
Rifle introduces a novel architecture that deeply integrates UI with fast reactive relational databases, addressing numerous pain points in current web application development through a local-first model. The Overtone case study validates the applicability of the Rifle system in high-complexity and high-performance scenarios, providing significant inspiration for future user application development.
Research Questions / Practical Problems
Question signals indexed for this paper.
Research Questions
3- How can a reactive relational architecture solve complex state management problems in applications?Category: Hardware Maintenance and Asynchronous Problem-Solving SupportSimilar questionsarrow_forward
- Can local-first architecture reduce inconsistencies and improve UX by unifying UI and data state?Category: Hardware Maintenance and Asynchronous Problem-Solving SupportSimilar questionsarrow_forward
- How does incremental view maintenance (IVM) optimize data update efficiency in complex applications with high performance requirements?Category: Hardware Maintenance and Asynchronous Problem-Solving SupportSimilar questionsarrow_forward
Practical Problems
1- Developers struggle to efficiently manage cross-layer state and asynchronous updates in complex applications.Category: Hardware Maintenance and Asynchronous Problem-Solving SupportSimilar questionsarrow_forward
- 100%
Doppio: Tracking UI Flows and Code Changes for App Development
CHI '18· Knowledge Worker Tools & Workflows +1
- 67%
Exploring The Future of Data-Driven Product Design
CHI '20· Knowledge Worker Tools & Workflows +2
- 67%
Who is in Control? Understanding User Agency in AR-assisted Construction Assembly
CHI '25· AR Navigation & Context Awareness +2
- 60%
Challenges and Opportunities for Technology-Supported Activity Reporting in the Workplace
CHI '18· Knowledge Management & Team Awareness +1
- 60%
Improving Discoverability and Expert Performance in Force-Sensitive Text Selection for Touch Devices with Mode Gauges
CHI '18· Force Feedback & Pseudo-Haptic Weight +1
- 60%
ActiveErgo: Automatic and Personalized Ergonomics using Self-actuating Furniture
CHI '18· Full-Body Interaction & Embodied Input +1
- 60%
Exploring New File Metaphors for a Networked World through the File Biography
CHI '18· Knowledge Worker Tools & Workflows +1
- 60%
Pointing at a Distance with Everyday Smart Devices
CHI '18· Full-Body Interaction & Embodied Input +1
- 60%
Training Person-Specific Gaze Estimators from User Interactions with Multiple Devices
CHI '18· Eye Tracking & Gaze Interaction +1
- 60%
Using Visual Histories to Reconstruct the Mental Context of Suspended Activities
CHI '18· Knowledge Worker Tools & Workflows +1
Based on Jaccard similarity of research subtopics & professions (≥60%)