|
1 | 1 | # Anode
|
2 | 2 |
|
3 |
| -A real-time collaborative notebook system built with LiveStore event sourcing. |
| 3 | +A real-time collaborative notebook system built on LiveStore, focusing on seamless AI ↔ Python ↔ User interactions. |
4 | 4 |
|
5 |
| -**Current Status: ✅ FULLY OPERATIONAL** - Python code execution working end-to-end with reactive architecture. |
| 5 | +**Current Status: ✅ FULLY OPERATIONAL** - Zero-latency Python execution with reactive architecture working end-to-end. |
6 | 6 |
|
7 |
| -## Architecture |
8 |
| - |
9 |
| -- **Schema Package** (`@anode/schema`): LiveStore schema definitions |
10 |
| -- **Web Client** (`@anode/web-client`): React-based web interface |
11 |
| -- **Document Worker** (`@anode/docworker`): Cloudflare Worker for sync backend |
12 |
| -- **Kernel Client** (`@anode/dev-server-kernel-ls-client`): Python execution server |
| 7 | +## What Makes Anode Different |
13 | 8 |
|
14 |
| -### Key Design |
15 |
| -- Each notebook = one LiveStore store (`NOTEBOOK_ID = STORE_ID`) |
16 |
| -- Execution queue system: `pending` → `assigned` → `executing` → `completed` |
17 |
| -- **Reactive kernel architecture** using LiveStore's `queryDb` subscriptions |
18 |
| -- Manual kernel management (start one per notebook) |
| 9 | +- **Real-time collaboration** built on event sourcing (LiveStore) |
| 10 | +- **Zero-latency execution** using reactive subscriptions (no polling) |
| 11 | +- **AI-first design** for intelligent code assistance and context-aware suggestions |
| 12 | +- **Local-first architecture** with offline capability |
19 | 13 |
|
20 | 14 | ## Quick Start
|
21 | 15 |
|
22 |
| -### 1. Start Core Services |
| 16 | +### 1. Install and Start Core Services |
23 | 17 | ```bash
|
24 | 18 | pnpm install
|
25 | 19 | pnpm dev # Starts web client + sync backend
|
26 | 20 | ```
|
27 | 21 |
|
28 |
| -### 2. Create Notebook |
| 22 | +### 2. Create Your First Notebook |
29 | 23 | 1. Open http://localhost:5173
|
30 |
| -2. URL gets notebook ID: `?notebook=notebook-123-abc` |
31 |
| -3. Create cells and edit |
| 24 | +2. URL automatically gets notebook ID: `?notebook=notebook-123-abc` |
| 25 | +3. Start creating cells and editing |
32 | 26 |
|
33 | 27 | ### 3. Enable Python Execution
|
34 | 28 | ```bash
|
35 |
| -# In new terminal - use your actual notebook ID |
| 29 | +# In new terminal - use your actual notebook ID from the URL |
36 | 30 | NOTEBOOK_ID=notebook-123-abc pnpm dev:kernel
|
37 | 31 | ```
|
38 | 32 |
|
| 33 | +**Pro tip**: Click the **Kernel** button in the notebook header to copy the exact command for your notebook! |
| 34 | + |
39 | 35 | ### 4. Execute Code
|
40 |
| -- Add code cell in web interface |
41 |
| -- Write Python: `import random; random.random()` |
42 |
| -- Press Ctrl+Enter or click Run |
43 |
| -- See results appear in real-time |
| 36 | +- Add a code cell in the web interface |
| 37 | +- Write Python: `import numpy as np; np.random.random(5)` |
| 38 | +- Press **Ctrl+Enter** or click **Run** |
| 39 | +- See results appear instantly |
44 | 40 |
|
45 |
| -## What's Working |
| 41 | +## Architecture |
46 | 42 |
|
47 |
| -- ✅ Real-time collaborative editing |
48 |
| -- ✅ Python code execution via Pyodide |
49 |
| -- ✅ Event sourcing and sync |
50 |
| -- ✅ **Reactive work queue management** (instant response) |
51 |
| -- ✅ Multiple isolated notebooks |
52 |
| -- ✅ Output generation and display |
53 |
| -- ✅ Zero-latency execution (no polling delays) |
| 43 | +Anode uses a breakthrough reactive architecture for instant execution: |
54 | 44 |
|
55 |
| -## Development Commands |
| 45 | +``` |
| 46 | +┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ |
| 47 | +│ Web Client │◄──►│ Document Worker │◄──►│ Python Kernel │ |
| 48 | +│ (React UI) │ │ (CF Workers) │ │ (Pyodide) │ |
| 49 | +└─────────────────┘ └──────────────────┘ └─────────────────┘ |
| 50 | + │ │ │ |
| 51 | + ▼ ▼ ▼ |
| 52 | + LiveStore DB Event Sync Hub Execution Queue |
| 53 | +``` |
56 | 54 |
|
57 |
| -```bash |
58 |
| -# Core development |
59 |
| -pnpm dev # Start web + sync |
60 |
| -NOTEBOOK_ID=your-id pnpm dev:kernel # Start kernel |
| 55 | +### Key Design Principles |
| 56 | +- **One notebook = One LiveStore store** (`NOTEBOOK_ID = STORE_ID`) |
| 57 | +- **Reactive work queue**: `executionRequested` → `executionAssigned` → `executionStarted` → `executionCompleted` |
| 58 | +- **Event sourcing**: All changes are events, enabling perfect collaboration and audit trails |
| 59 | +- **Session-based kernels**: Each kernel gets a unique session for isolation |
61 | 60 |
|
62 |
| -# Utilities |
63 |
| -pnpm reset-storage # Clear all data |
64 |
| -pnpm build:schema # Build schema after changes |
| 61 | +## What's Working Right Now |
65 | 62 |
|
66 |
| -# Individual services |
67 |
| -pnpm dev:web-only # Web client only |
68 |
| -pnpm dev:sync-only # Sync backend only |
69 |
| -``` |
| 63 | +- ✅ **Instant Python execution** with zero polling delays |
| 64 | +- ✅ **Real-time collaborative editing** across multiple users |
| 65 | +- ✅ **Reactive architecture** using LiveStore's `queryDb` subscriptions |
| 66 | +- ✅ **Multiple isolated notebooks** with separate kernels |
| 67 | +- ✅ **Rich output display** for Python results |
| 68 | +- ✅ **Offline-first operation** with sync when connected |
| 69 | +- ✅ **Event sourcing** for complete history and debugging |
70 | 70 |
|
71 | 71 | ## Project Structure
|
72 | 72 |
|
73 | 73 | ```
|
74 |
| -packages/ |
75 |
| -├── schema/ # LiveStore events and tables |
76 |
| -├── web-client/ # React notebook interface |
77 |
| -├── docworker/ # Cloudflare Workers sync |
78 |
| -└── dev-server-kernel-ls-client/ # Python kernel process |
| 74 | +anode/ |
| 75 | +├── packages/ |
| 76 | +│ ├── schema/ # LiveStore events & state definitions |
| 77 | +│ ├── web-client/ # React notebook interface |
| 78 | +│ ├── docworker/ # Cloudflare Workers sync backend |
| 79 | +│ └── dev-server-kernel-ls-client/ # Python execution server |
| 80 | +├── ROADMAP.md # Development priorities |
| 81 | +└── AGENTS.md # AI agent context |
| 82 | +``` |
| 83 | + |
| 84 | +## Development Commands |
| 85 | + |
| 86 | +```bash |
| 87 | +# Core development workflow |
| 88 | +pnpm dev # Start web + sync |
| 89 | +NOTEBOOK_ID=your-notebook-id pnpm dev:kernel # Start kernel for specific notebook |
| 90 | + |
| 91 | +# Utilities |
| 92 | +pnpm reset-storage # Clear all local data |
| 93 | +pnpm build:schema # Rebuild schema after changes |
| 94 | + |
| 95 | +# Individual services (for debugging) |
| 96 | +pnpm dev:web-only # Web client only |
| 97 | +pnpm dev:sync-only # Sync backend only |
79 | 98 | ```
|
80 | 99 |
|
81 |
| -## Architecture Notes |
| 100 | +## Next Phase: AI-First Notebooks |
82 | 101 |
|
83 |
| -**Simplified Schema**: Removed all timestamp fields to eliminate complexity and database errors. Simple schemas are more reliable for prototypes. |
| 102 | +Anode is designed around **AI ↔ Python ↔ User interactions**. The next major milestone is completing the AI cell architecture: |
84 | 103 |
|
85 |
| -**Reactive Over Polling**: Kernels use LiveStore's `queryDb` reactive subscriptions for instant work detection. No more polling delays - executions start immediately when cells are run. |
| 104 | +### Coming Soon |
| 105 | +- **AI cells** that understand notebook context |
| 106 | +- **Code completions** with LSP + kernel integration |
| 107 | +- **Intelligent suggestions** based on current data and code |
| 108 | +- **Context-aware assistance** for data analysis workflows |
86 | 109 |
|
87 |
| -**One Store Per Notebook**: Each notebook gets its own LiveStore database for clean isolation. |
| 110 | +See [ROADMAP.md](./ROADMAP.md) for detailed development priorities. |
88 | 111 |
|
89 | 112 | ## Troubleshooting
|
90 | 113 |
|
91 |
| -**Build failures**: Run `pnpm build:schema` first |
92 |
| -**Execution not working**: Start kernel with correct `NOTEBOOK_ID` |
93 |
| -**Stale state**: Run `pnpm reset-storage` |
94 |
| -**Slow execution**: Should be instant with reactive architecture - check kernel logs for errors |
| 114 | +| Problem | Solution | |
| 115 | +|---------|----------| |
| 116 | +| Build failures | Run `pnpm build:schema` first | |
| 117 | +| Execution not working | Start kernel with correct `NOTEBOOK_ID` (use copy button in UI) | |
| 118 | +| Stale state | Run `pnpm reset-storage` | |
| 119 | +| Slow execution | Should be instant - check kernel logs | |
| 120 | + |
| 121 | +## Architecture Highlights |
| 122 | + |
| 123 | +**Simplified Event Schema**: Removed timestamp complexity for reliability. Simple schemas work better for rapid prototyping. |
| 124 | + |
| 125 | +**Reactive Over Polling**: Kernels use LiveStore's reactive subscriptions for instant work detection. This breakthrough eliminates polling delays entirely. |
| 126 | + |
| 127 | +**Local-First Design**: Everything works offline first, syncs when connected. Your work is never lost. |
| 128 | + |
| 129 | +## Contributing |
| 130 | + |
| 131 | +Anode is an open source project focused on developer experience. The system provides a solid foundation for collaborative notebook execution and can be extended incrementally. |
95 | 132 |
|
96 |
| -## Next Steps |
| 133 | +Key areas for contribution: |
| 134 | +- AI cell implementation |
| 135 | +- Code completion systems |
| 136 | +- Rich output formats |
| 137 | +- Performance optimizations |
97 | 138 |
|
98 |
| -1. Clean up tests (remove timestamp field references) |
99 |
| -2. Add error recovery for kernel restarts |
100 |
| -3. Improve kernel lifecycle management |
101 |
| -4. Add proper authentication |
| 139 | +## License |
102 | 140 |
|
103 |
| -The system provides a solid foundation for collaborative notebook execution with **instant reactive execution** and can be extended incrementally. |
| 141 | +[License TBD - Open Source] |
0 commit comments