Hands-on science education for African universities β no physical lab required.
29 interactive experiments across 5 disciplines, an AI lab assistant, and real analytics,
served from the Cloudflare edge to any device, even on flaky connections.
- Overview
- Key Features
- Experiment Catalogue
- Architecture
- Tech Stack
- Getting Started
- Project Structure
- Testing
- Roadmap
- Contributing
- License
Laboratory access is one of the biggest bottlenecks in African science education: equipment is scarce, consumables are expensive, and a single broken centrifuge can sideline an entire cohort. AfriLab closes that gap with a fully simulated laboratory platform where students perform real experimental procedure β titrating, pipetting, wiring circuits, reading ECGs β in the browser, with measurement recording, AI-guided hints, and instructor oversight built in.
The whole platform is a single SvelteKit application deployed to Cloudflare Pages, backed by D1 (SQLite at the edge), KV sessions, R2 asset storage, and Workers AI for tutoring. It ships as an installable PWA with offline support, so learning doesn't stop when the connection does.
- 29 interactive simulations, 5 disciplines β Chemistry, Biology, Physics, Pharmacy, and Medical labs with step-guided procedures, 3D equipment (Three.js), safety banners, timers, and data recorders.
- AI lab assistant β a context-aware tutor powered by Cloudflare Workers AI (
@cf/meta/llama-3.1-70b-instruct) that knows your discipline, experiment, current step, and recent measurements β and gives progressive hints instead of answers. - Progress & analytics β measurement recording, lab reports, certificates, a student dashboard with history and progress tracking, a leaderboard, and an instructor analytics view.
- Collaboration β presence indicators and a collaboration panel so students can work together in the lab.
- Offline-first PWA β installable, with a service worker, offline page, and connection indicator.
- Multi-institution by design β institution registry, role-based access (student / instructor / admin), enrollments, assignments, and Google OAuth sign-in alongside email/password auth.
Every experiment below has a working simulation engine in src/lib/simulations/ and a lab route under src/routes/labs/.
| Discipline | Experiments |
|---|---|
| Chemistry | AcidβBase Titration Β· UV-Vis Spectroscopy Β· Calorimetry Β· Chromatography Β· Electrochemistry Β· Organic Synthesis |
| Biology | Microscopy Β· DNA Extraction Β· Cell Division Β· Enzyme Kinetics Β· Genetics Β· Photosynthesis Β· Ecosystem |
| Physics | Ohm's Law Β· Optics Β· Pendulum Β· Projectile Motion Β· Thermodynamics Β· Wave Motion |
| Pharmacy | Compounding Β· Dosage Calculations Β· Drug Interactions Β· Pharmacokinetics Β· Quality Control |
| Medical | Auscultation Β· Blood Analysis Β· ECG Reading Β· Patient Assessment Β· Vital Signs |
AfriLab runs entirely on Cloudflare's edge network β there is no separate backend to deploy:
| Layer | Technology | Role |
|---|---|---|
| Frontend & SSR | SvelteKit 2 + Svelte 5 on Cloudflare Pages | Server-rendered UI, lab routes, dashboards |
| API | SvelteKit server routes (/api/*) |
AI chat & hints, analytics, demo lifecycle, seeding |
| Database | Cloudflare D1 (SQLite) | Users, institutions, experiments, sessions, measurements, assessments |
| Sessions & cache | Cloudflare KV | Low-latency session storage |
| Object storage | Cloudflare R2 | 3D models, videos, and lab assets |
| AI | Cloudflare Workers AI | Llama 3.1 70B lab assistant and adaptive hints |
| Auth | Custom sessions + Google OAuth 2.0 | Email/password and institutional Google sign-in |
| 3D rendering | Three.js | Interactive lab equipment (beakers, burettes, flasks) |
| Category | Choice |
|---|---|
| Framework | SvelteKit 2, Svelte 5, Vite 6 |
| Language | TypeScript |
| Styling | Tailwind CSS 3 (+ forms & typography plugins) |
| Platform | Cloudflare Pages via @sveltejs/adapter-cloudflare |
| Data | D1, KV, R2 |
| AI | Workers AI (@cf/meta/llama-3.1-70b-instruct) |
| 3D | Three.js |
| Unit tests | Vitest + Testing Library |
| E2E tests | Playwright |
- Node.js 18+
- A Cloudflare account with the Wrangler CLI (
npm install -g wrangler)
# 1. Clone
git clone https://github.com/ghwmelite-dotcom/AfriLab.git
cd AfriLab
# 2. Install dependencies
npm install
# 3. Create the Cloudflare resources
wrangler d1 create afrilab-db
wrangler kv:namespace create SESSIONS
wrangler r2 bucket create afrilab-assets
# 4. Copy the generated IDs into wrangler.toml
# 5. Apply the database schema and seed data
npm run db:migrate # local D1
npm run db:migrate:prod # production D1
# 6. Run the dev server
npm run devTo run with real Cloudflare bindings locally:
npm run build
npm run preview:wranglerFor Google sign-in, set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET as secrets and configure GOOGLE_REDIRECT_URI (see the comments in wrangler.toml). Without them, email/password auth still works.
npm run deploy # builds and deploys to Cloudflare Pagesafrilab/
βββ migrations/ # D1 schema + seed migrations (0001β0005)
βββ src/
β βββ lib/
β β βββ components/
β β β βββ ai/ # Chat assistant & hint button
β β β βββ analytics/ # Dashboard & page tracking
β β β βββ collaboration/ # Presence & collaboration panel
β β β βββ lab/ # Lab canvas, 3D equipment, data recorder, certificates
β β β βββ layout/ # Header, sidebar, footer
β β β βββ onboarding/ # First-run experience
β β β βββ pwa/ # Install prompt & offline indicator
β β β βββ ui/ # Shared UI primitives
β β βββ server/ # auth, OAuth, db, AI prompt builders & hints
β β βββ simulations/ # 29 experiment engines, one file each
β β β βββ biology/ chemistry/ medical/ pharmacy/ physics/
β β βββ stores/ # Svelte stores (lab, AI, user, theme, notificationsβ¦)
β β βββ types/ # Shared TypeScript definitions
β β βββ utils/ # Helpers (incl. Three.js utilities)
β βββ routes/
β β βββ api/ # ai/chat, ai/hint, analytics, demo-login, demo-cleanup, seed
β β βββ auth/ # login, register, logout, Google OAuth flow
β β βββ dashboard/ # student home, labs, progress, history, leaderboard, profile
β β βββ instructor/ # students, assignments, analytics
β β βββ labs/ # 29 lab pages across 5 disciplines
β β βββ admin/ # admin & seeding
β β βββ offline/ # offline fallback page
β βββ hooks.server.ts # session resolution
β βββ service-worker.ts # PWA offline support
βββ e2e/ # Playwright end-to-end suites
βββ static/ # favicon, web manifest, service worker assets
βββ docs/ # documentation & assets (incl. this README's artwork)
βββ wrangler.toml # Cloudflare bindings & configuration
npm run test:run # unit tests (Vitest, single run)
npm run test:coverage # unit tests with coverage
npm run test:e2e # Playwright end-to-end tests
npm run test:e2e:ui # Playwright interactive UI mode- Expand the experiment catalogue (organic synthesis pathways, more medical scenarios)
- Richer instructor tooling: rubric-based grading and cohort comparisons
- Real-time multiplayer lab benches
- Localized content for more African languages
- LMS integration (LTI) for universities
Contributions are welcome β from new simulations to accessibility fixes.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-experiment - Make your changes (TypeScript, follow the existing code style, add tests for new behavior)
- Run
npm run test:runandnpm run build - Open a pull request
Please report bugs and request experiments via GitHub Issues.
Distributed under the MIT License. See LICENSE for details.
Built for African education.
Powered by SvelteKit and the Cloudflare edge.