Interactive molecular visualization toolkit built with modern web technologies
Molvis is a high-performance molecular visualization toolkit that brings interactive 3D molecular graphics to the web, desktop, and Jupyter notebooks. Built on Babylon.js and powered by WebAssembly, Molvis delivers smooth, real-time rendering of large molecular systems with an intuitive, modern interface.
- π High Performance: WebAssembly-powered molecular data processing with GPU-accelerated rendering
- π¨ Multiple Rendering Modes: View, select, edit, manipulate, and measure molecular structures
- π Trajectory Support: Smooth playback and analysis of molecular dynamics trajectories
- π§ Extensible Pipeline: Modular modifier system for custom data transformations
- β‘ Modern Stack: TypeScript, React, and cutting-edge build tools
- π§ͺ Well Tested: Comprehensive unit tests with rstest framework
- π¦ Multiple Interfaces: Web app, Jupyter widget, and VSCode extension
npm install @molvis/core# Clone the repository
git clone https://github.com/molcrafts/molvis.git
cd molvis
# Install dependencies
npm install
# Start the development server
npm run dev:pageVisit http://localhost:3000 to see the application.
import { mountMolvis, readFrame } from "@molvis/core";
const container = document.getElementById("viewer");
if (!container) {
throw new Error("viewer container not found");
}
const app = mountMolvis(container);
const response = await fetch("/structure.pdb");
const pdbText = await response.text();
const frame = readFrame(pdbText, "structure.pdb");
app.loadFrame(frame);
await app.start();This repository is organized as a monorepo with multiple packages:
molvis/
βββ core/ # Core TypeScript library
β βββ src/ # Source code
β β βββ commands/ # Command system with undo/redo
β β βββ core/ # Core rendering and scene management
β β βββ pipeline/ # Data processing pipeline
β β βββ mode/ # Interaction modes
β β βββ ui/ # UI components
β βββ tests/ # Test files
βββ page/ # React web application
β βββ src/ # Web app source
βββ python/ # Python Jupyter widget
β βββ src/molvis/ # Python package source
βββ vsc-ext/ # VSCode extension
β βββ src/ # Extension source
βββ docs/ # Documentation and release runbooks
The heart of Molvis, providing:
- Rendering Engine: Babylon.js-based 3D visualization with custom shaders
- Command System: Full undo/redo support for all operations
- Pipeline Architecture: Extensible modifier system for data transformations
- Multiple Modes: View, select, edit, manipulate, and measure
- File Format Support: PDB, XYZ, LAMMPS data files
- Trajectory Playback: Timeline controls with smooth interpolation
A modern React-based interface featuring:
- Responsive layout with resizable panels
- Integrated timeline control for trajectories
- Real-time settings and property editing
- Export capabilities
- Dark/light theme support
One mv.Molvis() class, works in both scripts and Jupyter:
import molvis as mv
import molpy as mp
viewer = mv.Molvis() # script: opens a browser tab
viewer.draw_frame(frame)
viewer.snapshot()
scene = mv.Molvis(name="demo") # Jupyter: mounts the page bundle in the cell
scene.draw_frame(frame)
sceneBidirectional events: canvas interactions (selection, mode, frame) flow back to Python without polling.
viewer.on("selection_changed", lambda ev: print(ev["atom_ids"]))
ev = viewer.wait_for("selection_changed", timeout=30)
viewer.selection # Selection(atom_ids=(...), bond_ids=(...))Implementation details:
- One frontend app β the
page/bundle β drives both hosts. - JSON-RPC 2.0 over a local WebSocket with a token handshake; numpy arrays ride as binary buffers instead of JSON lists.
- Frontend JSON-RPC failures are raised into Python as
molvis.MolvisRPCError.
Custom editor for molecular files with:
- Syntax highlighting for .pdb, .xyz, .data files
- Inline preview commands
- Integrated visualization panel
# Install dependencies
npm install
# Run tests
npm test
# Build all packages
npm run build:all
# Development mode for specific packages
npm run dev:core # Core library
npm run dev:page # Web application (also the bundle mounted in Jupyter cells)Molvis uses multiple test lanes:
core: rstestpage: Node's built-in test runnerpython:pytestvsc-ext: TypeScript + Mocha / VS Code test host
# Run all tests
npm test
# Run tests for a specific package
npm run test -w core
npm run test -w page
npm run test -w python
npm run test -w vsc-ext# Lint and format
npx biome check --write# Build core library
npm run build:core
# Build web application (also copies into python/src/molvis/dist/)
npm run build:page# See the multi-package release runbook
open docs/release/0.0.2-release-checklist.mdAll operations are implemented as commands with do() and undo() methods, enabling full undo/redo functionality:
class MyCommand extends Command<void> {
async do(): Promise<void> {
// Perform operation
}
async undo(): Promise<void> {
// Reverse operation
}
}Data transformations are handled through a modular pipeline:
const modifier: Modifier = {
id: 'wrap-pbc',
name: 'Wrap PBC',
enabled: true,
modify: (frame: Frame) => {
// Transform molecular data
return wrappedFrame;
}
};
pipeline.addModifier(modifier);- View Mode: Camera controls and visualization settings
- Select Mode: Atom/bond selection and inspection
- Edit Mode: Add, delete, modify atoms and bonds
- Manipulate Mode: Move, rotate selected groups
- Measure Mode: Distance, angle, dihedral measurements
- Language: TypeScript 5.8+
- Rendering: Babylon.js 7.x
- Build Tool: Rsbuild
- Testing: rstest
- Code Quality: Biome
- UI Framework: React 19
- WASM: molwasm (Rust-based molecular data processing)
- PDB - Protein Data Bank format
- XYZ - Standard Cartesian coordinates
- LAMMPS Data - LAMMPS data files with topology
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
We welcome contributions! Please see our contributing guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with clear commit messages
- Add tests for new functionality
- Ensure all tests pass (
npm test) - Run code quality checks (
npx biome check --write) - Submit a pull request
- Write tests for all new features
- Follow TypeScript best practices
- Use meaningful variable and function names
- Document public APIs with JSDoc comments
- Keep commits atomic and well-described
- Additional file format support (GRO, MOL2, CIF)
- Advanced selection language
- Animation and keyframe system
- Collaborative editing features
- Plugin system for custom modifiers
- Performance profiling tools
This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.
If you use Molvis in your research, please cite:
@software{molvis2026,
title = {Molvis: Interactive Molecular Visualization Toolkit},
author = {Roy Kid},
year = {2026},
version = {0.0.2},
url = {https://github.com/molcrafts/molvis}
}- Built with Babylon.js
- Molecular data processing powered by molwasm
- Inspired by VMD, PyMOL, and Ovito
- π Documentation (coming soon)
- π Issue Tracker
- π¬ Discussions
Made with β€οΈ by the Molvis team