Unstoppable - This application demonstrates technology that continues operating even when cloud providers fail, governments attempt censorship, or software vendors shut down their services. Your data and functionality remain under your control, distributed across a resilient peer-to-peer network or self-hosted signaling or relay nodes. Imagine traditional software which was sold on a compact disc in the past - once installed it could never be stopped. A USP which should convince every client around the globe.
This is a browser only local-first peer-to-peer todo application that operates without any traditional server infrastructure. It connects directly to other browsers and mobile devices through peer-to-peer connections, creating a truly decentralized experience.
This project includes an enhanced P2P relay server that facilitates peer discovery and connectivity for the simple-todo application. The relay server provides:
# Run both the app and relay together
docker-compose up --build
# Access the app at http://localhost:5173
# Access relay API at http://localhost:3000
# Install relay dependencies
cd relay
npm install
# Start the relay server
npm start
# Or with verbose logging
npm run start:verbose
The relay server can be configured using environment variables:
# Port Configuration
RELAY_WS_PORT=4001 # WebSocket port for browsers
RELAY_TCP_PORT=4002 # TCP port for native libp2p nodes
RELAY_WEBRTC_PORT=4003 # WebRTC port
RELAY_WEBRTC_DIRECT_PORT=4006 # WebRTC Direct port
HTTP_PORT=3000 # HTTP API port
# Storage
DATASTORE_PATH=./relay-datastore
# Networking
PUBSUB_TOPICS=todo._peer-discovery._p2p._pubsub
# Security (Production)
API_PASSWORD=your_secure_password_here
RELAY_PRIV_KEY=your_hex_private_key_here
# Debugging
ENABLE_DATASTORE_DIAGNOSTICS=true
STRUCTURED_LOGS=true
The relay provides several HTTP API endpoints for monitoring and management:
GET /health
- Health check and system statusGET /multiaddrs
- Get relay multiaddresses for peer connectionGET /peers
- List connected peersGET /metrics
- Prometheus metrics (public endpoint)POST /test-pubsub
- Test pubsub messagingGET /pinning/stats
- OrbitDB pinning statisticsGET /pinning/databases
- List pinned databasesPOST /pinning/sync
- Manually sync a databaseThe relay comes with full Docker support including:
For comprehensive guides on how this app works, implementation details, and reusable components:
The tutorial covers:
🔧 AI-Friendly Component Reference
This codebase contains reusable components for building decentralized P2P applications. Key components for AI analysis and reuse:
ConsentModal.svelte - A comprehensive privacy consent component that manages user preferences for data storage (persistent vs session), network connectivity, and P2P connections. Features configurable checkboxes, storage toggles, and handles GDPR-style consent flow for decentralized applications.
StorachaIntegration.svelte - Complete Web3 storage integration component providing UCAN-based authentication, space management, and backup/restore functionality for OrbitDB databases to Storacha/Filecoin. Includes progress tracking, error handling, and space usage monitoring.
storacha-backup.js - Core backup/restore utility module that bridges OrbitDB with Storacha cloud storage. Provides functions for client initialization, space management, database backup/restore operations, and UCAN delegation handling for decentralized storage workflows.
p2p.js - Core P2P network initialization module that handles libp2p node creation, Helia (IPFS) setup, and OrbitDB database initialization. Manages user consent preferences for storage persistence, network connectivity, and peer connections. Includes comprehensive error handling, mobile-aware storage fallbacks, and initialization state management.
db-actions.js - Database operations module providing CRUD functionality for OrbitDB-based todo management. Features reactive Svelte stores, real-time database synchronization, event listeners for database changes, and comprehensive todo lifecycle management (add, delete, toggle completion, assignment).
libp2p-config.js - LibP2P network configuration module with environment-aware relay selection, multi-transport support (WebRTC, WebSockets, Circuit Relay), peer discovery via gossipsub, and configurable network preferences. Supports both development and production relay configurations with comprehensive connection management.
These components demonstrate patterns for: P2P consent management, Web3 storage integration, OrbitDB backup strategies, UCAN authentication flows, libp2p network configuration, decentralized database operations, and privacy-compliant P2P initialization.
# Clone repository
git clone https://github.com/NiKrause/simple-todo.git
# checkout simple-todo branch
git checkout simple-todo
# run (like this you don't need to cut and past anything)
./tutorial-01.js
This project is open source and available under the LICENSE file.