Zum Inhalt

Dezentralisierung

🌐 Warum Dezentralisierung?

CommunicationFinder verfolgt eine dezentrale Architektur, um folgende Ziele zu erreichen:

  1. Privacy: Keine zentrale Instanz kann deine Daten einsehen
  2. Censorship Resistance: Niemand kann die Plattform abschalten
  3. Vendor-Lock-Free: Keine Abhängigkeit von einzelnen Anbietern
  4. User Ownership: Du besitzt deine Daten, nicht ein Unternehmen

🏗️ Dezentrale Komponenten

graph TB subgraph "Storage Layer" A1[IPFS] A2[Arweave] A3[Gun.js] end subgraph "Identity Layer" B1[DIDs] B2[ENS] B3[Unstoppable Domains] end subgraph "Computation Layer" C1[Client-Side JS] C2[Cloudflare Workers] C3[WebAssembly] end subgraph "Hosting Layer" D1[GitHub Pages] D2[Cloudflare Pages] D3[IPFS Gateway] end A1 --> B1 A2 --> B1 A3 --> B1 B1 --> C1 B2 --> C1 B3 --> C1 C1 --> D1 C2 --> D2 C3 --> D3 style A1 fill:#FFF3E0 style B1 fill:#F3E5F5 style C1 fill:#E3F2FD style D1 fill:#E8F5E9

📦 IPFS: Verteilte Speicherung

Was ist IPFS?

InterPlanetary File System ist ein Peer-to-Peer-Netzwerk zum Speichern und Teilen von Daten.

Kernkonzepte: - Content Addressing: Dateien werden durch ihren Inhalt identifiziert (CID) - Deduplizierung: Identische Inhalte werden nur einmal gespeichert - Verteilung: Daten werden über viele Nodes repliziert

Integration in CommunicationFinder

class IPFSStorage {
    constructor() {
        // Multi-Gateway für Redundanz
        this.gateways = [
            'https://ipfs.io/ipfs/',
            'https://cloudflare-ipfs.com/ipfs/',
            'https://dweb.link/ipfs/',
            'https://gateway.pinata.cloud/ipfs/'
        ];
    }

    async uploadSettings(settings) {
        // 1. Verschlüsseln (optional)
        const encrypted = await this.encrypt(settings);

        // 2. Zu IPFS hochladen
        const formData = new FormData();
        formData.append('file', new Blob([JSON.stringify(encrypted)]));

        const response = await fetch('https://api.pinata.cloud/pinning/pinFileToIPFS', {
            method: 'POST',
            headers: {
                'pinata_api_key': 'YOUR_API_KEY',
                'pinata_secret_api_key': 'YOUR_SECRET'
            },
            body: formData
        });

        const { IpfsHash } = await response.json();

        // 3. CID zurückgeben
        return IpfsHash; // z.B. QmXxx...
    }

    async downloadSettings(cid) {
        // Versuche mehrere Gateways
        for (const gateway of this.gateways) {
            try {
                const response = await fetch(gateway + cid);
                if (response.ok) {
                    const data = await response.json();
                    return this.decrypt(data);
                }
            } catch (err) {
                console.warn(`Gateway ${gateway} failed, trying next...`);
            }
        }
        throw new Error('All IPFS gateways failed');
    }
}

Vorteile

Permanenz

Einmal hochgeladene Settings bleiben für immer verfügbar (solange mindestens 1 Node sie hostet)

Integrität

CIDs sind kryptographische Hashes – manipulierte Daten haben andere CIDs

Kosteneffizienz

Identische Settings werden automatisch dedupliziert


🔐 DIDs: Selbstverwaltete Identität

Was sind DIDs?

Decentralized Identifiers sind ein W3C-Standard für Identitäten ohne zentrale Autorität.

Format:

did:ethr:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb
did:ion:EiClkZMDxPKqC9c-umQfTkR8vvZ9JPhl_xLDI9Nfk38w5w
did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK

Integration

