RootIB: RB-20260304210059-95D75935

# GravityNet — Apple Relay Mesh

> **Token:** `5XPRrteUXNp5qNjHYuXL8SsehYXmmgvZ5PvWV95Apump`  
> **Pump page:** <https://join.pump.fun/HSag/f4dnwcgm>  
> **Live demo:** <https://barbrickdesign.github.io/gravityNet.html>  
> **Creator:** Ryan Barbrick · BarbrickDesign@gmail.com  
> **RootIB:** RB-20260304210059-95D75935

---

## Overview

GravityNet turns Apple devices (Mac, iPhone, iPad) into compensated relay nodes for the **DeepSoil messaging mesh**.

Relay nodes:
- Route iMessage / SMS traffic through a local native bridge (not in-browser).
- Report telemetry to the mesh via a WebSocket control plane.
- Earn **GravityNet tokens** based on uptime, message throughput, and routing quality.

The front-end (`gravityNet.html`) is a single-file, static HTML app that:
- Registers and controls relay nodes.
- Displays live telemetry from the gravity coordinator backend.
- Connects a wallet for identity and payout tracking.
- Works entirely offline against the local stub coordinator.

---

## Quick Start

### Prerequisites

- [Node.js](https://nodejs.org/) ≥ 18
- `npm` (bundled with Node.js)
- A modern web browser

### 1. Clone

```bash
git clone https://github.com/barbrickdesign/barbrickdesign.github.io.git
cd barbrickdesign.github.io
```

### 2. Install

```bash
npm install
```

> **Note:** The coordinator only requires the `ws` package. If you haven't installed it yet:
>
> ```bash
> npm install ws
> ```

### 3. Run the coordinator

```bash
npm run gravity:dev
# OR directly:
node gravityNet-coordinator.js
```

The coordinator starts at `ws://localhost:4747/ws`.

### 4. Open the front-end

Open **`gravityNet.html`** in your browser:

```bash
# macOS
open gravityNet.html

# Or serve via any static file server:
npx serve .
# Then navigate to http://localhost:3000/gravityNet.html
```

`gravityNet.html` automatically detects `localhost` / `127.0.0.1` and connects to
`ws://localhost:4747/ws`. You should see live dummy telemetry within seconds.

---

## Project Structure

| File | Description |
|------|-------------|
| `gravityNet.html` | Single-file front-end (all JS inline, no external deps at runtime) |
| `gravityNet-coordinator.js` | Node.js WebSocket coordinator stub |
| `gravityNet-README.md` | This file |
| `gravityNet-protocol.md` | JSON message schema reference |

---

## Architecture

```
┌─────────────────────┐       WebSocket (JSON)      ┌───────────────────────┐
│  gravityNet.html    │ ◄────────────────────────► │  gravity coordinator  │
│  (browser)          │       ws://host:4747/ws     │  (Node.js stub)       │
└─────────────────────┘                             └───────────────────────┘
       │ control plane only                                │
       │ (no direct iMessage access)                       │ in-memory relay state
       │                                                   │ periodic telemetry
       ▼                                                   ▼
  Register relay                                  Real integration:
  Toggle relay on/off                             - DeepSoil Solana program
  Connect wallet                                  - Apple native bridge
  View earnings & metrics                         - iMessage/SMS router
```

The browser handles **only** the control plane and telemetry display. All native
Apple messaging operations (iMessage, SMS) happen in a separate native bridge process
that is out of scope for this stub.

---

## How Rewards Are Intended to Work

> **Design-level description — payouts are not yet live.**

Relay operators earn **GravityNet tokens** based on three factors:

### 1. Uptime Score
- Relays earn a base rate proportional to the total seconds they are online.
- Formula: `uptime_score = uptimeSeconds / targetPeriodSeconds`

### 2. Messages Routed
- Each successfully relayed message increments a counter.
- High-throughput relays earn a multiplier on top of their uptime score.
- Formula: `throughput_multiplier = log10(messagesRouted + 10) / log10(10)`

### 3. Routing Score (Quality)
- The coordinator grades each relay 0–100 based on latency, drop rate, and peer connectivity.
- Formula: `quality_factor = routingScore / 100`

### Combined Formula

```
relay_earnings = base_rate × uptime_score × throughput_multiplier × quality_factor
```

Payouts are sent **periodically** (e.g. daily) to the configured **payout address**
for each relay. The payout address can be any supported chain address; initially Solana
(to align with the GravityNet token on pump.fun).

### Token Details

| Field | Value |
|-------|-------|
| Token address | `5XPRrteUXNp5qNjHYuXL8SsehYXmmgvZ5PvWV95Apump` |
| Chain | Solana |
| Pump.fun page | <https://join.pump.fun/HSag/f4dnwcgm> |
| Ticker | `GRA` |

---

## How to Run a Relay

1. Install GravityNet coordinator (see Quick Start above).
2. Open `gravityNet.html` in your browser.
3. Fill in:
   - **Relay ID** — a unique, human-readable name (e.g. `orchard-nyc-mbp-01`).
   - **Device Type** — Mac, iPhone, iPad, or Other.
   - **Capacity Tier** — Light / Standard / Heavy.
   - **Payout Address** — your Solana wallet address for token rewards.
4. Click **Register / Update Relay**.
5. Click **Relay: Stopped** to toggle the relay ON.
6. Watch the metrics and logs update in real time.

In production, the coordinator will also spawn (or communicate with) the
**Apple native bridge** process that handles actual iMessage / SMS routing.

---

## WebSocket Protocol

See [gravityNet-protocol.md](gravityNet-protocol.md) for the complete message schema.

Short summary:

| Direction | Type | Purpose |
|-----------|------|---------|
| Browser → Coordinator | `registerRelay` | Register or update a relay node |
| Browser → Coordinator | `toggleRelay` | Start or stop a relay |
| Browser → Coordinator | `walletLinked` | Notify coordinator of a connected wallet |
| Coordinator → Browser | `relayStatus` | Current relay metrics |
| Coordinator → Browser | `earningsUpdate` | Token earnings summary |
| Coordinator → Browser | `deepSoilLink` | DeepSoil node ID assignment |
| Coordinator → Browser | `log` | Log entry for relay or mesh scope |

---

## License

MIT — see `LICENSE` in the repository root.

---

## Contact

Ryan Barbrick · BarbrickDesign@gmail.com  
AI Assistant: Merlin AI  
© 2008–2026 Barbrick Design
