Management Science · Decision Analytics

Turn your Excel optimization model
into a live web app

Normally, running Python means installing it, managing environments, and keeping packages in sync. This workflow eliminates all of that — Python runs inside the browser, so anyone can use the app with no setup at all.

Get started How it works Next steps
The idea

Convert your Excel model in a few steps

An AI assistant reads your Excel file, extracts the math, and produces a single HTML file you can share with anyone. Optionally add a notebook step to review and fine-tune the solver before publishing.

Direct path

📊
Your Excel model Data, Solver setup, constraints
→
🤖
AI assistant Reads model, picks solver, writes code
→
🌐
HTML browser app One file — share the link, anyone can use it

Before sharing: open the file locally and check the default outputs match your Excel Solver result. That is Layer 1 of the testing strategy.

Optional: via notebook (recommended for complex models)

📊
Your Excel model Data, Solver setup, constraints
→
🤖
AI assistant Produces a Jupyter notebook
→
📓
Review in Colab Run cells, verify assertions, tweak
→
🤖
AI assistant Converts notebook → HTML app
→
🌐
HTML browser app One file — share the link

The excel-to-notebook.md prompt generates assert cells automatically — that is Layer 2 of the testing strategy, built in from the start.

The app is the HTML file. Python runs inside the browser using Pyodide — a full Python runtime compiled to WebAssembly. No server, no back-end, zero running cost. The file you receive from the AI is the app; you can open it locally, or host it anywhere.
The stack

What the generated app uses

Every layer is free and declared inside the single HTML file. Open it in a browser — nothing to install.

🐍
Runtime

Pyodide v0.29.3

Python compiled to WebAssembly. Runs inside Chrome, Firefox, Safari — no install, no server.

⚙️
Solver

scipy · CVXPY · Clarabel

scipy for LP & MILP. CVXPY + Clarabel for convex programs (QP, SOCP — e.g. portfolio variance).

🖥️
UI

Vanilla HTML + JS

Plain form inputs and result tables. No framework, no magic — the generated code is transparent and auditable.

Under the hood

How Python runs inside the browser

The browser downloads a special build of Python compiled to WebAssembly (WASM) — a low-level format every modern browser understands. Your solver code runs inside that Python, in the tab.

First visit takes ~15 seconds while Python and the packages download. After that the browser caches everything, so subsequent visits load instantly.

Environments

Three ways to run the same Python code

The solver code is identical in all three contexts. Only the packaging layer differs.

Context Where Python runs How to install packages How to start Best for
Google Colab notebook Google's cloud servers !pip install cvxpy clarabel in the first cell Open the .ipynb file in colab.research.google.com Easiest to get started — no local setup
Local notebook (uv) Your machine (CPython) uv sync reads pyproject.toml, writes uv.lock uv run jupyter notebook Reproducible local development; versions pinned in uv.lock
Browser app (Pyodide) The visitor's browser tab (WebAssembly) pyodide.loadPackage(["cvxpy-base", "clarabel"]) in the HTML file Open the URL — nothing to install Sharing with non-technical users
Note on package names: In Pyodide's package index the library is called cvxpy-base, but on PyPI (Colab, uv, pip) it is just cvxpy. In both cases you write import cvxpy as cp — the name difference is invisible to your code.
Get started

Convert your Excel model in minutes

  1. 1
    Open an AI assistant

    Go to claude.ai, ChatGPT, or Gemini and start a new conversation. A free account is sufficient.

  2. 2
    Attach your Excel file

    Upload the .xlsx file that contains your optimization model (the one with Solver set up).

  3. 3
    Choose a path and paste the matching prompt

    Go direct to HTML for a quick result, or go via notebook to review the solver logic first (recommended for complex models).

  4. 4
    Test locally

    Save the index.html and open it in your browser. Check that the default values match Excel and that Solve returns the right answer.

  5. 5
    Share

    Send the index.html directly — by email, Canvas, or any file share. Anyone who opens it can run the solver with no install.