class DIDManager {
    async createDID() {
        // Ethereum-basierte DID erstellen
        const provider = new ethers.providers.Web3Provider(window.ethereum);
        const signer = provider.getSigner();
        const address = await signer.getAddress();

        return `did:ethr:${address}`;
    }

    async signSettings(settings, did) {
        // Settings mit privatem Schlüssel signieren
        const message = JSON.stringify(settings);
        const signature = await window.ethereum.request({
            method: 'personal_sign',
            params: [message, did.split(':')[2]]
        });

        return {
            settings,
            signature,
            did,
            timestamp: Date.now()
        };
    }

    async verifySignature(signedData) {
        const { settings, signature, did } = signedData;
        const message = JSON.stringify(settings);
        const address = did.split(':')[2];

        const recovered = ethers.utils.verifyMessage(message, signature);
        return recovered.toLowerCase() === address.toLowerCase();
    }
}

Use Cases

  1. Settings-Ownership: Beweise, dass Settings von dir stammen
  2. Vertrauensnetzwerk: Importiere nur Settings von verifizierten DIDs
  3. Reputation: DID-basierte Bewertung von Settings-Qualität

🔄 Gun.js: P2P-Synchronisation

Was ist Gun.js?

Ein dezentrales, offline-first Graph-Datenbank-System mit Echtzei-Synchronisation.

Architektur

graph LR A[Alice Browser] <-->|P2P| B[Bob Browser] B <-->|P2P| C[Charlie Browser] C <-->|P2P| A A <-->|Backup| D[Relay Server 1] B <-->|Backup| E[Relay Server 2] C <-->|Backup| D style A fill:#E3F2FD style B fill:#E8F5E9 style C fill:#FFF3E0 style D fill:#F3E5F5 style E fill:#F3E5F5

Integration

// Gun initialisieren mit mehreren Peers
const gun = Gun({
    peers: [
        'https://relay1.communicationfinder.org/gun',
        'https://relay2.communicationfinder.org/gun',
        'https://relay3.communicationfinder.org/gun'
    ],
    localStorage: true, // Offline-First
    radisk: true        // Persistent Storage
});

// Settings publizieren
const user = gun.user();
await user.auth('username', 'password');

user.get('settings').get('current').put({
    data: encryptedSettings,
    timestamp: Date.now(),
    version: '2.0'
});

// Settings von anderen abonnieren
gun.get('communicationfinder')
   .get('public-settings')
   .map()
   .on((settings, key) => {
       if (settings && settings.timestamp > lastSyncTime) {
           mergeRemoteSettings(settings);
       }
   });

Konflikt-Auflösung

Gun nutzt CRDT (Conflict-free Replicated Data Types):

// Automatische Merge-Strategie
gun.get('settings').get('weights').get('whatsapp').put(85);
// Andere Node setzt gleichzeitig:
gun.get('settings').get('weights').get('whatsapp').put(90);

// Gun merged automatisch (Last-Write-Wins)
// Ergebnis: 90 (neuester Timestamp gewinnt)

📜 Arweave: Permanente Speicherung

Was ist Arweave?

Eine Blockchain für permanente Datenspeicherung – einmalige Zahlung, ewige Verfügbarkeit.

Integration

class ArweaveStorage {
    constructor() {
        this.arweave = Arweave.init({
            host: 'arweave.net',
            port: 443,
            protocol: 'https'
        });
    }

    async uploadPermanent(settings) {
        const wallet = await this.loadWallet();

        const transaction = await this.arweave.createTransaction({
            data: JSON.stringify(settings)
        }, wallet);

        // Tags für Searchability
        transaction.addTag('App-Name', 'CommunicationFinder');
        transaction.addTag('Content-Type', 'application/json');
        transaction.addTag('Version', '2.0');

        await this.arweave.transactions.sign(transaction, wallet);
        await this.arweave.transactions.post(transaction);

        return transaction.id; // Permanent Transaction ID
    }

    async downloadPermanent(txId) {
        const data = await this.arweave.transactions.getData(txId, {
            decode: true,
            string: true
        });
        return JSON.parse(data);
    }
}

