Skip to content

weboko/p2p-gists

Repository files navigation

πŸ” P2P Gists

P2P Gists Banner

A lightweight, peer-to-peer web application for sharing encrypted code snippets

Live Demo MIT License React Waku


🌟 What is P2P Gists?

P2P Gists is a modern, privacy-focused alternative to traditional code sharing platforms. Instead of storing your code on centralized servers, it uses cutting-edge peer-to-peer technology to share encrypted code snippets directly between users.

🎯 Key Concepts Explained

πŸ”— Peer-to-Peer (P2P)

Instead of sending your code to a central server (like GitHub or Pastebin), P2P technology allows users to share data directly with each other. Think of it like passing a note directly to someone instead of putting it in a shared mailbox.

🏠 Local-First

Your data lives on your device first. The app works offline, syncs when online, and you maintain control over your information. No dependency on external servers for basic functionality.

πŸ” End-to-End Encryption (E2EE)

Your code is encrypted before it leaves your device and can only be decrypted by recipients who have the proper keys. Even if someone intercepts the data, they can't read it without the decryption key.


✨ Features

  • πŸ”’ End-to-end encrypted code sharing
  • 🌐 Peer-to-peer distribution using Waku network
  • πŸ’Ύ Local-first - works offline and syncs when online
  • 🎨 Syntax highlighting for 20+ programming languages
  • πŸŒ™ Dark/Light theme support
  • πŸ“± Responsive design - works on desktop and mobile
  • πŸš€ No registration required - truly anonymous
  • ⚑ Fast and lightweight - built with modern web technologies

πŸ› οΈ Technology Stack

  • Frontend: React 18 + Vite
  • Styling: Tailwind CSS
  • P2P Network: Waku - Ethereum's messaging protocol
  • Database: Dexie (IndexedDB wrapper)
  • Encryption: Built-in Web Crypto API
  • Syntax Highlighting: PrismJS
  • Routing: React Router

πŸš€ Quick Start

πŸ“± Use Online (Recommended)

Visit the live application: https://weboko.github.io/p2p-gists/

πŸ’» Run Locally

Prerequisites

  • Node.js 18+ installed
  • npm or yarn package manager

Installation

# Clone the repository
git clone https://github.com/weboko/p2p-gists.git
cd p2p-gists

# Install dependencies
npm install

# Start development server
npm run dev

The app will be available at http://localhost:3000

Build for Production

# Build the application
npm run build

# Preview the build
npm run preview

πŸ“– How to Use

Creating a Code Snippet

  1. Open the app in your browser
  2. Write or paste your code in the editor
  3. Select the programming language from the dropdown
  4. Add a title (optional)
  5. Click "Share" to generate an encrypted link
  6. Copy the link and share it with others

Viewing a Shared Snippet

  1. Click on a P2P Gists link you received
  2. The app will automatically decrypt the code (if you have access)
  3. View the syntax-highlighted code in your browser
  4. Copy the code or save it locally if needed

πŸ”‘ Privacy Features

  • No accounts required - completely anonymous
  • No server storage - code is shared directly between peers
  • Automatic encryption - your code is encrypted before leaving your device
  • Ephemeral sharing - snippets exist only as long as peers are sharing them

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Your Device   β”‚    β”‚   Waku Network  β”‚    β”‚  Peer's Device  β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚    β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚    β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚   Encrypt   β”‚ │───▢│ β”‚   Relay     β”‚ │───▢│ β”‚   Decrypt   β”‚ β”‚
β”‚ β”‚   Code      β”‚ β”‚    β”‚ β”‚   Messages  β”‚ β”‚    β”‚ β”‚   Code      β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚    β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚    β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚    β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚    β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Local Store β”‚ β”‚    β”‚ β”‚ P2P Network β”‚ β”‚    β”‚ β”‚ Local Store β”‚ β”‚
β”‚ β”‚ (IndexedDB) β”‚ β”‚    β”‚ β”‚ (Libp2p)    β”‚ β”‚    β”‚ β”‚ (IndexedDB) β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚    β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚    β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. Code is encrypted on your device using Web Crypto API
  2. Encrypted data is shared via Waku's P2P network
  3. Peers receive and decrypt the code using the shared key
  4. Local storage keeps your snippets available offline

πŸ”§ Development

Project Structure

src/
β”œβ”€β”€ components/          # React components
β”‚   β”œβ”€β”€ CreateSnippet.jsx
β”‚   β”œβ”€β”€ ViewSnippet.jsx
β”‚   └── ...
β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”œβ”€β”€ useIdentity.js
β”‚   └── useTheme.js
β”œβ”€β”€ lib/                 # Core utilities
β”‚   β”œβ”€β”€ crypto.js        # Encryption/decryption
β”‚   β”œβ”€β”€ database.js      # Local storage
β”‚   β”œβ”€β”€ waku.js          # P2P networking
β”‚   └── utils.js
└── ...

Available Scripts

npm run dev      # Start development server
npm run build    # Build for production
npm run preview  # Preview production build
npm run lint     # Run ESLint

Environment Variables

The app automatically detects the environment:

  • Development: No configuration needed
  • GitHub Pages: Automatically configured for deployment

🀝 Contributing

We welcome contributions! Here's how you can help:

πŸ”₯ Technical Challenges

Want to dive deep into P2P technology? We have exciting implementation challenges:

  • Peer Sharing Module - Implement real-time P2P snippet sharing
  • Collaborative Editing - Add CRDT-based collaborative editing

πŸ‘‰ View All Challenges & Get Started β†’

πŸ› Found a Bug?

  • Check existing issues
  • Create a new issue with detailed description

πŸ’‘ Have an Idea?

  • Open an issue to discuss your idea
  • Fork the repo and create a pull request

πŸ”§ Want to Code?

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Test thoroughly
  5. Commit: git commit -m 'Add amazing feature'
  6. Push: git push origin feature/amazing-feature
  7. Open a pull request

πŸ›‘οΈ Security & Privacy

What We Do

  • βœ… End-to-end encryption for all code snippets
  • βœ… No server-side storage of your code
  • βœ… No tracking or analytics
  • βœ… Open source - audit the code yourself

What We Don't Do

  • ❌ No data collection - we don't know what you share
  • ❌ No user accounts - completely anonymous
  • ❌ No server logs - no central storage of any kind

Important Notes

  • Links contain encryption keys - only share with trusted recipients
  • Snippets are ephemeral - they exist only while peers are online
  • Use responsibly - don't share sensitive credentials or personal data

πŸ“š Learn More

About the Technologies

Similar Projects


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ’– Support

If you find this project useful:

  • ⭐ Star the repository
  • 🐦 Share on social media
  • 🀝 Contribute to the code
  • πŸ› Report bugs or suggest features

Made with ❀️ for the decentralized web

Demo β€’ Issues β€’ Discussions

About

Implementation of GitHub Gists in local-first, p2p and end-to-end encrypted way.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published