• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
zcpbx

zcpbx

MolstarViewer

Public
Like
MolstarViewer
Home
Code
13
backend
3
docking-viewer
3
frontend
2
shared
2
.vtignore
AGENTS.md
CHANGELOG.md
QUICKSTART.md
README.md
deno.json
index.html
H
index.tsx
molstar-viewer.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
…
Viewing readonly version of main branch: v175
View latest version
README.md

Molstar Viewer Apps

A collection of Molstar molecular visualization applications built for Val Town, using JSR imports and TSX.

πŸš€ Quick Start

This Val serves four different Molstar visualization applications:

  • Viewer 🧬 - Standard Mol* viewer for visualizing molecular structures
  • Docking Viewer πŸ”¬ - Specialized viewer for molecular docking results
  • Mesoscale Explorer πŸ”­ - Explore mesoscale biological structures
  • MVS Stories πŸ“– - Interactive molecular visualization stories

πŸ“ Project Structure

MolstarViewer/
β”œβ”€β”€ index.tsx                    # Main entry point (imports backend)
β”œβ”€β”€ backend/                     # Server-side routing and logic
β”‚   β”œβ”€β”€ index.tsx               # Hono app with routes
β”‚   β”œβ”€β”€ routes/                 # Individual route handlers (future)
β”‚   └── README.md
β”œβ”€β”€ frontend/                    # Client-side TSX components
β”‚   β”œβ”€β”€ apps/                   # Individual app components
β”‚   β”‚   β”œβ”€β”€ viewer.tsx
β”‚   β”‚   β”œβ”€β”€ docking-viewer.tsx
β”‚   β”‚   β”œβ”€β”€ mesoscale-explorer.tsx
β”‚   β”‚   └── mvs-stories.tsx
β”‚   └── README.md
β”œβ”€β”€ shared/                      # Shared types and utilities
β”‚   β”œβ”€β”€ types.ts
β”‚   └── README.md
β”œβ”€β”€ viewer/                      # Original Molstar viewer source (reference)
β”œβ”€β”€ docking-viewer/              # Original docking viewer source (reference)
β”œβ”€β”€ mesoscale-explorer/          # Original mesoscale explorer source (reference)
β”œβ”€β”€ mvs-stories/                 # Original MVS stories source (reference)
└── README.md                    # This file

πŸ› οΈ Technology Stack

  • Runtime: Val Town (Deno-based)
  • Framework: Hono for routing
  • UI: React 18.2.0 via esm.sh
  • Molstar: JSR package jsr:@zachcp/molstar@5.3.4
  • Language: TypeScript/TSX

πŸ“¦ JSR Imports

All dependencies are imported using the JSR protocol:

Molstar from JSR

import { Viewer } from "jsr:@zachcp/molstar@5.3.4";

Available exports from jsr:@zachcp/molstar:

  • . (main export - includes Viewer class)
  • ./plugin-ui
  • ./plugin
  • ./plugin-state
  • ./canvas3d
  • ./data
  • ./state
  • ./task
  • ./util

Hono from JSR

import { Hono } from "jsr:@hono/hono@4";

Why JSR?

JSR (JavaScript Registry) provides native Deno/TypeScript support and works seamlessly in Val Town's runtime environment.

πŸ—οΈ Architecture

Backend (Hono from JSR)

The backend uses Hono from JSR for HTTP routing. Each route corresponds to a Molstar app:

import { Hono } from "jsr:@hono/hono@4"; import { renderToString } from "https://esm.sh/react-dom@18.2.0/server"; const app = new Hono(); app.get("/", (c) => { // Home page listing all apps }); app.get("/viewer", (c) => { const html = renderToString(ViewerApp()); return c.html(html); }); // ... etc

Frontend (TSX Components)

Each app is a self-contained TSX component that returns a complete HTML document:

Create val
/** @jsxImportSource https://esm.sh/react@18.2.0 */ export default function ViewerApp() { return ( <html lang="en"> <head> <meta charSet="UTF-8" /> <title>Mol* Viewer</title> </head> <body> <div id="molstar-container" /> <script type="module" dangerouslySetInnerHTML={{ __html: ` import { Viewer } from "jsr:@zachcp/molstar@5.3.4"; // Initialize viewer `}} /> </body> </html> ); }

Shared Types

Common TypeScript interfaces and constants are defined in shared/types.ts for use across backend and frontend.

πŸ”§ Development

Current Status

The project is currently scaffolded with:

  • βœ… Backend routing with Hono from JSR
  • βœ… TSX components for each app
  • βœ… Shared types and metadata
  • βœ… Viewer app fully functional with JSR imports
  • ⏳ Docking viewer (scaffolded)
  • ⏳ Mesoscale explorer (scaffolded)
  • ⏳ MVS Stories (scaffolded)

Next Steps

  1. Implement Molstar initialization in each app component
  2. Add proper error handling and loading states
  3. Style the apps with proper CSS
  4. Add interactive controls for each viewer
  5. Implement app-specific features:
    • Viewer: Load PDB structures by ID
    • Docking Viewer: Load and compare docking results
    • Mesoscale Explorer: Load mesoscale structures
    • MVS Stories: Story navigation and playback

πŸ“š Resources

  • Mol* Website
  • Val Town Documentation
  • JSR Package Registry
  • Hono Framework

πŸ“ Notes

  • All components use the /** @jsxImportSource https://esm.sh/react@18.2.0 */ pragma
  • JSR imports use the jsr: protocol (e.g., jsr:@zachcp/molstar@5.3.4)
  • Inline styles use React style objects with camelCase properties
  • Client-side scripts are injected using dangerouslySetInnerHTML
  • Code in shared/ must work in both server and browser environments

🀝 Contributing

When adding new features:

  1. Keep backend routing logic in backend/
  2. Keep TSX components in frontend/apps/
  3. Keep shared types in shared/types.ts
  4. Use JSR imports for Molstar dependencies
  5. Follow Val Town best practices from AGENTS.md

πŸ“„ License

Copyright (c) 2018-2025 mol* contributors, licensed under MIT

FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2025 Val Town, Inc.