How to Build an AI-Powered Photosynthesis Interactive Lab for Middle School Science

    This article explains how to turn a textbook lesson on photosynthesis into an interactive experiment bench using AI coding tools. It covers structuring teaching goals with a reusable prompt, modeling light, carbon dioxide, and water as controllable variables, designing a four-part page layout, and generating a runnable single-file HTML prototype. The focus stays on single-variable control and the full scientific inquiry cycle rather than visual polish.

    1. The Starting Problem: Students Don’t Lack Effort, They Lack an Operable Cognitive Scaffold

    When students can’t make sense of photosynthesis, the cause is usually not weak memory. Textbooks compress a process into a conclusion: raw materials, conditions, and products are handed over all at once, so students never get the chance to observe “what happens if I change one condition.” In the first year of middle school, students are just beginning to work with controlled experiments, and the real cognitive difficulties sit in two places: understanding the single-variable principle, meaning only one factor may change while everything else stays the same; and understanding the complete chain of scientific inquiry instead of memorizing its steps.

    So before handing the textbook to an AI for planning, it is critical to state the goal clearly. The goal is not “make a nice-looking animation.” It is “let students discover the relationship between variables and results through their own actions.” Once that goal is fixed, every later decision about tool choice, page structure, and interaction design has a standard to be judged against.

    2. Design the Teaching First, Implement the Technology Second

    2.1 Structure the Teaching Goals in Natural Language

    Start by turning the textbook passage into plain text, then send the planning request to an AI coding tool and ask for a teaching design rather than code. A reusable prompt structure looks like this:

    1. Role: You are a teaching design assistant for middle school biology.
    2. Input: The original textbook passage (see below).
    3. Target learners: 7th graders who are new to controlled experiments.
    4. Cognitive points that must be covered:
    5. 1) Controlling a single variable;
    6. 2) The six stages of scientific inquiry: ask a question, form a hypothesis,
    7. make a plan, carry out the experiment, draw a conclusion, communicate results.
    8. Output requirements:
    9. - First, state the teaching objectives and the key/difficult points;
    10. - Then, give the page modules and interaction flow of the interactive lab;
    11. - Finally, give acceptance criteria (what students must be able to do to count as
    12. having learned it).
    13. Textbook passage: ...

    The value of this approach is that it pins down both “what I want her to learn” and “how she is supposed to learn it” at the same time, which keeps the AI from improvising in ways that drift away from the curriculum standard.

    2.2 Break Photosynthesis into an Interactive Variable Model

    Photosynthesis is usually summarized as: under light, plants use carbon dioxide and water to produce organic matter and release oxygen. For 7th graders, there is no need to go deep into biochemical pathways; the point is to build a causal intuition of “condition → process → product.” The interactive variables can be abstracted as:

    • Light: present / absent
    • Carbon dioxide: sufficient / insufficient
    • Water: sufficient / lacking
    • Observation indicators: number of bubbles produced, color change in the leaf starch test, volume of oxygen collected, and other schematic displays

    Technically there is no need to pursue a physically accurate simulation. It is enough to guarantee that “changing one variable keeps the others constant” and to visualize the difference in feedback.

    2.3 Suggested Page Modules

    A minimum viable interactive lab usually contains four areas:

    1. Goal and task area: one sentence stating the inquiry question for this session;
    2. Variable control area: radio buttons or switches that enforce changing only one variable at a time;
    3. Experiment visualization area: results and differences presented with graphics and numbers;
    4. Inquiry record area: text fields where students write hypothesis, observation, and conclusion, closing the loop across the six stages.

    3. Implementation Approach: Let AI Generate a Prototype, Then Tighten the Constraints

    3.1 Start with a “Runnable Minimum Prototype”

    When making the request, ask the AI coding tool for a single-file web prototype so it is quick to open and iterate on:

    1. Generate a single-file HTML page (with inline CSS and JS) that implements an
    2. interactive photosynthesis controlled-experiment bench:
    3. - The variable control area allows only one variable to be changed at a time;
    4. - After clicking "Start Experiment", show the differences with animation and numbers;
    5. - Provide text fields for recording hypothesis / observation / conclusion;
    6. - Keep the interface simple and suitable for middle school students.

    3.2 Use a “State–Rules–Feedback” Structure