Skip to content

Add QuantaLab: interactive virtual science laboratory on Cloudflare Python Workers#1

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-interactive-laboratory-simulation
Draft

Add QuantaLab: interactive virtual science laboratory on Cloudflare Python Workers#1
Copilot wants to merge 2 commits intomainfrom
copilot/add-interactive-laboratory-simulation

Conversation

Copy link

Copilot AI commented Mar 8, 2026

Bootstraps the QuantaLab application from scratch — a browser-based virtual lab with real-time Canvas simulations across physics, chemistry, and biology, guided by an AI mentor via Cloudflare Workers AI.

Architecture

  • Cloudflare Python Worker (src/index.py) — HTTP router serving the API and delegating static assets via wrangler.toml assets binding
  • AI Mentor (src/ai_mentor.py) — calls @cf/meta/llama-3.1-8b-instruct through env.AI.run(); Socratic system prompt, 10-turn history window
  • Experiment catalogue (src/experiments.py) — 9 experiments (3 per domain) as typed dicts with parameter ranges, defaults, and learning objectives; JSON-serialisable for the API

API surface

Method Path Description
GET /api/experiments Full catalogue
GET /api/experiments/{domain}/{id} Single experiment
POST /api/mentor AI mentor chat
GET /api/health Health check

Frontend (static/)

Single-page app — fixed header with domain nav, experiment sidebar, Canvas simulation panel, and AI chat pane. No framework dependencies.

Nine Canvas simulations, each driven by live sliders:

Domain Experiments
Physics Pendulum (SHM), Projectile motion, Ohm's Law
Chemistry Acid–base pH, Boyle's Law (PV), Titration curve
Biology Mitosis phases, Natural selection, Photosynthesis rate
# Mentor endpoint — POST /api/mentor
body = {"message": "Why does a longer pendulum swing slower?",
        "domain": "physics", "experiment": "pendulum", "history": [...]}

# Worker delegates to Cloudflare AI
reply = await env.AI.run("@cf/meta/llama-3.1-8b-instruct", {"messages": messages})

Tests

22 pytest unit tests covering the experiment catalogue (field presence, parameter range validation, JSON serialisability, uniqueness constraints).

Original prompt

Interactive virtual laboratory where students can explore physics, chemistry, and biology experiments in simulation. Guided by an AI mentor that explains concepts, answers questions, and suggests experiments. Designed to make scientific exploration accessible, safe, and engaging through hands-on digital experimentation. using cloudflare python workers and cloudflare ai


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: A1L13N <193832434+A1L13N@users.noreply.github.com>
Copilot AI changed the title [WIP] Add interactive virtual laboratory for science experiments Add QuantaLab: interactive virtual science laboratory on Cloudflare Python Workers Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants