How directus/rstore works
Main Components
• Core Data Store Module:
– Represented by packages/core.
– Provides the normalized reactive cache, query engine (findFirst, findMany, peek variants), mutation engine (create, update, delete), subscription system, and store management.
• Plugin System:
– Core’s extensibility via plugins is implemented (see packages/core/src/plugin.ts and hooks in shared packages).
– Emphasize how plugins allow the core to adapt fetch mechanisms (e.g., REST, GraphQL).
• Integration Modules for Frameworks:
– Nuxt integrations (packages/nuxt, packages/nuxt-directus, packages/nuxt-drizzle) that wrap the core with framework‑specific logic and devtools.
– Vue integration (packages/vue) that exposes functions to use within Vue applications.
• Playground/Demo Applications:
– Multiple “playground” packages show example usage and act as both testbeds and demonstrations of how rstore can be integrated (e.g., packages/playground-drizzle, packages/playground-nuxt-directus, packages/playground-ws-server, and packages/playground).
• Documentation and DevTools:
– The docs folder with VitePress configuration points to an extensive documentation system.
– Devtools integration in Nuxt and client modules as shown by components under packages/nuxt/client in the devtools folder.
• Shared Utilities and Types:
– Common/shared code in packages/shared that includes type definitions and utility functions used across modules.
Relationships and Interactions
• All integration modules (Nuxt, Vue, etc.) depend on the core package to perform data operations.
• The plugin system acts as a middleware layer between the core and any external data sources.
• The reactive cache ensures that when data is mutated via the mutation API or updated via subscriptions, all connected UI components (often colocated in the host framework, like Nuxt) are kept in sync.
• Playground applications demonstrate how the modules (core + integrations) work together, sometimes including separate server code (REST API endpoints or WebSocket routes as found under playground and playground-ws-server).
• Shared utilities and type definitions provide consistency across the code base, interfacing with both the core functionality and integration packages.
Architectural Patterns and Design Principles
• Modularity: The monorepo organizes related but distinct aspects as separate packages; each package has a clear niche (core, direct integrations, utilities, playgrounds).
• Plugin/Extensibility Design: Illustrate how external data fetching strategies (REST, GraphQL, etc.) can be abstracted via plugins.
• Colocation: Document that queries can be colocated in components (see docs/guide/data) which directly use modules from the core.
Relevant Technologies, Frameworks, and Libraries
• TypeScript – nearly all files use it (indicated by .ts and .mts files).
• Nuxt and Vue – with dedicated packages for integration.
• VitePress – used for docs and demonstration.
• Testing frameworks – Vitest configuration is present for tests (highlight test folders under packages).
• GitHub Actions – as seen in the workflows in .github/workflows (for CI, release, nightly).
• Branch out to “Plugin System” that influences or extends the core.
• Also branch out to “Playground / Demo Applications” and “Documentation/DevTools.”
Happy diagramming!