Architecture Overview
Ganimede is built as a real-time collaborative 2D computational notebook with a clear separation between backend and frontend concerns. The system uses Yjs CRDTs for real-time synchronization and collaboration.High-Level Architecture
Technology Stack
Ganimede is built on top of several key technologies:| Component | Technology | Purpose |
|---|---|---|
| Backend Framework | Starlette | ASGI web framework for Python |
| Kernel Integration | jupyter_client | Execute code in Jupyter kernels |
| Frontend Framework | Svelte | Reactive UI components |
| CRDT Sync | Yjs | Conflict-free replicated data types |
| Code Editor | Monaco Editor | VS Code’s editor component |
Component Responsibilities
Backend Components
- Starlette Application: HTTP server and routing (port 8000)
- Ypy WebSocket Server: Yjs synchronization server (port 1234)
- Notebook Manager: Loads
.ipynbfiles, manages cell graph structures (np_graph, pc_graph) - Kernel Manager: Spawns and communicates with Jupyter kernels
- Comms Manager: WebSocket communication for control messages
- YDoc: Shared CRDT document containing all notebook state
Frontend Components
- Canvas: 2D workspace with pan and zoom
- Notebook: Renders cells and manages graph visualization
- Cell: Individual code or markdown cells with drag-and-drop
- Tissue: Grouping container for heading cells and their children
- Monaco Editor: Code editing with syntax highlighting
- Stores: Svelte stores for socket, mouse, zoom, and notebook state
Request/Response Flow
1. Application Startup
2. Frontend Initialization
3. Code Execution Flow
4. Real-time Collaboration Flow
Data Flow
All notebook state flows through the YDoc:- Frontend → YDoc: User edits trigger Yjs updates
- YDoc → YDoc: Ypy WebSocket Server synchronizes all clients
- Backend → YDoc: Kernel outputs update YDoc maps/arrays
- YDoc → Frontend: Yjs observers trigger Svelte reactivity
Communication Channels
Ganimede uses two separate WebSocket connections:- Yjs WebSocket (port 1234): For CRDT synchronization of notebook state
- Comms WebSocket (port 8000): For control messages (run cell, restart kernel, etc.)
Next Steps
- Backend Architecture - Detailed backend structure
- Frontend Architecture - Svelte component architecture
- Yjs Integration - CRDT synchronization details