Molecular visualization

MolecuLens

A published molecular visualization product supported by a FastAPI compute service for Psi4 orbital and density overlays rendered in Three.js.

Problem

Why this mattered

Molecular orbitals and density surfaces are useful learning tools, but the heavy quantum chemistry work does not belong in a client renderer. The product needed server-side compute that still felt interactive to a Three.js front end.

Build

What shipped

  • A FastAPI service that accepts 3D SDF input and computes HOMO, LUMO, and optional density overlays.
  • Server-side conversion of computed surfaces into ready-to-render mesh data with vertices, normals, indices, and triangle counts.
  • Separate positive and negative orbital lobes for clearer visualization.
  • Compressed base64 typed-array payloads for efficient transfer into a browser renderer.
  • A Postgres-backed async job queue, result caching by geometry and parameters, Docker deployment, and protected cache metrics.

Stack

Tools and systems

PythonFastAPIPsi4PostgresDockerCaddyThree.jsSwiftiOS

Decisions

Technical choices

  • Pre-mesh orbital surfaces server-side so the client receives renderer-ready geometry.
  • Cache by geometry and compute parameters to avoid repeating expensive chemistry jobs.
  • Expose async job polling rather than blocking the request path on long-running compute.
  • Keep operator cache metrics behind HTTP basic auth instead of making internals public.

Outcome

Proof surface

The work connects a published iOS app, public product surface, and production-ready compute service into one molecular visualization stack.