Watch out for confidential data. When you upload an Excel file to an AI assistant, the data goes to an external server. If your model contains sensitive numbers — real costs, client names, proprietary figures — replace them with plausible fake values first. The structure of the model is what the AI needs; the actual numbers can be substituted and corrected later.

The prompts

Pick the right prompt for your path, then copy and paste it into your AI assistant.

prompts/excel-to-html.md
I have an Excel optimization model (attached). Convert it into a single-file browser app.

## Step 1 — Understand the model

Read all sheets. State explicitly:

- Parameters — fixed inputs (costs, distances, capacities, etc.)
- Decision variables — cells Excel Solver changes; continuous, binary, or integer?
- Objective — what is minimized or maximized; write the formula in plain math
- Constraints — list each one with type (≤, ≥, =) and meaning

Then pick the solver:

  All variables continuous, linear objective    →  scipy.optimize.linprog
  All variables continuous, quadratic objective →  CVXPY + Clarabel
  Any binary or integer variables               →  scipy.optimize.milp

## Step 2 — Stack

  Python runtime:  Pyodide v0.29.3 (WebAssembly — runs Python inside the browser)
  Packages:        pyodide.loadPackage([...])
  UI:              Vanilla HTML + CSS + JavaScript
  Output:          One self-contained index.html file

Package calls:
  scipy solvers  →  await pyodide.loadPackage(["numpy", "scipy"])
  CVXPY/Clarabel →  await pyodide.loadPackage(["cvxpy-base", "clarabel"])

## Step 3 — App requirements

- Pre-fill every input with default values from the Excel file
- All inputs editable so users can explore scenarios
- Loading message while Python initialises (~15 s first visit)
- After solving: optimal decision values, objective value, and a breakdown
- Clear error message if infeasible

## Step 4 — Serialisation rules (mandatory — violating causes a runtime crash)

Numpy types crash json.dumps. Always convert before returning:

  result.x.tolist()    ← numpy array → plain Python list
  float(result.fun)    ← numpy scalar → plain Python float

JS → Python bridge:
  pyodide.globals.set("_payload", JSON.stringify(data))
  const raw = await pyodide.runPythonAsync("run_from_js(_payload)")

## Deliver

One complete index.html. No separate files. No build step.
Must open directly in a browser from disk.
prompts/excel-to-notebook.md
I have an Excel optimization model (attached). Convert it into a Jupyter notebook.

## Step 1 — Understand the model

Read all sheets. State explicitly:

- Parameters — fixed inputs (costs, distances, capacities, etc.)
- Decision variables — cells Excel Solver changes; continuous, binary, or integer?
- Objective — what is minimized or maximized; write the formula in plain math
- Constraints — list each one with type (≤, ≥, =) and meaning

Pick the solver:

  All variables continuous, linear objective    →  scipy.optimize.linprog
  All variables continuous, quadratic objective →  CVXPY + Clarabel
  Any binary or integer variables               →  scipy.optimize.milp

## Step 2 — Notebook structure

Produce an .ipynb notebook with these cells in order:

1. Install cell (always first):
     import sys
     if "google.colab" in sys.modules:
         %pip install cvxpy clarabel -q   # adjust to chosen solver

2. Imports — numpy, pandas, solver library, matplotlib if plotting

3. Data — all parameters as named variables; pd.DataFrame display of matrix inputs

4. Solver function — self-contained function; identical logic to what goes in a browser app

5. Solve and test — call with default values; assert statements to verify vs Excel solution

6. Results — pd.DataFrame tables with clear labels

7. Sensitivity analysis (if applicable) — sweep one key parameter

## Step 3 — Code quality

- Use descriptive variable names matching the Excel labels
- Add a brief markdown cell before each section
- Solver function must be self-contained (no global state)

## Deliver

