# rSpace

A composable, local-first platform for collaborative knowledge work, democratic governance, and programmable economic flows.

**Live at [rspace.online](https://rspace.online)**

## What is rSpace?

rSpace is an integrated suite of 35+ collaborative applications ("rApps") built on shared digital primitives — identity, encrypted CRDT data, micropayments, and AI — that gain power through composition on an infinite spatial canvas.

Every rApp works offline-first. Data lives on your device as Automerge CRDTs, encrypted per-document. The server is a sync peer, not a gatekeeper. Identity is a single passkey tap — no passwords, no seed phrases.

## Architecture

```
rStack (Foundation)  — Identity, CRDT sync, payments, encryption
rSpace (Platform)    — Spaces, infinite canvas, module composition
rApps  (Modules)     — 35+ apps that compose on the canvas
```

## Digital Primitives

These are the building blocks that all rApps share and compose:

**EncryptID** — Self-sovereign identity via WebAuthn passkeys. One biometric tap derives encryption keys (AES-256-GCM), a DID identity (Ed25519), and a crypto wallet (secp256k1). Social recovery via threshold guardian approval. No passwords or seed phrases, ever.

**Local-First Data** — 7-layer Automerge CRDT stack. All data encrypted client-side before sync. Conflict-free offline editing with automatic merge on reconnect. The server stores only ciphertext.

**x402 Micropayments** — HTTP 402 as a first-class protocol. Any endpoint can require payment. Passkey-derived wallet signs transactions on L2 rollups (~$0.001/tx). No MetaMask popup required.

**CRDT Tokens** — Automerge-based token ledger (cUSDC, $MYCO) with bonding curve dynamics. Instant, free, off-chain transfers that settle to L2 when needed.

**Spatial Canvas** — FolkJS web components on an infinite 2D canvas. Modules render as positioned shapes that can be connected, nested, and linked.

**On-Demand Sidecars** — Docker containers (Ollama, KiCad, FreeCAD, Blender, Scribus) start on first API call and stop after 5 minutes idle. Saves ~8GB RAM when not in use.

**IPFS Pinning** — Generated files auto-pinned to Kubo with `.cid` sidecar files. Encrypted backups also pinned for redundancy.

## rApps

### Information & Documents

| App | Description |
|-----|-------------|
| **rNotes** | Rich-text notebooks with voice transcription, code blocks, file attachments, and Notion/Google Docs sync |
| **rPubs** | Markdown to print-ready pocket books via Typst compilation |
| **rBooks** | Community PDF library with flipbook reader |
| **rFiles** | File sharing with time-limited links, password protection, and Memory Cards for cross-module data interchange |
| **rData** | Privacy-first analytics (cookieless, self-hosted Umami) |

### Planning & Coordination

| App | Description |
|-----|-------------|
| **rCal** | Calendar with lunar/solar/seasonal systems, group scheduling, location-aware events, and spatio-temporal coupling with rMaps |
| **rMaps** | Real-time location sharing with OSM tiles, indoor routing (c3nav), privacy controls (precision fuzzing, ghost mode), and push notifications |
| **rTrips** | Collaborative trip planner with itinerary, routing, expenses, and packing lists |
| **rTasks** | Kanban boards with ClickUp bi-directional sync |
| **rSchedule** | Cron-based job scheduling — emails, webhooks, calendar events, broadcasts, workflow nodes |

### Communication

| App | Description |
|-----|-------------|
| **rInbox** | Collaborative email with shared mailboxes, threaded comments, and Gnosis Safe multisig approval for outgoing mail |
| **rMeets** | Video meetings (Jitsi) with recording transcription and search |
| **rSocials** | Federated social feed — multi-platform posting via Postiz, newsletters via Listmonk, AI content generation |
| **rForum** | One-click self-hosted Discourse forum deployment with Cloudflare DNS auto-provisioning |

### Democratic Governance

| App | Description |
|-----|-------------|
| **rVote** | Conviction voting with credit-weighted decay, ranked proposals, ELO scoring, and delegative trust flows (liquid democracy) |
| **rChoices** | Polls, ranked lists, and multi-criteria spider plots as canvas shapes |
| **rGov** | Modular governance circuits — signoff gates, resource thresholds, tunable knobs, amendable decision flows |
| **CrowdSurf** | Swipe-based activity coordination with commitment thresholds — triggers when enough people join |

### Economic & Financial

| App | Description |
|-----|-------------|
| **rWallet** | Multi-chain Safe wallet viewer with CoinGecko prices, Zerion DeFi positions, CRDT token balances, bonding curve swap UI, and fiat on/off-ramp |
| **rFlows** | Budget river visualization, Openfort smart accounts, outcome tracking, community budgeting with "enoughness" thresholds |
| **rExchange** | P2P crypto/fiat exchange with intent matching, escrow settlement, and reputation tracking |
| **rTime** | Timebank commitment pool — visualizes hour pledges as floating orbs, weaves commitments into tasks with skill-curve matching |
| **rCart** | Group shopping and cosmolocal print-on-demand shop with multi-currency checkout |
| **rNetwork** | Community relationship graph (3D force-directed) with CRM sync and trust visualization |

### Creative & Media

| App | Description |
|-----|-------------|
| **rDesign** | AI-powered desktop publishing — Scribus via noVNC with a Gemini agent that drives the layout |
| **rSwag** | Design print-ready stickers, posters, and tees with dithering, color separation, and fulfillment routing |
| **rPhotos** | Community photo commons (Immich-backed gallery) |
| **rTube** | Video hosting and HLS live streaming via Cloudflare R2 |
| **rSplat** | 3D Gaussian splat viewer for `.ply`/`.splat`/`.spz` files |

### Sharing Economy

| App | Description |
|-----|-------------|
| **rBnb** | Trust-based hospitality and space sharing — gift economy as a first-class option |
| **rVnb** | Peer-to-peer camper and RV rentals with trust, endorsements, and configurable economy models |

### AI Services

The platform integrates multiple AI providers as composable canvas shapes:

- **Gemini** — CAD orchestration (drives KiCad/FreeCAD via MCP tool-calling), design agent, zine generation, image generation
- **Ollama** — Local inference (llama3, qwen-coder, mistral) via on-demand sidecar
- **fal.ai** — Flux Pro image gen, WAN 2.1 text-to-video, Kling image-to-video
- **LiteLLM** — Unified proxy across 9 models

## Tech Stack

- **Runtime**: Bun + Hono
- **Frontend**: Lit web components (FolkJS) + Vite
- **Data**: Automerge CRDT with AES-256-GCM encryption
- **Identity**: WebAuthn PRF + HKDF key derivation
- **Payments**: x402 + ethers.js + Gnosis Safe SDK
- **Infrastructure**: Docker + Traefik + Cloudflare Tunnel
- **AI**: Gemini SDK, Ollama, fal.ai, LiteLLM

## Development

```bash
bun install
bun run dev
```

Requires Bun 1.1+. See `ONTOLOGY.md` for detailed architecture documentation.

## License

All rights reserved.
