Repository navigation
Architecture
Sudharsan Selvaraj edited this page Jul 20, 2026
·
1 revision
TokenPrint is split cleanly into three separate concerns: Parsing, Inference, and Rendering. The architecture is heavily decoupled to ensure the frontend never fabricates numbers and the backend never concerns itself with pixels.
Tight coupling between visualization code and machine learning code leads to unmaintainable systems. By strictly enforcing a client-server boundary via REST and WebSockets, TokenPrint allows engineers to modify the PyTorch inference engine without touching React, and vice versa.
- Frontend: A Next.js and React Three Fiber application responsible purely for state management and rendering.
- Backend: A FastAPI and PyTorch application responsible purely for loading weights and executing forward passes.
- WebSocket Protocol: The strict JSON schema that streams generation frames from backend to frontend.
- Data Pipeline: The flow of tensors from disk to memory to WebSocket.
- Renderer: The WebGL engine translating math to geometry.
- Event System: The Zustand store managing state without triggering unnecessary React renders.
flowchart LR
subgraph Frontend Node
React[Next.js AppRouter]
R3F[React Three Fiber]
GGUF[Client GGUF Parser]
end
subgraph Backend Node
FastAPI[FastAPI Server]
PyTorch[PyTorch Engine]
end
React -- HTTP / WS --> FastAPI
FastAPI -- JSON Data --> React
PyTorch -- Tensors --> FastAPI
React --> R3F
| Previous | Home | Next |
|---|---|---|
| Interaction Model | Home | Overall Architecture |
TokenPrint Wiki | Home | Getting Started | User Guide | Concepts | Architecture | API | GitHub
TokenPrint is an interactive 3D visualization platform for exploring transformer architectures, tensors, and real-time LLM inference.
- User Guide
- Architecture Explorer
- Live Inference
- Tensor Inspector
- Camera Controls
- HUD
- Timeline
- Scene Navigation
- Transformer Concepts
- Tokenization
- Embeddings
- Positional Encoding
- RoPE
- Multi-Head Attention
- KV Cache
- LayerNorm
- Feed Forward Network
- Residual Connections
- Logits
- Softmax
- Sampling
- Autoregressive Generation
- Visualization System
- Scene Graph
- Geometry
- Materials
- Animation System
- Color Mapping
- Camera System
- Interaction Model
- Architecture
- Overall Architecture
- Frontend
- Backend
- WebSocket Protocol
- Data Pipeline
- Renderer
- Event System