# DreamStack — Vision & Use Cases > **Core insight**: DreamStack turns UI into a streamable binary protocol. > Any `.ds` app becomes multiplayer with one line. No networking code. No database sync. > Just `stream main on url { mode: signal }`. --- ## The Paradigm Shift Today, a UI is a **program** running on your device. With DreamStack's bitstream, a UI is a **signal stream** — writable by any source, receivable by any surface, composable, replayable, and physics-native. | Traditional | DreamStack | |---|---| | App runs on one device | Signal stream renders on N surfaces | | Multiplayer = WebSocket + state sync + conflict resolution | Multiplayer = one `stream` declaration | | Screen sharing = compressed pixels | State sharing = signal diffs (10-100x smaller) | | Session replay = specialized SDK | Session replay = just record the bitstream | | Physics = external library | Physics = built-in WASM engine, state streamed | --- ## The Five Primitives DreamStack's full vision combines five independent primitives into something that doesn't exist yet: | Primitive | Role | |---|---| | **DreamStack bitstream** | UI as a streamable signal protocol | | **Iroh P2P** | Zero-infrastructure device mesh | | **Local LLM** | On-device intelligence, fully private | | **Solana NFT** | Ownership, identity, payments | | **PgFlex** | Schemaless, real-time, zero-config database | Each is powerful alone. Combined, they produce **a portable, tradeable, self-sovereign software company — minted as a single NFT**. --- ## Part 1 — Fundamental UI Redesigns ### 1. Ambient UI — App Without a Device A `.ds` app runs once (server, edge, or one browser). Its signal stream renders on every available surface simultaneously: - **Phone** shows controls (buttons, sliders) - **Laptop** shows detail view (data, forms) - **TV** shows visualization (charts, physics) - **Watch** shows status (alerts, counts) This isn't responsive design (same app adapting). It's **one signal graph, many renderers**. Each surface subscribes to the signals it cares about and renders at its own resolution and frame rate. **Why it matters**: Apps stop being "installed things" and become ambient services that appear on whatever screen is nearest. #### Universal Receiver Spectrum The simplest device that can accept a DreamStack stream needs only: a socket client, 16-byte header parsing, and any output surface. | Device | What it consumes | Cost | |--------|-----------------|------| | **ESP32 + LED** | Signal frames only (`0x30`/`0x31`) — ~20 lines MicroPython | ~$4 | | **Raspberry Pi + e-ink** | Signal frames → text render | ~$15 | | **Any browser tab** | All 6 frame types (zero-framework HTML receiver) | Free | | **Phone / tablet** | All frames + touch/pointer input back | Free | | **Smart display** | Full bidirectional + physics | ~$100 | A signal-mode stream sending `{"brightness": 0.7}` is trivially parseable even on a microcontroller. The source decides the *meaning*, the receiver decides the *manifestation*. ### 2. Time-Travel Interfaces Every signal diff is a timestamped binary frame. Record the stream → complete session recording. Scrub to any point. Fork from any moment into a new interactive session. - **Bug reporting**: User reports a bug → replay their exact session, scrub to the problem, fork it, debug live - **Tutorials**: Record an interactive tutorial — viewers replay it at their own pace, with full interactivity - **Undo/redo**: Unlimited, branching undo — fork from any point in history - **Analytics**: Replay user sessions to understand behavior (not heatmaps — actual interactive replays) ### 3. UI Composition via Signal Mixing ``` source weather_api | layout dashboard | render tv ``` Take a data signal stream from a weather API. Take a layout signal from a design tool. Take interaction signals from a game controller. Merge them into one renderer. - **Dashboards**: Compose N data sources into one view without backend - **Mashups**: Overlay a chat stream on a video stream on a data stream - **Customization**: Users pick their own layout for someone else's data **Why it matters**: UI becomes composable like Unix pipes. ### 4. Zero-Install Instant Apps The receiver doesn't need the app code. It just decodes the bitstream and renders. Connect to `ws://app.example.com/stream/main` and the full interactive UI appears. Close the tab, it's gone. - No download, no permissions, no App Store - The app "lives" on the source — viewers are just windows into it - Updates are instant — the source changes, all viewers see it immediately - Works on any device with a bitstream receiver ### 5. Physics-Native Interaction With `ds-physics` baked into the language, UI elements aren't positioned — they're simulated. - Drag a panel → it continues with momentum - Throw a card → it bounces off other cards - Pinch a stack → items push apart with spring forces - Resize a container → content flows like water The physics state streams like any other signal. Multiple users can interact with the same physics world simultaneously. --- ## Part 2 — Iroh P2P: Zero-Infrastructure Streaming Adding Iroh P2P to the bitstream protocol removes the relay server entirely and opens use cases that centralized infrastructure cannot serve. | | WebSocket Relay | WebRTC | **Iroh P2P** | |---|---|---|---| | Discovery | Needs known URL | Needs signaling server | **Content-addressed (hash)** | | NAT traversal | N/A (server) | ICE/STUN/TURN | **Built-in holepunching** | | Topology | Star (relay center) | Peer pairs | **Mesh / swarm** | | Offline-first | ❌ | ❌ | **✅ (local-first sync)** | | Identity | URL-based | Session-based | **Cryptographic (public key)** | | Persistence | Relay must stay up | Connection must stay open | **Content persists in network** | ### Key Use Cases **Zero-Infrastructure Streaming** — A teacher in a classroom with no internet runs a live `.ds` lesson to 30 student tablets over LAN via mDNS discovery. No server. No URL. No relay cost. **Persistent Bitstream Archives** — A recorded bitstream session becomes a content hash. Anyone with the hash fetches and replays it from the swarm. Bug reports, tutorials, session replays — all just 32-byte hashes. No replay server. **Mesh Multiplayer** — N peers form a gossip mesh instead of routing through a star topology. If one person drops, the others keep going. Latency drops (direct paths instead of relay bounce). **Offline-First + Sync-on-Reconnect** — Device goes offline, accumulates signal diffs locally, reconnects → Iroh syncs missing state automatically. Field workers, IoT sensors, home displays — all work disconnected and reconcile on reconnect. **Cryptographic Identity** — Every Iroh node has a public key. Zero-config auth: only whitelisted keys can subscribe to your stream. No API keys, no OAuth. --- ## Part 3 — Local LLM: Intelligent Ambient UI Combining DreamStack + Iroh + local LLM inference produces intelligent, private, serverless computing that renders on any surface. ### The AI That Lives in the Room A single device (NUC, Mac Mini, laptop) runs a local LLM and joins the Iroh mesh. Every surface in the house receives its signal stream. - Speak to **any screen** → voice input through the mesh → local LLM processes → response streams as signal diffs to **every surface** - Kitchen display shows the recipe. Phone shows the shopping list. TV shows the tutorial video. **One inference, N renderers.** - All private. Nothing leaves the network. Ever. ### Distributed Inference Swarm Multiple devices in the mesh each run small models. The signal protocol coordinates them: - Phone runs a fast model for intent detection - Desktop runs a large model for generation - No orchestration server. Models discover each other via Iroh. - **LLM inference becomes a mesh protocol.** ### Self-Organizing Smart Spaces The LLM observes signal streams flowing through the mesh and adapts the UI: - Sees calendar signals → "Meeting in 10 minutes" → pushes notification to watch - Sees IoT sensor signals → generates natural-language summary → nearest display - Learns patterns → proactively streams control signals No IFTTT. No Home Assistant rules. The LLM **is** the automation engine, DreamStack **is** the I/O bus. ### Private AI Tutor Teacher runs a `.ds` physics simulation. Students interact via tablets (touch inputs stream back through Iroh mesh). A local LLM watches each student's interaction stream and generates personalized hints. The hints stream as signal diffs only to that student's device. **Adaptive tutoring. Zero cloud. Works offline in rural schools.** ### Conversational Database (with PgFlex) The local LLM watches PgFlex's SSE change stream and builds understanding: - "Top 3 products last week?" → LLM generates PostgREST query → PgFlex returns → DreamStack renders - "Alert me when inventory < 50" → LLM creates computed field + threshold → SSE fires when triggered - PgFlex's schemaless nature means the LLM can create new fields on the fly - **The LLM becomes a database architect that responds to natural language** | Without LLM | With Local LLM | |---|---| | Streams carry **data** | Streams carry **meaning** | | Surfaces **render** signals | Surfaces **understand** signals | | Users **configure** automations | The system **infers** intent | --- ## Part 4 — Content-Addressed UI Distribution This is where all primitives converge into the most radical departure from traditional software distribution. ### Two Layers of Hash | Layer | What | Analogy | |---|---|---| | **App hash** | Compiled `.ds` code (static artifact) | Torrent of an executable | | **Stream topic** | Live signal state (running instance) | Joining a live game server | When you share `ds:bafk2bza...`, the receiver: 1. **Fetches the app code** from the swarm (content-addressed, cached, verified) 2. **Joins the live stream** from the source (signal diffs, real-time state) You're not distributing a file. **You're distributing a running application.** ### Why It Matters **Link rot / platform risk** — A content-addressed app cannot go offline unless every peer disappears. No Vercel dependency. No AWS bill surprise. No domain expiration. **Distribution without gatekeepers** — App Store takes 30%. A `.ds` app distributed via hash has zero distribution cost and zero gatekeepers. The app doesn't need to be "installed" — the receiver just decodes the bitstream. **Instant, zero-trust sharing** — Today: URL → DNS → load JS → hydrate → render (2-5 seconds). With hash: peer already has the bundle cached → stream connects → UI appears (~100ms). **Versioning is automatic** — v1.0 = hash `abc123`, v1.1 = hash `def456`. Both exist simultaneously in the swarm. No deployment. No rollback scripts. Users can pin a version. Developers publish updates without breaking existing users. --- ## Part 5 — Solana NFT: App Ownership On-Chain A compiled `.ds` app is small — signal-mode apps are a reactive state graph plus view declarations. Compiled, that's kilobytes. Small enough to store on-chain. ### The NFT Structure ``` ┌─────────────────────────────────────────┐ │ Solana NFT (Metaplex Core) │ │ │ │ metadata: { name, creator, version } │ │ appData: │ │ stream: │ │ dbConfig: text "{order.customer}: ${order.total}" ] stream dashboard on iroh { topic: "dashboard" } ``` Database changes → PgFlex SSE → DreamStack signals → Iroh mesh → every screen updates. **No API layer. No polling. No frontend state management.** ### Why Not Automerge / CRDTs? CRDTs (like Automerge) solve concurrent uncoordinated writes with no central authority. PgFlex doesn't need them because **no layer in this architecture produces that problem**: ``` Layer Sync mechanism Conflicts? ──────────────────────────────────────────────────────── DreamStack signals Version map + diffs No — single source per stream PgFlex writes PostgreSQL transactions No — single DB is authority PgFlex reads ElectricSQL shapes No — read-only replication Iroh P2P Content-addressed blobs No — immutable by hash ``` PgFlex's natural topology is **single-writer**: one PostgreSQL instance per deployment (home, school, hospital). Within that deployment, PostgreSQL handles write ordering via transactions. ElectricSQL handles read replication to edge devices. SSE pushes change notifications. No write contention occurs. For offline scenarios (two peers editing state while disconnected), the conflict resolution happens **in the signal layer, not the database layer**: ``` Peer A ──signals──→ DreamStack merge ←──signals── Peer B │ resolved state │ PgFlex (just persists) ``` DreamStack's signal protocol reconciles on reconnect (last-write-wins per signal, using version maps). PgFlex materializes whatever the signal graph settles on. Adding Automerge would be a redundant conflict resolution layer between two systems that already don't produce conflicts. > [!NOTE] > If PgFlex-to-PgFlex replication across sites is ever needed, the answer is > PostgreSQL logical replication + custom conflict handlers — not Automerge. > Stay in the PostgreSQL ecosystem. --- ## Revenue-Generating Applications ### Tier 1: High Conviction — Clear Buyer, Clear Budget #### A. Private AI Appliance for Regulated Industries **Buyer**: Hospitals, law firms, financial advisors, government agencies **Budget they already spend**: $50K-500K/year on HIPAA/SOC2-compliant cloud AI **The product**: A box (Jetson/NUC) running local LLM + DreamStack + PgFlex. Plug into the network. Every screen in the facility gets AI — medical record summaries on the doctor's tablet, appointment prep on the wall display, billing codes on admin screen. Zero data leaves the building. **Why they pay**: Compliance. They *can't* use ChatGPT for patient data. Local LLM solves this. DreamStack solves multi-surface delivery. PgFlex stores patient data locally. **Revenue**: Hardware ($500-2000) + annual software license ($2K-10K/yr) **Market**: Healthcare IT alone is $400B. Even 0.001% = $4M. **Moat**: Multi-surface streaming. Competitors sell "local LLM in a box" but output is one terminal. DreamStack makes it ambient. #### B. Live Education Platform **Buyer**: School districts, edtech resellers, corporate training departments **Budget they already spend**: $5-15/student/year on Nearpod, Pear Deck, Kahoot **The product**: Teacher runs interactive simulations on their laptop. Students connect from any device — Chromebook, iPad, phone. Over LAN via Iroh when internet is down. Local LLM provides per-student adaptive hints. **Why they pay**: Current tools are glorified PowerPoint with polls. DreamStack delivers actual interactive simulations + works offline (huge for rural schools). **Revenue**: $8/student/year (undercut Nearpod at $15) **Market**: 50M US K-12 students × $8 = $400M TAM **Moat**: Physics-native simulations over bitstream. Offline-via-Iroh is a killer feature for school procurement. ### Tier 2: Strong Signal — Needs Validation #### C. Full-Stack NFT Marketplace **Buyer**: Solo developers, indie SaaS builders, agencies **Budget**: Currently $0 (new market) or $20-100/mo on hosting **The product**: `ds publish --solana` mints your app as a tradeable NFT. Buyers get a complete, deployable, intelligent app with persistent storage. Developers earn royalties on secondary sales. | What you sell | What the buyer gets | Price range | |---|---|---| | CRM NFT | App + PgFlex schema + LLM customer insights | 10-50 SOL | | Analytics Dashboard NFT | Real-time dashboard + data layer + anomaly detection | 5-20 SOL | | Inventory Tracker NFT | Multi-surface inventory + auto-reorder via LLM | 20-100 SOL | | Custom App (commissioned) | Bespoke `.ds` app minted for one client | 100+ SOL | **Revenue**: Transaction fees (2.5% of NFT sales) + pinning service **Moat**: The NFT isn't a JPEG — it's a running application. Utility value, not speculative. #### D. DreamStack Registry (ds.run) **The product**: `ds publish` → app gets a content hash. Anyone with the hash fetches and runs it from the swarm. | Tier | What | Price | |---|---|---| | **Free** | Publish to swarm (ephemeral, lives as long as peers have it) | $0 | | **Pin** | Permanent peers keep your app alive 24/7 | $5/app/month | | **Pro** | Pin + custom domain + analytics + `ds.run` web gateway | $20/month | | **Enterprise** | Private registry, SSO, audit log, SLA | $200/month | The web gateway `ds.run/hash` opens the app in a browser via the WASM receiver. Lets you share apps with people who don't have DreamStack yet. **Moat**: The hash isn't just code — it includes the live stream topic. Pinned apps are running, interactive, multiplayer applications. IPFS = static files. Vercel = static sites. DreamStack Registry = live interactive apps as hashes. #### E. Relay-as-a-Service **Buyer**: SaaS developers building collaborative features **Budget**: $0.10-1.00/concurrent connection/month on Liveblocks **The product**: `npm install dreamstack` → add one `stream` declaration → instant multiplayer. Hosted relay + Iroh P2P fallback. **Revenue**: Usage-based, $0.05/connection/month **Moat**: Signal-graph-aware sync (not generic pub/sub), binary efficiency, P2P fallback = lower infrastructure cost #### F. IoT / Operations Dashboard **Buyer**: Factory floor managers, DevOps teams, operations centers **Budget**: $15-50/user/month on Grafana Cloud, Datadog **The product**: Sensor data streams via Iroh mesh to any screen. Local LLM adds anomaly detection + natural language alerts. No cloud egress fees. **Revenue**: $20/source/month **Moat**: Binary efficiency + P2P = massive cost savings at scale --- ## Go-to-Market Sequence ``` Phase 1 (NOW → 3 months): Open-source the protocol + relay. Ship the "Collaborative Step Sequencer" demo. → Developer attention + GitHub stars. Phase 2 (3-6 months): Relay-as-a-Service (E). → First revenue, proves developer demand. → Low cost to operate (already built). Phase 3 (6-12 months): Education Platform (B) + ds.run Registry (D). → Pick one school district, pilot it. → Add local LLM hints as differentiator. → Registry grows alongside open-source adoption. Phase 4 (12-18 months): Private AI Appliance (A) + NFT Marketplace (C). → Partner with healthcare IT reseller. → Hardware margin + recurring license. → NFT marketplace leverages existing Solana ecosystem. ``` **Through-line**: DreamStack's moat is **multi-surface + binary efficiency + P2P**. Every product must lean into all three. If a product only needs one, someone else will eat your lunch. --- ## Demo Prioritization | Demo | Effort | Wow Factor | Revenue Signal | |------|--------|------------|----------------| | Collaborative Step Sequencer | 1 day | ⭐⭐⭐⭐⭐ | Relay-as-a-Service | | Two-Tab Synced Counter | 1 hour | ⭐⭐⭐ | — | | Physics Playground | 2 days | ⭐⭐⭐⭐ | Education | | Collaborative Whiteboard | 2 days | ⭐⭐⭐⭐ | Design Tool | | ESP32 Signal Receiver | 1 day | ⭐⭐⭐⭐ | IoT / Ambient UI | | Session Replay Viewer | 3 days | ⭐⭐⭐ | Analytics | | NFT-Minted App + ds.run | 3 days | ⭐⭐⭐⭐⭐ | NFT Marketplace | | Multi-Surface Dashboard | 1 week | ⭐⭐⭐⭐⭐ | IoT/Operations | **Recommended first demo**: Collaborative Step Sequencer. It's visual, temporal, interactive, and multiplayer — proving the entire stack in the most visceral way possible. Two browser tabs, one beat grid, instant sync, zero networking code. **Killer demo for NFT vision**: Publish a step sequencer as a content hash. Share it in a tweet. Anyone who clicks the `ds.run/hash` link instantly joins the live session — no account, no install, no server. 50 people making music together from a 32-byte hash. --- ## Technical Foundation (Complete) All infrastructure is built and tested: - ✅ **Bitstream protocol**: 16-byte binary header, 6 frame types - ✅ **Relay v1.0.0**: Multi-source routing, keyframe cache, channel GC, max receivers, source reconnection, 54 tests - ✅ **WASM codec**: Shared Rust↔browser encoding (18KB) - ✅ **WebRTC transport**: Peer-to-peer data channels with auto-fallback - ✅ **Compiler integration**: `stream` keyword, `stream from` expression, `transport: webrtc` option - ✅ **Receiver protocol**: All 6 frame types, RLE decode, exponential backoff - ✅ **PgFlex**: Schemaless PostgreSQL, PostgREST, SSE, ElectricSQL — 110 tests - ✅ **110+ tests, 0 failures** ### Primitives Still Needed - ⬜ **Iroh P2P transport**: Replace WebSocket relay with Iroh mesh - ⬜ **`ds publish`**: Mint `.ds` app as Solana NFT - ⬜ **`ds run sol:ADDRESS`**: Fetch + boot from on-chain bytecode - ⬜ **ds.run gateway**: Web gateway for content-addressed apps - ⬜ **NFT-gated stream auth**: Check wallet ownership before allowing connection - ⬜ **PgFlex signal bridge**: SSE → DreamStack signal graph - ⬜ **Local LLM integration**: Model loading + signal-based I/O --- ## Part 7 — Impossible Use Cases (Enabled by 44KB Output) > The JS output optimizations (DOM helpers, tree-shaking, minification) reduced > compiled DreamStack apps to **44KB** (~8KB gzipped). At this size, an interactive > application crosses a threshold: **it stops being infrastructure and becomes data.** > Data can travel through streams, live on-chain, or be generated on the fly. ### 1. Frame-Zero Self-Propagating Apps **The insight**: The app is small enough to be sent through its own data stream. ``` ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ Source │ │ Relay │ │ Browser │ │ (Pi, laptop) │ │ (any relay) │ │ (viewer) │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ FRAME 0: full HTML │ │ │ (44KB compiled app) │ │ │───────────────────────>│ caches it │ │ FRAME 1: {temp: 72.4} │ │ │───────────────────────>│ │ │ │ Someone opens URL │ │ │<──────── GET /s/a8f3c │ │ │ serves FRAME 0 │ │ │───────────────────────>│ renders app │ │ WS auto-connects │ │ │<──────── upgrade ──────│ │ FRAME N: {temp: 73.1} │ │ │───────────────────────>│───────────────────────>│ live update ``` One command: `dreamstack stream sensors.ds --bootstrap` One URL: `https://relay.dreamstack.dev/s/a8f3c` No CDN, no hosting, no separate frontend deployment. **Why impossible today**: React (200KB+) is too large to push through a WebSocket. Firebase/Supabase require pre-deployed frontends. No existing framework can travel through its own data channel. ### 2. Solana Accounts as Reactive Signal Sources **The insight**: DreamStack signals map directly to on-chain state. The wallet balance IS a reactive signal. A transfer IS a signal mutation. **The blockchain replaces the relay server.** This is NOT "store HTML on-chain" (anyone can do that). The signals themselves are sourced from on-chain state. The app reads its state FROM the blockchain and writes state BACK via transactions. ``` User clicks "Send 0.5 SOL" │ ├─→ balance signal reacts ├─→ buildTransaction(transfer(recipient, 0.5 SOL)) ├─→ wallet.signAndSend(tx) ← Phantom popup │ ▼ Solana validators confirm (~400ms) │ ├─→ accountSubscribe fires: balance changed ▼ Sender's UI: balance spring-animates down Recipient's UI: balance spring-animates up Both update with zero infrastructure between them ``` **Zero infrastructure.** No relay, no WebSocket server, no database. The blockchain IS the pub/sub layer, the state store, and the audit log. | What you'd need | React + Firebase | **DreamStack + Solana** | |---|---|---| | Frontend hosting | Vercel ($20/mo) | **On-chain ($0.12 once)** | | Real-time sync | Firebase ($25/mo)| **accountSubscribe (free)** | | Backend server | Cloud Functions | **None** | | Audit log | Build it yourself| **Solana Explorer** | | Total infra | 3-4 services | **0 services** | **Why impossible today**: No frontend framework has a signal system that maps to Solana account bytes. React/Vue call the chain — the chain doesn't push state back reactively. DreamStack closes the loop: signals ↔ account data ↔ subscribers. ### 3. AI-Generated Live Applications **The insight**: An LLM generates 20 lines of `.ds` source → compiles in <100ms → produces 44KB HTML → pushes to relay as frame 0. The AI responds with a **running application** instead of text. ``` User: "Show me a live dashboard of my Solana validator" AI: [generates 30 lines of .ds — 500 bytes] [compiles to 44KB HTML in 80ms] [pushes to relay as frame 0] → Here's your dashboard: relay.dreamstack.dev/s/x9f2 (already live, already streaming real data) ``` The AI doesn't link you to a website. The AI doesn't generate code for you to deploy. **The AI's response IS a live, streaming, interactive application.** **Why impossible today**: ChatGPT produces static text. Code Interpreter produces screenshots. V0/Bolt generate code you deploy yourself. No AI can respond with a live streaming app because existing frameworks require build infrastructure and are too large for inline delivery. ### The Unifying Principle > When an application is small enough, it stops being infrastructure and becomes > data. Data can travel through streams (frame-zero), live on-chain (Solana UI), > or be generated on the fly (AI apps). DreamStack apps crossed that threshold — > they're small enough to go anywhere data goes.