One complete .ipynb notebook. Must run top-to-bottom in Google Colab. All assertions must pass.
prompts/notebook-to-html.md
I have a Jupyter notebook (attached) with a working Python optimization solver.
Convert it into a single-file browser app.

## Step 1 — Understand the notebook

Read the notebook and identify:

- The solver function — self-contained Python function that takes params and returns results
- Default parameter values used in the notebook
- What the function returns (decision variables, objective, breakdown)
- Which libraries are imported (scipy, cvxpy, numpy, etc.)

Select the Pyodide package call:

  scipy.optimize.linprog / milp  →  await pyodide.loadPackage(["numpy", "scipy"])
  cvxpy                          →  await pyodide.loadPackage(["cvxpy-base", "clarabel"])

Note: the import statement (import cvxpy as cp) is identical in both environments.

## Step 2 — Stack

  Python runtime:  Pyodide v0.29.3 (WebAssembly)
  Packages:        pyodide.loadPackage([...])
  UI:              Vanilla HTML + CSS + JavaScript
  Output:          One self-contained index.html file

## Step 3 — App requirements

- Embed the solver function from the notebook as-is in the HTML
- One editable input field per parameter, pre-filled with notebook defaults
- Loading message while Pyodide initialises
- After solving: optimal decision values, objective value, and a breakdown
- Clear error message if infeasible

## Step 4 — Serialisation rules (mandatory)

Wrap numpy results before json.dumps:

  np_array.tolist()    ← array → plain list
  float(np_scalar)     ← scalar → plain float

The solver function itself does NOT need to change — only the run_from_js wrapper.

## Deliver

One complete index.html. No separate files. No build step.
Must open directly in a browser from disk.

Full prompt files are in the prompts/ directory of this repository.

Examples in this repo

Two working apps to learn from

🏭

Facility Location

Which warehouses to open? How to allocate customers?
Model: MILP  ·  Solver: scipy.optimize.milp

Open app Open in Colab Download notebook Download Excel
📈

Portfolio Frontier

Minimum-variance portfolio for every return level.
Model: QP  ·  Solver: CVXPY + Clarabel

Open app Open in Colab Download notebook Download Excel

The Open in Colab links work once the repo is public on GitHub.

Testing

A testing strategy that grows with your model

Start with what you already trust — the Excel result — and build upward. Layers 1 and 2 are already wired into the workflow prompts; Layer 3 is optional and can be added with an AI coding agent when the app matures.

  1. 1
    Excel — establish the ground truth

    Run Excel Solver once with your baseline inputs. Record the optimal objective value, the key decision variables, and which constraints are binding. These numbers are your spec: every downstream environment must reproduce them.

    Both prompts — excel-to-notebook.md and excel-to-html.md — ask the AI to record these values in comments automatically. They serve as permanent documentation and a regression anchor.
  2. 2
    Notebook — assert against the Excel reference

    The excel-to-notebook.md prompt already generates this cell — named EXCEL_* constants and assert statements are included automatically. Run the full notebook to confirm the match, then add edge cases by hand as the model grows. Re-run whenever you change the formulation; a broken assertion immediately surfaces regressions.

    # ── Tests (baseline: Excel Solver run 2025-03-09) ──
    EXCEL_COST  = 1_247.50        # total cost from Excel reference run
    EXCEL_OPEN  = frozenset({0, 2, 4})   # which facilities are opened
    
    result = solve(demand, capacity, fixed_cost, transport_cost)
    
    assert abs(result["total_cost"] - EXCEL_COST) < 0.5, \
        f"Cost mismatch: {result['total_cost']:.2f} vs {EXCEL_COST}"
    assert frozenset(result["open_facilities"]) == EXCEL_OPEN, \
        f"Facilities mismatch: {result['open_facilities']}"
    
    print("All assertions passed.")

    Extend with edge cases: zero demand, a single facility forced open, capacity just tight enough to be binding. Each edge case is one extra assert block.

  3. 3
    App — end-to-end with Playwright (optional, ~20 lines)

    A Playwright test loads index.html in a real browser, fills in the baseline inputs, clicks Solve, and checks that the output matches the notebook reference. It catches issues unique to the browser layer — Pyodide loading, JS wiring, DOM serialization — that the notebook alone cannot see.

    // tests/app.spec.js  (Playwright)
    import { test, expect } from '@playwright/test';
    import path from 'path';
    
    test('baseline facility-location solve', async ({ page }) => {
      await page.goto('file://' + path.resolve('facility-location-app/index.html'));
      await page.waitForSelector('#solve-btn:not([disabled])'); // Pyodide ready
    
      // fill baseline inputs (match Excel reference run)
      await page.fill('#demand-0', '120');
      await page.fill('#demand-1', '80');
      // … remaining inputs …
    
      await page.click('#solve-btn');
      await page.waitForSelector('#result-cost');   // output rendered
    
      const cost = await page.textContent('#result-cost');
      expect(parseFloat(cost)).toBeCloseTo(1247.50, 0);
    });

    Install once: npm init playwright@latest. Run with npx playwright test. Ask an AI coding agent — Claude Code, Gemini CLI, or OpenCode — to generate the full test from your notebook's reference values and the app's HTML. It can read both files and wire them together automatically.

