Skip to content

Enhancement: IPFS integration for large file storage #104

@michaelstingl

Description

@michaelstingl

Background

Tribelike currently stores all data in Gun.js, including references to images and other media. As the platform grows, storing large binary files directly in Gun could impact performance and increase storage requirements across all peers.

How This Idea Came About

While documenting the P2P architecture, I noticed that all data - including potentially large files like profile images - flows through Gun.js. This is a common challenge in P2P systems: Gun.js excels at synchronizing structured data, but large binary files can bloat the database. IPFS (InterPlanetary File System) is the standard solution in the decentralized web community for this exact problem.

Proposal

Integrate IPFS (InterPlanetary File System) for distributed storage of large files while keeping metadata and references in Gun.js.

Implementation Approach

  1. IPFS Integration

    • Add IPFS client to the frontend
    • Set up IPFS gateway for retrieval
    • Optional: Run local IPFS node
  2. File Upload Flow

    // Upload to IPFS
    const cid = await ipfs.add(file)
    
    // Store reference in Gun
    gun.get('profile/123').put({
      avatar: `ipfs://${cid}`
    })
  3. Retrieval

    • Fetch from IPFS using CID
    • Cache locally for performance
    • Fallback to HTTP gateways

Benefits

  • Reduced data size in Gun.js
  • Efficient distribution of large files
  • Content-addressed storage (deduplication)
  • Maintains decentralized architecture

Considerations

  • IPFS node requirements
  • Gateway availability
  • Pinning strategy for persistence
  • Migration of existing media

Resources

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions