Skip to content

ghwmelite-dotcom/AfriLab

Repository files navigation

AfriLab πŸ§ͺ

Africa's Premier Virtual Science Laboratory Platform

AfriLab is a comprehensive simulated laboratory platform designed for African universities, enabling students to perform hands-on science experiments in a safe, accessible virtual environment. Built entirely on Cloudflare's edge infrastructure with AI-powered tutoring.

SvelteKit Cloudflare TailwindCSS TypeScript


✨ Features

πŸ”¬ Virtual Laboratory Simulations

  • Chemistry Labs: Acid-base titrations, spectroscopy, organic synthesis
  • Biology Labs: Microscopy, virtual dissections, cell studies
  • Physics Labs: Mechanics, optics, circuit simulations
  • Pharmacy Labs: Drug compounding, dosage calculations, interactions
  • Medical Labs: Patient scenarios, diagnostic reasoning

πŸ€– AI-Powered Learning

  • Intelligent Lab Assistant: Powered by Cloudflare Workers AI (Llama 3.1)
  • Context-Aware Help: Understands your current experiment and progress
  • Adaptive Hints: Progressive guidance without giving away answers
  • Automated Assessment: AI-generated feedback on lab reports

πŸ“Š Progress Tracking

  • Real-time measurement recording
  • Performance analytics dashboard
  • Learning progress visualization
  • Institution-wide reporting for instructors

🏫 Multi-Institution Support

  • University registration codes
  • Role-based access (Student, Instructor, Admin)
  • SSO-ready architecture
  • Cross-institution analytics

πŸ—οΈ Architecture

AfriLab is built entirely on Cloudflare's ecosystem:

Component Technology Purpose
Frontend SvelteKit + Cloudflare Pages Fast, SEO-friendly UI
Database Cloudflare D1 (SQLite) Edge-located data storage
Sessions Cloudflare KV Low-latency session management
Assets Cloudflare R2 3D models, videos, documents
AI Cloudflare Workers AI Intelligent tutoring (Llama 3.1)
Compute Cloudflare Workers Serverless backend logic
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    CLOUDFLARE EDGE                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚  Pages  β”‚  β”‚   D1    β”‚  β”‚   KV    β”‚  β”‚   Workers AI    β”‚β”‚
β”‚  β”‚ (UI/SSR)β”‚  β”‚(SQLite) β”‚  β”‚(Sessionsβ”‚  β”‚   (Llama 3.1)   β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚       β”‚            β”‚            β”‚                β”‚          β”‚
β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β”‚                           β”‚                                  β”‚
β”‚                    β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”                          β”‚
β”‚                    β”‚   Workers   β”‚                          β”‚
β”‚                    β”‚  (API/Auth) β”‚                          β”‚
β”‚                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • npm or pnpm
  • Cloudflare account
  • Wrangler CLI (npm install -g wrangler)

Installation

  1. Clone the repository

    git clone https://github.com/ghwmelite-dotcom/AfriLab.git
    cd AfriLab
  2. Install dependencies

    npm install
  3. Create Cloudflare resources

    # Create D1 database
    wrangler d1 create afrilab-db
    
    # Create KV namespace
    wrangler kv:namespace create SESSIONS
    
    # Create R2 bucket (optional)
    wrangler r2 bucket create afrilab-assets
  4. Update wrangler.toml with your resource IDs

  5. Run database migrations

    npm run db:migrate        # Local
    npm run db:migrate:prod   # Production
  6. Start development server

    npm run dev      # Vite dev server
    npm run preview  # Wrangler preview with bindings

Deployment

npm run deploy

This builds the project and deploys to Cloudflare Pages.


πŸ“ Project Structure

afrilab/
β”œβ”€β”€ migrations/              # D1 database migrations
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ components/      # Svelte components
β”‚   β”‚   β”‚   β”œβ”€β”€ ai/          # AI chat interface
β”‚   β”‚   β”‚   β”œβ”€β”€ lab/         # Lab equipment components
β”‚   β”‚   β”‚   └── layout/      # Header, Sidebar, Footer
β”‚   β”‚   β”œβ”€β”€ server/          # Server-side utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.ts      # Authentication logic
β”‚   β”‚   β”‚   β”œβ”€β”€ db.ts        # Database helpers
β”‚   β”‚   β”‚   └── ai.ts        # AI prompt builders
β”‚   β”‚   β”œβ”€β”€ simulations/     # Experiment logic
β”‚   β”‚   β”‚   └── chemistry/   # Chemistry simulations
β”‚   β”‚   β”œβ”€β”€ stores/          # Svelte stores
β”‚   β”‚   β”œβ”€β”€ types/           # TypeScript definitions
β”‚   β”‚   └── utils/           # Helper functions
β”‚   └── routes/
β”‚       β”œβ”€β”€ api/             # API endpoints
β”‚       β”œβ”€β”€ auth/            # Login, Register, Logout
β”‚       β”œβ”€β”€ dashboard/       # Student dashboard
β”‚       β”œβ”€β”€ instructor/      # Instructor dashboard
β”‚       └── labs/            # Laboratory pages
β”œβ”€β”€ static/                  # Static assets
β”œβ”€β”€ wrangler.toml           # Cloudflare configuration
└── package.json

πŸ§ͺ Available Experiments

Chemistry

  • Acid-Base Titration - Learn volumetric analysis with phenolphthalein indicator
  • UV-Vis Spectroscopy - Beer-Lambert law and absorbance measurements
  • Organic Synthesis (coming soon)

Biology

  • Microscopy Basics (coming soon)
  • Virtual Dissection (coming soon)

Physics

  • Optics Lab (coming soon)
  • Circuit Simulation (coming soon)

Pharmacy

  • Drug Compounding (coming soon)
  • Pharmacokinetics (coming soon)

πŸ”§ Configuration

Environment Variables

Create a .dev.vars file for local development:

# Optional: Override defaults
APP_ENV=development

Cloudflare Bindings

The wrangler.toml file configures all Cloudflare services:

[[d1_databases]]
binding = "DB"
database_name = "afrilab-db"
database_id = "your-database-id"

[[kv_namespaces]]
binding = "SESSIONS"
id = "your-kv-namespace-id"

[[r2_buckets]]
binding = "STORAGE"
bucket_name = "afrilab-assets"

[ai]
binding = "AI"

🀝 Contributing

We welcome contributions from the community! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Development Guidelines

  • Follow the existing code style
  • Write TypeScript for type safety
  • Add tests for new features
  • Update documentation as needed

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Cloudflare - For providing the edge infrastructure
  • Svelte Team - For the amazing framework
  • African Universities - For inspiring this project

πŸ“ž Contact


Built with ❀️ for African Education
Powered by Cloudflare

About

Africa's Premier Virtual Science Laboratory Platform - Built on Cloudflare (D1, KV, R2, Workers AI). Interactive chemistry, biology, physics, pharmacy & medical simulations with AI-powered tutoring.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors