Skip to content

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.

# PATCH/PUT /seeds/1
def update
if @seed.update(seed_params)
redirect_to @seed, notice: 'Seed was successfully updated.', status: :see_other

Check notice

Code scanning / Brakeman

Possible unprotected redirect. Note

Possible unprotected redirect.
@@ -0,0 +1,10 @@
<p style="color: green"><%= notice %></p>

<%= render @seed %>

Check notice

Code scanning / Brakeman

Render path contains parameter value. Note

Render path contains parameter value.
…th validation, size limits, and safe YAML loading; add corresponding tests.
…ding safe YAML loading, file path validation, file size limits, and enhanced import infrastructure; add extensive testing coverage.
…rt process; update migrations, factories, and specs accordingly.
…ling; update specs to reflect changes in person lookup logic
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.

2 participants