-
Notifications
You must be signed in to change notification settings - Fork 2
Description
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
-
IPFS Integration
- Add IPFS client to the frontend
- Set up IPFS gateway for retrieval
- Optional: Run local IPFS node
-
File Upload Flow
// Upload to IPFS const cid = await ipfs.add(file) // Store reference in Gun gun.get('profile/123').put({ avatar: `ipfs://${cid}` })
-
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