chemX is an interactive chemistry practice web application designed for school students to explore basic reactions in a safe virtual lab. It combines guided learning missions with visual simulation effects such as color changes, bubbling, foam, and a browser-based 3D lab scene.
The project is built as a frontend-only learning experience for middle-school and early high-school chemistry practice. Students can open missions, select reagents, mix them in a virtual beaker, and observe the outcome through rule-based reaction logic and animated feedback.
This repository currently focuses on:
- Guided chemistry practice missions
- Rule-based reaction matching instead of a full chemistry engine
- Visual feedback for fizzing, glow, foam, precipitate, and liquid color changes
- A 3D lab view built with React Three Fiber
- Local progress saving with
localStorage
- Mission-based learning flow with hints and takeaways
- Curated reagent and reaction catalog for classroom-friendly chemistry concepts
- Virtual lab bench with selectable reagents
- 3D beaker scene with camera controls and animated reaction states
- Neutral feedback for unsupported combinations so students can still learn from observation
- Local persistence for completed missions and last-opened mission
- Unit and UI tests with Vitest and Testing Library
- React 19
- TypeScript
- Vite
- Vitest
- React Testing Library
- Three.js
- React Three Fiber
- Drei
src/
components/
LabScene3D.tsx
data/
missions.ts
reactions.ts
reagents.ts
lib/
reactionEngine.ts
test/
setup.ts
App.tsx
main.tsx
styles.css
types.ts
- Node.js 20+ recommended
- npm 10+ recommended
npm installnpm run devThen open the local URL shown by Vite in your browser.
npm run buildnpm run previewRun the automated test suite:
npm testThe test coverage currently includes:
- Reaction matching behavior
- Neutral outcome handling
- Lab reset behavior
- Mission completion flow
- Local progress persistence
chemX does not attempt full scientific fluid simulation. Instead, it uses a structured reaction catalog and deterministic visual states to create an educational, believable experience.
Each reaction definition includes:
- Reagent combination
- Container type
- Result message
- Safety note
- Mission tags
- Visual effect settings
The reaction engine resolves the selected reagents and maps them to a visual outcome shown in the lab scene.
- The chemistry logic is curated and rule-based, not exhaustive
- The 3D scene is optimized for browser compatibility, not advanced scientific realism
- Progress is stored only in the current browser
- No authentication, backend, or classroom dashboard yet
- More reagents and missions
- Better 3D lab assets and tools
- Drag-and-pour interactions
- Sound effects for bubbling and pouring
- Difficulty levels by student grade
- Teacher mode or classroom progress tracking
- Mobile-specific interaction improvements
npm run dev- start the Vite development servernpm run build- type-check and create a production buildnpm run preview- preview the production build locallynpm test- run the test suite oncenpm run test:watch- run tests in watch mode
Contributions are welcome if you want to improve the chemistry content, interaction design, 3D visuals, or educational flow. If you plan to expand the simulation model, keep the chemistry rules separate from the rendering layer so the app stays maintainable.
No license has been added yet. If you plan to make the repository public for reuse, consider adding one such as MIT.