Kostenmodell

  • Einmalige Zahlung: ~$0.01 per MB (Stand 2025)
  • Keine monatlichen Gebühren
  • Garantie: 200+ Jahre Speicherung

🌍 ENS & Unstoppable Domains

Menschenlesbare Adressen

Statt ipfs://QmXxx...communicationfinder.eth

// ENS Resolution
const provider = new ethers.providers.Web3Provider(window.ethereum);
const resolver = await provider.getResolver('alice.eth');
const contentHash = await resolver.getContentHash();

// contentHash = ipfs://QmYourSettingsCID
const ipfsCID = contentHash.replace('ipfs://', '');
const settings = await ipfsStorage.downloadSettings(ipfsCID);

Use Case

Alice teilt: "Importiere meine Settings von alice.eth"
ENS löst auf: ipfs://QmABC123...
IPFS lädt: alice-settings.json
Matrix importiert Settings

🔧 Cloudflare Workers: Edge Computing

Warum Edge Computing?

  • Niedrige Latenz: Code läuft nah beim User
  • Kostenlos bis 100k Requests/Tag
  • Keine Server-Verwaltung

Beispiel: Settings-Proxy

// Cloudflare Worker
addEventListener('fetch', event => {
    event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
    const url = new URL(request.url);
    const cid = url.pathname.split('/')[2];

    // Versuche IPFS-Gateways
    const gateways = [
        'https://ipfs.io/ipfs/',
        'https://cloudflare-ipfs.com/ipfs/'
    ];

    for (const gateway of gateways) {
        try {
            const response = await fetch(gateway + cid, {
                cf: { cacheEverything: true } // Cache am Edge
            });
            if (response.ok) {
                return response;
            }
        } catch {}
    }

    return new Response('Not found', { status: 404 });
}

📊 Dezentralisierungs-Scorecard

Komponente Zentralisiert Dezentral Status
Hosting GitHub Pages IPFS Gateway ✅ Phase 3
Storage LocalStorage IPFS + Arweave ✅ Phase 3
Identity Email/Password DIDs 🔄 Phase 3
Sync REST API Gun.js P2P 🔄 Phase 3
Compute Server Edge + WASM ✅ Jetzt
Domain DNS ENS 🔮 Phase 4

Dezentralisierungs-Score: 83% (Ziel: 95%)


🚀 Migrations-Roadmap

Phase 1: Statisch (Q4 2025) ✅

  • Offline HTML-Tools
  • LocalStorage
  • Keine Server

Phase 2: IPFS (Q1 2026)

// Settings zu IPFS hochladen
const cid = await ipfs.upload(settings);
console.log(`Deine Settings: ipfs://${cid}`);

// QR-Code generieren zum Teilen
const qr = generateQR(`ipfs://${cid}`);

Phase 3: DIDs (Q2 2026)

// DID erstellen
const did = await createDID();

// Settings mit DID signieren
const signed = await did.sign(settings);

// In IPFS publizieren
const cid = await ipfs.upload(signed);

Phase 4: P2P (Q3 2026)

// Gun.js Echtzeit-Sync
gun.get('communicationfinder')
   .get('team')
   .get('alice.eth')
   .on(settings => {
       console.log('Alice hat ihre Settings aktualisiert!');
       mergeSettings(settings);
   });

🎯 Vorteile für Nutzer

1. Kein Vendor-Lock

Google Drive ist down? → Settings auf IPFS weiter verfügbar
GitHub löscht Repo? → Code auf Arweave permanent
Slack API ändert sich? → Deine Settings unabhängig

2. Privacy

Zentral: Server sieht alle Daten
Dezentral: Nur du hast Zugriff (verschlüsselt)

3. Kosten

Zentral: $10-50/Monat Server-Kosten
Dezentral: $0 (User hostieren P2P)

Vision

"Keine einzelne Entität sollte Kontrolle über deine Kommunikations-Entscheidungen haben – weder technisch noch rechtlich."


← Zurück: Architektur Weiter: Technology Stack →