Skip to content

Add BetterTogether::Seed #790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Add BetterTogether::Seed #790

wants to merge 4 commits into from

Conversation

rsmithlal
Copy link
Member

@rsmithlal rsmithlal commented Mar 7, 2025

Summary of Changes

This pull request introduces BetterTogether::Seed, a new interoperable data protocol for the Community Engine platform. The Seed facilitates structured import/export of data, supporting:

  • Platform migrations (moving data between platforms)
  • Data backups and restores
  • Inter-platform data sharing over the internet (enabling federated platforms to exchange information in a controlled way)

Key Features & Changes

1. New BetterTogether::Seed Model

  • Central record for tracking a unit of exported or imported data.
  • Stores structured data (payload) and metadata (origin), including:
    • Contributors
    • Platform version
    • License
    • Usage notes
  • Supports attachment of a YAML file via Active Storage to allow easy download, transfer, or archival.

2. Seedable Concern for Models

  • Adds a Seedable module that any model can include to become seed-exportable.
  • Implements #plant, #export_as_seed, and #export_as_seed_yaml.
  • Supports exporting single records or collections.
  • Models currently made seedable:
    • Person
    • Wizard
    • WizardStep
    • WizardStepDefinition

3. SeedsController for CRUD UI

  • Basic admin UI to view, create, and manage seeds.
  • Accessible via /seeds in the admin panel.

4. Import/Export Workflow

  • Seeds can be created directly from records (manual export).
  • Seeds can also be loaded from files (manual import).
  • Supports two approaches to import:
    • Direct file path.
    • Predefined namespace lookup (config/seeds/...).

5. Schema Migration

  • New table better_together_seeds with:
    • Polymorphic seedable association.
    • origin and payload JSONB columns (indexed for performance).
    • Index on type + identifier for fast lookup.

6. FactoryBot Factories & Shared Example

  • Adds factories for seeds.
  • Introduces a shared_examples file to ensure any seedable model behaves correctly.

Why This Matters

The Seed is a foundational piece of Community Engine’s commitment to data sovereignty. By enabling structured data import/export in a standard format, it:

✅ Empowers communities to migrate between platforms with minimal friction.
✅ Enables true data ownership, giving admins the ability to back up and restore their data anytime.
✅ Sets the groundwork for future federated platform collaboration, where platforms can exchange content in a structured, permissioned way.


Testing & Coverage

  • Includes full RSpec test suite for:
    • Seed model.
    • Seedable concern.
    • Controller CRUD actions.
    • View rendering for seeds.
  • Adds a shared example ensuring all future seedable models adhere to the expected interface.

Files Changed

  • 32 files changed
  • 1,038 additions / 83 deletions

Migration Required

✅ Yes – create_better_together_seeds


Related Issues

  • Lays the groundwork for federated data exchange across platforms.
  • Supports backup/restore requirements for local hosting scenarios.

Suggested Next Steps

  • Document the Seed structure and format for third-party implementers.
  • Add support for bulk import/export from the command line.
  • Implement integration test cases for end-to-end import/export cycles across multiple platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant