# Architecture Overview

***

### System Layers

The NONOS ecosystem consists of four interconnected layers:

```
╔═══════════════════════════════════════════════════════════════════════╗
║                         APPLICATION LAYER                             ║
║  ┌─────────────────────────────────────────────────────────────────┐  ║
║  │                          BROWSER                             │  ║
║  │  • Native WebView (Rust/Tauri)                                  │  ║
║  │  • Svelte UI Components                                         │  ║
║  │  • Integrated Wallet                                            │  ║
║  │  • Security Level Controls                                      │  ║
║  └─────────────────────────────────────────────────────────────────┘  ║
╠═══════════════════════════════════════════════════════════════════════╣
║                          SERVICE LAYER                                ║
║  ┌───────────────┐  ┌───────────────┐  ┌───────────────────────────┐  ║
║  │  ZK Identity  │  │  Cache Mixer  │  │    Tracking Blocker       │  ║
║  │    Service    │  │    Service    │  │       Service             │  ║
║  └───────────────┘  └───────────────┘  └───────────────────────────┘  ║
║  ┌───────────────┐  ┌───────────────┐  ┌───────────────────────────┐  ║
║  │    Health     │  │    Quality    │  │      Stealth Address      │  ║
║  │    Beacon     │  │    Oracle     │  │        Scanner            │  ║
║  └───────────────┘  └───────────────┘  └───────────────────────────┘  ║
╠═══════════════════════════════════════════════════════════════════════╣
║                          NETWORK LAYER                                ║
║  ┌─────────────────────────────────────────────────────────────────┐  ║
║  │                     P2P NETWORK (libp2p)                        │  ║
║  │  ┌─────────┐  ┌─────────┐  ┌─────────┐  ┌─────────────────────┐ │  ║
║  │  │Kademlia │  │GossipSub│  │  Noise  │  │  Yamux Multiplexing │ │  ║
║  │  │   DHT   │  │ Pub/Sub │  │Encryption│  │                    │ │  ║
║  │  └─────────┘  └─────────┘  └─────────┘  └─────────────────────┘ │  ║
║  └─────────────────────────────────────────────────────────────────┘  ║
╠═══════════════════════════════════════════════════════════════════════╣
║                        SETTLEMENT LAYER                               ║
║  ┌─────────────────────────────────────────────────────────────────┐  ║
║  │                    ETHEREUM MAINNET                             │  ║
║  │  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────────┐  │  ║
║  │  │  NOX Token  │  │   Staking   │  │      Reward Claims      │  │  ║
║  │  │   (ERC-20)  │  │  Contract   │  │        Contract         │  │  ║
║  │  └─────────────┘  └─────────────┘  └─────────────────────────┘  │  ║
║  └─────────────────────────────────────────────────────────────────┘  ║
╚═══════════════════════════════════════════════════════════════════════╝
```

***

### Component Overview

#### Application Layer

The **NOXONE Browser** is the user-facing application:

| Component  | Technology       | Purpose                        |
| ---------- | ---------------- | ------------------------------ |
| WebView    | Tauri (wry/tao)  | Native browser rendering       |
| UI         | Svelte           | Reactive interface components  |
| Wallet     | Rust (secp256k1) | Key management, signing        |
| IPC Bridge | `window.noxone`  | Frontend-backend communication |

***

#### Service Layer

**NONOS Daemon** provides cryptographic privacy services:

| Service          | Function                      | Technology             |
| ---------------- | ----------------------------- | ---------------------- |
| ZK Identity      | Anonymous authentication      | Poseidon Merkle trees  |
| Cache Mixer      | Privacy-preserving caching    | AES-GCM + Merkle       |
| Tracking Blocker | Block trackers/fingerprinting | Pattern matching       |
| Health Beacon    | Network liveness              | GossipSub broadcast    |
| Quality Oracle   | Performance metrics           | On-chain reporting     |
| Stealth Scanner  | Private payments              | Viewing key derivation |

***

#### Network Layer

**P2P Network** connects all nodes:

| Protocol  | Purpose             | Implementation       |
| --------- | ------------------- | -------------------- |
| Kademlia  | Peer discovery      | DHT routing          |
| GossipSub | Message propagation | Pub/sub topics       |
| Noise     | Encryption          | XX handshake pattern |
| Yamux     | Multiplexing        | Stream management    |
| Identify  | Peer info           | Protocol negotiation |

***

#### Settlement Layer

**Ethereum** handles economic settlement:

| Contract         | Address         | Function         |
| ---------------- | --------------- | ---------------- |
| NOX Token        | `0x0a26...9eCA` | ERC-20 token     |
| Staking Vault    | `0xD548...0423` | 32M NOX pool     |
| Staking Contract | TBA             | Stake management |

***

### Data Flow

#### Browser Request Flow

```
┌──────────┐     ┌──────────┐     ┌──────────┐     ┌──────────┐
│  Browser │────►│  NONOS   │────►│  Anyone  │────►│ Internet │
│   User   │     │  Daemon  │     │ Network  │     │  Target  │
└──────────┘     └──────────┘     └──────────┘     └──────────┘
     │                │                │                │
     │   1. Request   │                │                │
     │───────────────►│                │                │
     │                │  2. Privacy    │                │
     │                │  Processing    │                │
     │                │  (ZK, cache,   │                │
     │                │   trackers)    │                │
     │                │───────────────►│                │
     │                │                │  3. Onion      │
     │                │                │     Routing    │
     │                │                │  (Anyone Net)  │
     │                │                │───────────────►│
     │                │                │                │
     │                │                │  4. Response   │
     │                │                │◄───────────────│
     │                │  5. Process    │                │
     │                │◄───────────────│                │
     │   6. Display   │                │                │
     │◄───────────────│                │                │
```

> **Note**: NONOS Daemon handles privacy services (ZK identity, cache mixing, tracker blocking). Traffic routing is handled by Anyone Network.

***

#### Node Reward Flow

```
┌──────────────────────────────────────────────────────────────────┐
│                        REWARD CYCLE                              │
└──────────────────────────────────────────────────────────────────┘

┌─────────┐         ┌─────────────┐         ┌─────────────────────┐
│  Node   │────────►│   Metrics   │────────►│   Quality Score     │
│ Service │         │  Collector  │         │   Calculation       │
└─────────┘         └─────────────┘         └──────────┬──────────┘
                                                       │
                                                       ▼
┌─────────────────────────────────────────────────────────────────┐
│                         EPOCH END                               │
│                                                                 │
│   Quality Score = (Uptime × 0.30) + (Success × 0.35) +          │
│                   (Latency × 0.20) + (Reliability × 0.15)       │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                      REWARD CALCULATION                         │
│                                                                 │
│   Reward = EpochEmission × (√Stake / TotalWeight) ×             │
│            QualityScore × TierMultiplier × StreakBonus          │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────┐         ┌─────────────┐         ┌─────────────────────┐
│ Pending │────────►│    Claim    │────────►│   NOX Tokens in     │
│ Rewards │         │ Transaction │         │   User Wallet       │
└─────────┘         └─────────────┘         └─────────────────────┘
```

***

### Node Types

#### Full Node (Recommended)

Participates in all network functions:

```
┌─────────────────────────────────────────────────────────────────┐
│                         FULL NODE                               │
│                                                                 │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────────┐  │
│  │   Privacy   │  │   Network   │  │      Staking &          │  │
│  │  Services   │  │   Comms     │  │       Rewards           │  │
│  │             │  │             │  │                         │  │
│  │ • ZK ID     │  │ • DHT       │  │ • Stake NOX             │  │
│  │ • Mixer     │  │ • Gossip    │  │ • Earn Rewards          │  │
│  │ • Blocker   │  │ • Beacons   │  │ • Report Metrics        │  │
│  └─────────────┘  └─────────────┘  └─────────────────────────┘  │
│                                                                 │
│  Hardware: 4+ vCPU, 8GB+ RAM, 100GB+ SSD, 1Gbps+                │
│                                                                 │
│  Note: NONOS nodes do NOT route traffic. Traffic routing is     │
│        handled by Anyone Network (separate project).            │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘
```

***

#### Light Node

Browser-only, uses network services:

```
┌─────────────────────────────────────────────────────────────────┐
│                        LIGHT NODE                               │
│                                                                 │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │                    NOXONE BROWSER                           ││
│  │                                                             ││
│  │  • Connects to Full Nodes for services                      ││
│  │  • No staking required                                      ││
│  │  • Privacy through network, not operation                   ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  Hardware: Any modern computer/phone                            │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘
```

***

### Security Model

#### Trust Boundaries

<pre><code>┌─────────────────────────────────────────────────────────────────┐
│                      TRUST MODEL                                │
│                                                                 │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │                    TRUSTED                                │  │
│  │  • Your device                                            │  │
│  │  • Your keys (never leave device)                         │  │
│  │  • Open source code (auditable)                           │  │
│  └───────────────────────────────────────────────────────────┘  │
│                                                                 │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │                   TRUSTLESS                               │  │
│  │  • Individual nodes (cryptographic verification)          │  │
│  │  • ZK identity (proves membership without revealing ID)   │  │
│  │  • Rewards (smart contract enforced)                      │  │
│  └───────────────────────────────────────────────────────────┘  │
│                                                                 │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │                    ASSUMED                                │  │
│  │  • Ethereum consensus                                     │  │
│  │  • Cryptographic primitives                               │  │
│  │  • Majority of nodes honest                               │  │
│  └───────────────────────────────────────────────────────────┘  │
<strong>│                                                                 │
</strong>└─────────────────────────────────────────────────────────────────┘
</code></pre>

***

#### Cryptographic Guarantees

| Guarantee           | Mechanism          | Property                        |
| ------------------- | ------------------ | ------------------------------- |
| **Confidentiality** | Noise encryption   | Traffic unreadable to observers |
| **Integrity**       | BLAKE3 hashing     | Data tampering detected         |
| **Authentication**  | Ed25519 signatures | Node identity verified          |
| **Anonymity**       | ZK proofs          | Prove without revealing         |
| **Non-linkability** | Stealth addresses  | Payments unlinkable             |

***

### Integration Points

#### Browser ↔ Daemon

Local HTTP API on `localhost:8420`:

```
GET  /api/status          - Node status
GET  /api/metrics         - Performance metrics
GET  /api/privacy/stats   - Privacy service stats
POST /api/staking/stake   - Stake tokens
POST /api/rewards/claim   - Claim rewards
```

***

#### Daemon ↔ Network

GossipSub topics:

```
nonos/health        - Node liveness beacons
nonos/quality       - Quality metric reports
nonos/peers         - Peer discovery
nonos/announcements - New node registration
```

***

#### Daemon ↔ Ethereum

Smart contract calls via ethers-rs:

```rust
// Read operations
get_stake(address)
get_pending_rewards(address)
get_tier(address)

// Write operations
stake(amount)
unstake(amount)
claim_rewards()
set_tier(tier)
```

***

### Summary

| Layer           | Purpose            | Technology       |
| --------------- | ------------------ | ---------------- |
| **Application** | User interface     | Tauri + Svelte   |
| **Service**     | Privacy features   | Rust + ZK proofs |
| **Network**     | Decentralized mesh | libp2p           |
| **Settlement**  | Economic layer     | Ethereum         |

***

> **Next:** Learn about the Privacy Model or dive into Technical Architecture.
