Repository navigation
Developer Guide Code Style
Sudharsan Selvaraj edited this page Jul 20, 2026
·
1 revision
TokenPrint enforces strict coding standards to maintain readability and scientific honesty across a complex, multi-language codebase.
In an educational tool, the code itself should be educational. Messy, undocumented code undermines the project's goal of demystifying AI. Furthermore, strict rules (like banning Math.random()) are mechanically enforced to prove the visualization's integrity.
The most important rule in TokenPrint: Never fabricate data to make the UI look better.
- The frontend build step
npm run buildliterally runs a script (verify-data.sh) that greps forMath.randomin theapp/,components/, andlib/directories. - If you need visual jitter for a particle effect, you must add it to the explicit allowlist in the build script and justify it in your PR.
-
Formatting: Use
blackandisort. -
Typing: Use strict Python type hints. Pydantic schemas (
schemas.py) must be used for all JSON serialization. -
Documentation: Use Google-style docstrings for complex tensor manipulations in
model.py.
-
Formatting: Use
prettier. -
Typing: Strict TypeScript is enforced. Do not use
any. Define interfaces for all API responses. - Components: Prefer functional components.
-
Colors: Never hardcode HEX or RGB values in React components. Always import from
lib/sceneColors.ts.
flowchart TD
PR[Pull Request Submitted] --> CI[GitHub Actions]
subgraph CI Pipeline
CI --> Black[Python: Black Formatting]
CI --> TS[TS: Type Checking]
CI --> Random[Grep: Check for Math.random]
end
Black --> Pass{All Pass?}
TS --> Pass
Random --> Pass
Pass -- Yes --> Merge[Ready to Merge]
Pass -- No --> Fail[Action Required]
| Previous | Home | Next |
|---|---|---|
| Building From Source | Home | Adding a New Visualization |
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