# Noterich P2P Sync Tutorial: Cross-Device Without Cloud > **Sync your notes across devices securely — no cloud storage required.** In an era where data privacy matters more than ever, Noterich offers a revolutionary approach to cross-device synchronization. Our **P2P (Peer-to-Peer) Sync** feature enables seamless note sharing between your devices without relying on any cloud servers. Your data stays yours — always. ## Why Choose P2P Sync? Traditional note-taking apps store your data on centralized servers. This creates potential privacy risks, subscription costs, and dependency on third-party infrastructure. Noterich takes a different path: ```mermaid graph LR A[Your Device] <-->|Direct Connection| B[Your Other Device] C[Cloud Server] -.->|Not Required| A C -.->|Not Required| B style A fill:#4CAF50,color:#fff style B fill:#4CAF50,color:#fff style C fill:#9E9E9E,color:#fff,stroke-dasharray: 5 5 ``` ### Key Benefits - **🔒 Privacy First**: Your notes never touch third-party servers - **⚡ Fast & Direct**: Devices communicate directly for faster sync - **💰 No Subscription**: Free P2P sync without premium tiers - **🌐 Works Anywhere**: Sync over local network or internet - **📱 Cross-Platform**: Works between desktop, laptop, tablet, and mobile ## How P2P Sync Works Noterich uses **WebRTC technology** combined with **PeerJS** to establish direct connections between your devices. When you initiate a sync: ```mermaid sequenceDiagram participant D1 as Device A (Sender) participant S as Signaling Server participant D2 as Device B (Receiver) D1->>S: Request connection ID S-->>D1: Generate room ID D1->>D2: Share connection link (QR/URL) D2->>S: Connect using room ID S-->>D2: Establish peer connection D1->>D2: Encrypt & send notes D2->>D2: Decrypt & import notes Note over D1,D2: Direct encrypted transfer<br/>No data stored on server ``` ### The Technology Behind the Scenes Noterich's P2P implementation leverages: 1. **PeerJS Library**: Handles WebRTC complexity for browser-to-browser communication 2. **AES-GCM Encryption**: Military-grade encryption for your note data 3. **PBKDF2 Key Derivation**: Secure password-based encryption key generation 4. **MessagePack Serialization**: Efficient binary data encoding for fast transfers 5. **IndexedDB Storage**: Local-first database for offline access ## Getting Started with P2P Sync ### Prerequisites Before you begin, ensure you have: - ✅ Noterich installed on both devices - ✅ Both devices connected to the internet (or same local network) - ✅ A modern web browser (Chrome, Firefox, Edge, Safari) ### Step 1: Initiate Sharing from Source Device 1. Open the note you want to share in Noterich 2. Click the **Share** button in the toolbar 3. Select **"P2P Share"** option 4. (Optional) Set a password for extra security - Passwords must be at least 8 characters - Uses AES-256-GCM encryption 5. Wait for the P2P server to initialize ```mermaid graph TD A[Open Note] --> B[Click Share Button] B --> C[Select P2P Share] C --> D{Set Password?} D -->|Yes| E[Enter Password ≥8 chars] D -->|No| F[Skip Encryption] E --> G[Initialize P2P Server] F --> G G --> H[Generate Share Link & QR Code] ``` ### Step 2: Share the Connection Link Once the P2P server starts, Noterich generates: - **A unique shareable link** containing connection parameters - **A QR code** for quick mobile scanning The link format looks like: ``` https://noterich.com/#dbshare=<infoHash>&server=<signaling-server> ``` **Sharing Methods:** | Method | Best For | How To | |--------|----------|--------| | 🔗 Copy Link | Email, messaging apps | Click "Copy Link" button | | 📱 QR Code | Mobile devices | Scan with device camera | | 📧 Email | Remote collaborators | Paste link in email | ### Step 3: Receive on Target Device On the receiving device: 1. **Open the share link** - Click the link directly, OR - Scan the QR code with your mobile device 2. **Review incoming notes** - Preview note titles and metadata - Verify the sender information 3. **Enter password** (if encrypted) - Input the password provided by sender - Data decrypts locally on your device 4. **Select destination workspace** - Choose existing workspace, OR - Create a new workspace for imported notes 5. **Confirm import** - Notes are decrypted and saved to IndexedDB - Search index rebuilds automatically ```mermaid graph LR A[Open Link] --> B[Connect to Sender] B --> C{Encrypted?} C -->|Yes| D[Enter Password] C -->|No| E[Receive Metadata] D --> E E --> F[Preview Notes] F --> G[Select Workspace] G --> H[Import & Index] H --> I[Sync Complete!] style I fill:#4CAF50,color:#fff ``` ## Advanced Features ### Encrypted Transfers For sensitive notes, Noterich offers optional end-to-end encryption: **Encryption Process:** ```javascript // Password → Encryption Key (PBKDF2) password + salt → deriveKey() → AES-256-GCM key // Note Data → Encrypted Buffer noteData + key + iv → encrypt() → encryptedBuffer // Transfer Package { encryptedBuffer: ArrayBuffer, salt: Uint8Array, // For key derivation iv: Uint8Array // Initialization vector } ``` **Security Features:** - 🔐 100,000 PBKDF2 iterations for key derivation - 🔐 Random salt and IV for each transfer - 🔐 AES-256-GCM authenticated encryption - 🔐 Password never transmitted — only used locally ### Batch Note Sync Transfer multiple notes efficiently: 1. Access **Database Transfer** from settings 2. Select **"P2P Sync"** mode 3. Choose notes to synchronize 4. Receiver gets batch preview with selection options **Performance Optimization:** - Notes transferred in chunks (512KB each) - Non-blocking async processing prevents UI freeze - Progress tracking with byte-level accuracy - Cancel anytime without data corruption ### Conflict Resolution When syncing notes that exist on both devices: ```mermaid graph TD A[Detect Conflict] --> B{Compare Timestamps} B -->|Local Newer| C[Keep Local Version] B -->|Remote Newer| D[Show Conflict Dialog] D --> E[Choose Version] E --> F[Local] E --> G[Remote] E --> H[Merge Manually] B -->|Both Deleted| I[Skip] style C fill:#2196F3,color:#fff style F fill:#2196F3,color:#fff style G fill:#4CAF50,color:#fff ``` **Conflict Types Handled:** - `local-newer`: Your version is more recent - `remote-newer`: Incoming version is newer - `local-deleted`: You deleted this note locally - `remote-deleted`: Note was deleted on sender's device - `remote-restored`: Previously deleted note restored ## Troubleshooting ### Common Issues & Solutions #### ❌ "PeerJS library not loaded" **Cause**: Network blocking PeerJS CDN or signaling server **Solutions:** 1. Check internet connection 2. Verify firewall allows WebRTC connections 3. Try alternative network (mobile hotspot) 4. Ensure browser supports WebRTC #### ❌ "Connection timeout" **Cause**: NAT/Firewall preventing direct connection **Solutions:** 1. Both devices on same network helps 2. Disable VPN temporarily 3. Check router WebRTC settings 4. Use QR code for mobile connections #### ❌ "Decryption failed" **Cause**: Incorrect password or corrupted transfer **Solutions:** 1. Verify password matches exactly (case-sensitive) 2. Request new share link from sender 3. Ensure stable connection during transfer 4. Try smaller batch sizes #### ❌ "Sync in progress" error **Cause**: Multiple simultaneous sync attempts **Solutions:** 1. Wait for current sync to complete 2. Close other Noterich tabs/windows 3. Refresh page and retry 4. Clear browser cache if persistent ### Connection Status Indicators | Status | Meaning | Action | |--------|---------|--------| | 🔵 Connecting | Establishing peer connection | Wait 5-10 seconds | | 🟡 Comparing | Analyzing note differences | Normal process | | 🟠 Waiting-for-user | Password or confirmation needed | Check modal dialogs | | 🟢 Applying | Importing notes to database | Do not close tab | | ✅ Success | Sync completed successfully | Ready to use notes | | 🔴 Error | Connection or transfer failed | Check troubleshooting | ## Security Best Practices ### Protecting Your Data While P2P sync is inherently secure, follow these guidelines: 1. **Use Strong Passwords** - Minimum 8 characters (12+ recommended) - Mix uppercase, lowercase, numbers, symbols - Never reuse passwords from other services 2. **Verify Recipients** - Only share links with trusted devices - Use QR codes for physical proximity transfers - Avoid posting links in public channels 3. **Monitor Active Connections** - Check connected peers during sync - Disconnect after successful transfer - Revoke shared links if compromised 4. **Regular Backups** - Export important notes periodically - Store backups in separate secure location - Test restore procedures regularly ### Understanding Encryption Limits **What's Encrypted:** - ✅ Note content (text, formatting, metadata) - ✅ Attachments and embedded media - ✅ Database structure during transfer **What's Not Encrypted:** - ⚠️ Connection metadata (timing, data size) - ⚠️ IP addresses (visible to signaling server) - ⚠️ Device identifiers (for connection routing) ## Performance Tips ### Optimize Sync Speed 1. **Network Conditions** - Same local network = fastest transfers - 5GHz WiFi preferred over 2.4GHz - Wired Ethernet for desktop devices 2. **Batch Sizes** - Large transfers: Split into smaller batches - Monitor progress indicator - Cancel and retry if stalled 3. **Browser Performance** - Keep Noterich tab active during sync - Close unnecessary browser tabs - Update to latest browser version 4. **Device Resources** - Ensure sufficient storage space - Close memory-intensive applications - Restart browser if sync slows ### Memory Management Noterich implements smart batching to prevent browser crashes: ```javascript // Async batch processing with setTimeout yielding async function asyncBatchProcessor(items, processor, batchSize = 10) { // Processes items in batches of 10 // Yields control every 10ms to keep UI responsive // Prevents main thread blocking during large imports } ``` **Recommendations:** - Limit single transfers to 100 notes maximum - Wait 30 seconds between large batch syncs - Clear browser cache periodically ## FAQ ### Q: Can I sync more than two devices? **A:** Yes! Initiate separate P2P sessions for each device pair. For multi-device workflows: 1. Sync Device A → Device B 2. Then sync Device B → Device C 3. Or use Device A as central hub for all others ### Q: Does P2P sync work offline? **A:** P2P requires initial internet connection for signaling server handshake. After connection establishment: - ✅ Local network transfers work without internet - ✅ Data transfers directly between devices - ❌ Initial connection needs signaling server access ### Q: What happens if sync is interrupted? **A:** Noterich handles interruptions gracefully: - Partially transferred notes are discarded - No corrupted data enters your database - Simply restart the sync process - Already-synced notes remain unaffected ### Q: Can I sync with someone else's Noterich instance? **A:** Absolutely! P2P sync works between any Noterich users: - Share individual notes with collaborators - No account linkage required - Each transfer is independent and secure - Perfect for one-time note sharing ### Q: Is there a file size limit? **A:** Practical limits depend on: - Browser memory availability - Network stability - Recommended max: 50MB per session - Larger transfers: Split into multiple batches ### Q: How long do share links remain valid? **A:** Share links are session-based: - Valid while sender's Noterich tab remains open - Expire when sender closes tab/browser - One-time use recommended for security - Generate new link for each transfer session ## Comparison: P2P vs Cloud Sync ```mermaid quadrantChart title "Sync Method Comparison" x-axis "Lower Privacy" --> "Higher Privacy" y-axis "Lower Control" --> "Higher Control" quadrant-1 "Noterich P2P" quadrant-2 "Avoid" quadrant-3 "Traditional Cloud" quadrant-4 "Centralized Services" "Noterich P2P": [0.9, 0.9] "Traditional Cloud": [0.3, 0.4] "Centralized Services": [0.4, 0.3] ``` | Feature | Noterich P2P | Cloud Sync | |---------|--------------|------------| | **Data Storage** | Your devices only | Third-party servers | | **Privacy Level** | Maximum | Depends on provider | | **Cost** | Free | Often subscription-based | | **Setup Complexity** | Moderate | Simple | | **Sync Speed** | Very Fast (direct) | Medium (via server) | | **Offline Access** | Full | Limited | | **Vendor Lock-in** | None | High | | **Data Portability** | Complete | Restricted | ## Real-World Use Cases ### 📚 Personal Knowledge Base Sync your PKM (Personal Knowledge Management) system across: - Home desktop for deep work - Laptop for coffee shop sessions - Tablet for reading and annotations - Phone for quick capture ### 👥 Team Collaboration Share research notes securely within teams: - No IT infrastructure required - End-to-end encrypted transfers - Audit trail via transfer logs - Compliant with privacy regulations ### 🎓 Academic Research Collaborate on papers and literature reviews: - Share annotated PDFs and notes - Maintain version history locally - Work across university/personal devices - Protect unpublished research ### 🏢 Enterprise Deployment Deploy Noterich in privacy-conscious organizations: - No data leaves company network - Works behind firewalls with configuration - Integrates with existing security policies - Reduces cloud service dependencies ## Technical Deep Dive (For Developers) ### Architecture Overview ```mermaid graph TB subgraph Sender["Sender Device"] A1[Note Data] --> A2[MessagePack Serialize] A2 --> A3{Encrypted?} A3 -->|Yes| A4[AES-256-GCM Encrypt] A3 -->|No| A5[Plain Binary] A4 --> A6[Chunk into 512KB] A5 --> A6 A6 --> A7[WebRTC Data Channel] end subgraph Receiver["Receiver Device"] B1[WebRTC Data Channel] --> B2[Reassemble Chunks] B2 --> B3{Encrypted?} B3 -->|Yes| B4[AES-256-GCM Decrypt] B3 -->|No| B5[Plain Binary] B4 --> B6[MessagePack Deserialize] B5 --> B6 B6 --> B7[IndexedDB Storage] B7 --> B8[Search Index Rebuild] end A7 -.->|Direct P2P| B1 style A4 fill:#FF5722,color:#fff style B4 fill:#FF5722,color:#fff style A7 fill:#4CAF50,color:#fff style B1 fill:#4CAF50,color:#fff ``` ### Key Implementation Details **Signaling Server Configuration:** ```javascript const peerConfig = { host: 'www.noterich.com', port: 443, secure: true, key: 'peerjs' }; ``` **Encryption Flow:** 1. Generate random salt (16 bytes) 2. Generate random IV (12 bytes) 3. Derive key using PBKDF2 (100k iterations) 4. Encrypt with AES-256-GCM 5. Package: `{encryptedBuffer, salt, iv}` **Data Transfer Protocol:** ```javascript // Message types handled: { type: 'metadata', payload: {...} } // Note list { type: 'note-chunk', payload: {...} } // Note data chunk { type: 'progress', payload: {...} } // Transfer progress { type: 'complete', payload: {...} } // Transfer finished { type: 'cancel-sync-request' } // User cancellation { type: 'error', message: '...' } // Error reporting ``` ## Future Roadmap Noterich continues to enhance P2P capabilities: - 🔄 **Automatic Background Sync**: Detect nearby devices and sync silently - 🌐 **Mesh Networking**: Multi-hop transfers through intermediate devices - 📦 **Selective Sync**: Choose specific note sections to synchronize - 🔔 **Push Notifications**: Alert when sync requests arrive - 📊 **Sync Analytics**: Visualize sync history and data transferred - 🔗 **Deep Linking**: Direct note-level sharing with anchors ## Conclusion Noterich's P2P Sync represents a paradigm shift in how we think about note synchronization. By eliminating the cloud middleman, we've created a system that respects your privacy, reduces costs, and gives you complete control over your data. Whether you're a student managing research notes, a professional organizing project documentation, or a team collaborating on sensitive materials, P2P Sync provides the security and flexibility you need. **Start syncing smarter today — your notes, your devices, your control.** --- ### Quick Reference Card ``` ┌─────────────────────────────────────────────────────┐ │ NOTERICH P2P SYNC QUICK GUIDE │ ├─────────────────────────────────────────────────────┤ │ 1. Open note → Click Share → Select P2P │ │ 2. Set password (optional but recommended) │ │ 3. Copy link or show QR code │ │ 4. On receiver: Open link / Scan QR │ │ 5. Enter password if encrypted │ │ 6. Select workspace → Confirm import │ │ 7. Wait for completion → Start working! │ ├─────────────────────────────────────────────────────┤ │ 🔒 Encryption: AES-256-GCM + PBKDF2 (100k iters) │ │ ⚡ Tech Stack: WebRTC + PeerJS + IndexedDB │ │ 📦 Chunk Size: 512KB for optimal performance │ │ 🌐 Signaling: www.noterich.com:443 │ └─────────────────────────────────────────────────────┘ ``` --- <div class="flex flex-wrap gap-2 mt-8 mb-12"> <span class="px-3 py-1 bg-[#f4f4f5] border border-[#eaeaea] rounded-full text-xs font-medium text-[#666]">P2P</span> <span class="px-3 py-1 bg-[#f4f4f5] border border-[#eaeaea] rounded-full text-xs font-medium text-[#666]">Privacy</span> <span class="px-3 py-1 bg-[#f4f4f5] border border-[#eaeaea] rounded-full text-xs font-medium text-[#666]">Local-First</span> <span class="px-3 py-1 bg-[#f4f4f5] border border-[#eaeaea] rounded-full text-xs font-medium text-[#666]">PKM</span> <span class="px-3 py-1 bg-[#f4f4f5] border border-[#eaeaea] rounded-full text-xs font-medium text-[#666]">WebRTC</span> <span class="px-3 py-1 bg-[#f4f4f5] border border-[#eaeaea] rounded-full text-xs font-medium text-[#666]">Encryption</span> <span class="px-3 py-1 bg-[#f4f4f5] border border-[#eaeaea] rounded-full text-xs font-medium text-[#666]">Cross-Device</span> <span class="px-3 py-1 bg-[#f4f4f5] border border-[#eaeaea] rounded-full text-xs font-medium text-[#666]">No-Cloud</span> </div>