# skepx/nillion-sync architecture

> Architecture diagram of the GitHub repository skepx/nillion-sync, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/skepx/nillion-sync
- Repository: https://github.com/skepx/nillion-sync

## Overview

##### Project Type & Purpose
- This is a secure communication/integration project where an initiator (Sync) and a responder (User) interact via a secure, decentralized, encrypted network.
- The project illustrates handling sensitive data through decentralized secure computation and local decryption on a User’s device (delivery node).

##### File Structure
- The project contains two main scripts: compute.py and offchain.py. These are likely to be the core modules handling the computation (integration with Nillion network) and off-chain processing respectively.

##### Core Components
a. Sync (Initiator):
- Represented as a component or service (possibly tied to compute.py) that starts the secure communication, triggers notifications, and interacts with Nillion.
b. User (Responder):
- This component creates a SyncID and attaches sensitive data. It should be depicted as a separate entity initiating the secure data generation.
c. Delivery Node (User’s Local Device):
- Depicted as the endpoint where local decryption occurs using the Sync mobile app. Clearly mark it as the “decryption endpoint.”
d. Nillion Decentralized Network:
- As the secure, decentralized, encrypted storage and computation engine, this component should be central. It handles data encryption, secure storage, and secret matching.
e. External Messaging Applications:

##### Depicting the Relationships and Data Flow
- The Sync component (via compute.py) triggers notifications or processing requests which are directed towards the Nillion network.

##### Architectural Patterns & Technologies
- Decentralization and local decryption principles for ensuring that sensitive data is processed securely.
- That there is a separation of concerns: one part handles initiation and secure computation (compute.py) while the other (offchain.py) might manage interactions that are not directly on-chain.
- Optionally, include notes about the role of Nillion’s infrastructure in facilitating trustless, encrypted communication.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    subgraph "User Interaction"
        User["User (Responder)"]:::responder
    end

    %% Network Security Layer
    subgraph "Network Security Layer"
        Network["Nillion Network (Decentralized Secure Storage & Computation)"]:::network
    end

    %% Sync and Offchain Modules
    subgraph "Sync & Offchain Modules"
        Sync["Sync (Initiator)"]:::script
        Offchain["Offchain Processing & Integration"]:::script
        Sync -->|"data/process"| Offchain
        Offchain -->|"response"| Sync
    end

    %% Delivery and Messaging
    subgraph "Delivery and Messaging"
        Delivery["Delivery Node (Local Device with Sync app)"]:::device
        External["External Messaging (WhatsApp/Telegram)"]:::messaging
    end

    %% Project Documentation
    subgraph "Project Documentation"
        Doc["Documentation (README)"]:::doc
    end

    %% Connections between layers
    User -->|"SyncIDCreation&DataAttachment"| Network
    Sync -->|"notificationTrigger"| Network
    Network -->|"secretMatching&Decryption"| Delivery
    Delivery -->|"messageDelivery"| External

    %% Click Events
    click Sync "https://github.com/skepx/nillion-sync/blob/main/compute.py"
    click Offchain "https://github.com/skepx/nillion-sync/blob/main/offchain.py"
    click Doc "https://github.com/skepx/nillion-sync/blob/main/README.md"

    %% Styles
    classDef responder fill:#ffdead,stroke:#000,stroke-width:2px;
    classDef network fill:#87cefa,stroke:#000,stroke-width:2px;
    classDef device fill:#98fb98,stroke:#000,stroke-width:2px;
    classDef messaging fill:#ffa07a,stroke:#000,stroke-width:2px;
    classDef script fill:#d3d3d3,stroke:#000,stroke-width:2px;
    classDef doc fill:#f0e68c,stroke:#000,stroke-width:2px;
```