Keep it proportional. For a teaching demo or a one-off analysis, Layer 1 alone is fine. For a model used in recurring decisions or shared with colleagues, add Layer 2 — ten minutes to write, hours saved in debugging. Layer 3 earns its keep when the app is actively maintained or the Pyodide/JS glue is non-trivial.

Expanding the test suite

Once the three layers are in place, an AI coding agent can push coverage further — additional edge-case cells in the notebook, multi-scenario Playwright runs, or a pytest suite driven by a CSV of test cases. A ready-made prompt for generating the full Playwright spec automatically is listed in Next steps below.

Iteration & next steps

Ways to improve the app further

The first version is already functional. Here are concrete ways to take it further.

🔌

Live data via API

Fetch prices, exchange rates, or demand forecasts from a public API and feed them directly into the solver — no manual copy-paste needed.

🎚️

Sensitivity sliders

Replace number inputs with range sliders so users can drag a parameter (e.g. demand, capacity) and see the optimal solution update in real time.

📊

Charts & visualisation

Add Chart.js to plot the efficient frontier, cost breakdown bar chart, or allocation heatmap alongside the results table.

🗂️

Scenario comparison

Let users save the current result, change inputs, solve again, and view a side-by-side table comparing multiple scenarios.

💾

CSV / Excel export

Add a download button that exports the results table as a .csv or .xlsx file — works entirely in the browser, no server needed.

🗄️

SQLite — in-browser database

Python's built-in sqlite3 works in Pyodide with no extra packages. Store scenario results or lookup tables in an in-memory database for the session, and let users download the .db file to open in any SQLite viewer.

🧪

E2E test prompt

Use an AI coding agent with your index.html and notebook to auto-generate a full Playwright spec — selectors, baseline inputs, and expected values, all inferred from your files.

💡

Your idea

What would make this app genuinely useful for a real decision? Pick one small addition, try it, and see how far you get.

🏭
Facility Location v2

A worked example combining several of the above: dynamic add/remove of servers and demand nodes, a geographic canvas map with flow lines, and XLSX data import/export. The expansion prompt itself was written with AI — describe the features you want and ask an AI assistant to draft the prompt for you.

How to iterate
Model changes

Tweaking the formulation, adding constraints, trying new data? Work in Excel or the notebook — both give a much faster feedback loop than editing the app directly.

Once the model is right, hand off to an AI coding agent to regenerate or update the app.

UI changes

Layout, inputs, charts, copy? Paste index.html into an AI coding agent and describe what you want.

For targeted edits — a specific function, a single section — use an agentic CLI tool like Claude Code, Gemini CLI, or OpenCode. They can locate and change exactly the right lines without touching the rest.