Offline-First AI Learning Platform for Rural Schools in India
P.E.E.R ("Peer-to-Peer Education & Energy Resource") is a complete open-source learning platform designed to work 100% offline after initial setup. It combines local AI inference, peer-to-peer sync, multi-language support, and gamification to empower students in rural areas with limited internet connectivity.
- 100% Offline Operation - Works without internet after first sync
- Local AI Tutor - 4-bit quantized Gemma-2B/Phi-3-mini running on-device
- RAG Pipeline - Semantic search over NCERT textbooks
- Multi-Language - Hindi, English, Tamil, Telugu, Bengali (speech + text)
- P2P Sync - Bluetooth & Wi-Fi Direct device-to-device sync
- Gamification - Points, badges, streaks, knowledge credits
- Peer Tutoring - Encrypted chat and micro-tutoring marketplace
- Teacher Dashboard - Mastery heatmaps and class analytics
- Cross-Platform - React PWA (web) + React Native (mobile) sharing 90% code
- ESP32 Integration - BLE-connected hardware for reminders
Frontend:
- React 18 + TypeScript
- Vite (web) + Expo (mobile)
- NativeWind v4 (Tailwind CSS) for mobile styling
- React Router for navigation
- Recharts for data visualization
Data Layer:
- SQLite (sql.js for web, expo-sqlite for mobile)
- Yjs CRDT for offline-first sync
- IndexedDB for persistence
AI & ML:
- llama.cpp WebAssembly (web)
- ONNX Runtime (mobile)
- ChromaDB-lite for vector search
- Vosk (speech-to-text)
- Piper (text-to-speech)
Sync & P2P:
- Bluetooth Low Energy
- Wi-Fi Direct (Android)
- End-to-end encryption
Hardware:
- ESP32 BLE firmware (Arduino)
- Vibration motor + LED + light sensor
peer/
├── apps/
│ ├── web/ # React + Vite PWA
│ │ ├── src/
│ │ │ ├── pages/ # Dashboard, Learn, Chat, Profile
│ │ │ ├── components/ # Shared UI components
│ │ │ └── main.tsx # Entry point
│ │ ├── vite.config.ts # PWA configuration
│ │ └── package.json
│ │
│ ├── mobile/ # React Native Expo app
│ │ ├── App.tsx # Main app with navigation
│ │ ├── app.json # Expo configuration
│ │ ├── src/screens/ # Mobile screens
│ │ └── package.json
│ │
│ └── admin/ # Next.js Admin Portal
│ ├── app/ # Next.js app directory
│ ├── components/ # Admin UI components
│ ├── prisma/ # Database schema
│ ├── Dockerfile # Docker configuration
│ ├── docker-compose.yml # Docker Compose setup
│ └── package.json
│
├── packages/
│ ├── shared/ # Types, constants, utilities
│ ├── db/ # SQLite schema & client
│ ├── sync/ # Yjs CRDT sync logic
│ ├── ai/ # AI inference (llama.cpp, ONNX)
│ ├── rag/ # RAG pipeline (PDF, chunking, embeddings)
│ ├── speech/ # Vosk STT + Piper TTS
│ ├── gamification/ # Points, badges, credits
│ └── p2p/ # Bluetooth/Wi-Fi Direct sync
│
├── firmware/
│ └── esp32/ # Arduino BLE firmware
│ ├── vidyut_bandhu.ino
│ └── README.md
│
├── data/
│ └── ncert-excerpts/ # Sample textbook content
│ ├── class6-math.txt
│ └── class6-science.txt
│
├── scripts/
│ ├── seed-db.ts # Database seeding
│ └── process-textbooks.ts # PDF processing pipeline
│
├── docs/
│ ├── ARCHITECTURE.md # System architecture
│ ├── DEPLOYMENT.md # Deployment guide
│ └── OFFLINE_STRATEGY.md # Offline-first design
│
├── package.json # Root workspace config
├── pnpm-workspace.yaml
└── README.md # This file
Ensure you have the following installed on your system:
Required:
- Node.js 18+ - Download
- pnpm 8+ - Install globally:
npm install -g pnpm
Optional (depending on what you want to run):
- Docker & Docker Compose - For the Admin portal (Download)
- Android Studio - For mobile app on Android (Download)
- Xcode - For mobile app on iOS (macOS only, Download)
- Arduino IDE with ESP32 support - For hardware integration (Download)
# Clone the repository
git clone https://github.com/yourusername/peer.git
cd peer
# Install all workspace dependencies
pnpm installThis will install dependencies for all packages and apps in the monorepo.
# Build all packages (required before running apps)
pnpm buildThis compiles:
- Shared packages (
@vidyut/shared,@vidyut/db, etc.) - Admin portal (Next.js)
- Web app (Vite + React)
Expected output: All packages should build successfully with exit code 0.
If you want to use the admin portal for managing students and tracking performance:
-
Create
.envfile inapps/admin/:cd apps/admin cp .env.example .env # or create manually
-
Add the following to
.env:POSTGRES_USER=vidyut POSTGRES_PASSWORD=your_secure_password POSTGRES_DB=vidyut_admin DATABASE_URL=postgresql://vidyut:your_secure_password@localhost:5432/vidyut_admin
-
Start with Docker:
docker-compose up -d
- Install PostgreSQL locally
- Create database:
createdb vidyut_admin - Set up
.envas above - Run migrations:
cd apps/admin pnpm prisma db push pnpm prisma db seed # Optional: seed with sample data
AI models are not included in the repository due to size. Download them if you want offline AI features:
# Run the download script (requires wget and unzip)
chmod +x scripts/download-models.sh
./scripts/download-models.shThis downloads:
- Gemma-2B 4-bit GGUF (~1.6GB) for web AI inference
- Vosk speech models (~40MB each) for English and Hindi
Note: Mobile ONNX models (Phi-3-mini) must be downloaded manually from HuggingFace and placed in apps/mobile/assets/models/.
# Development mode
pnpm dev:web
# Production build
pnpm build:web
cd apps/web/dist
python3 -m http.server 8080Open http://localhost:5173 (dev) or http://localhost:8080 (prod)
Installing as PWA:
- Open the web app in Chrome/Edge
- Click the install icon in the address bar
- The app will work offline after installation
cd apps/mobile
# Start Expo dev server
pnpm start
# Run on Android (requires Android Studio/emulator)
pnpm android
# Run on iOS (macOS only, requires Xcode)
pnpm iosScan the QR code with Expo Go app (Android | iOS) or use an emulator.
cd apps/admin
# Development mode
pnpm dev
# Or with Docker
docker-compose up -dDefault credentials (if using seed data):
- Email:
admin@vidyut.org - Password:
admin123
Build fails with TypeScript errors:
# Clean and rebuild
pnpm clean
pnpm install
pnpm buildPort already in use:
- Web: Change port in
apps/web/vite.config.ts - Admin: Set
PORT=3001in.env - Mobile: Expo will automatically find an available port
Models not downloading:
- Ensure
wgetandunzipare installed - Check internet connection
- Download manually from the URLs in
scripts/download-models.sh
Docker issues:
- Ensure Docker daemon is running
- Check ports 5432 (PostgreSQL) and 3000 (Next.js) are available
- Run
docker-compose logsto see error details
-
Hardware Needed:
- Raspberry Pi 4 (4GB+ RAM)
- MicroSD card (32GB+)
- Power supply
- Optional: Battery backup
-
Setup:
# Install Node.js on Raspberry Pi curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs # Clone and build git clone https://github.com/yourusername/peer.git cd peer npm install -g pnpm pnpm install pnpm build:web # Serve the app cd apps/web/dist python3 -m http.server 8080
-
Access:
- Students connect to Pi's Wi-Fi hotspot
- Open browser to
http://192.168.x.x:8080 - Install PWA for offline use
-
Build the APK:
cd apps/mobile npx expo build:android -
Distribute APK to tablets via USB or local file sharing
-
Students install and use offline
-
Initial Setup (with internet):
- Download all models and content
- Seed database with NCERT textbooks
- Build and test the app
-
Distribution:
- Copy built app + models to USB drives
- Distribute to schools
- Students copy to their devices
-
P2P Sync:
- Students sync progress via Bluetooth
- No internet required after setup
# Process NCERT PDFs
pnpm process-textbooks
# Seed database
pnpm seed-dbpnpm test# Lint
pnpm lint
# Format
pnpm formatSee firmware/esp32/README.md for detailed instructions.
Quick Summary:
- Flash the Arduino sketch to ESP32
- Pair with mobile app via Bluetooth
- Set reminder times in app
- Device vibrates/blinks LED at study times
- Quiz correct answer: 10 points
- First try bonus: +5 points
- Daily login: 5 points
- 7-day streak: 20 points bonus
- Content completion: 50 points
- Mastery achieved: 100 points
- First Steps - Complete first lesson
- Week Warrior - 7-day streak
- Math Master - Master 10 math topics
- Science Explorer - Complete 20 science topics
- Helpful Friend - Help 5 peers
- Point Collector - Earn 1000 points
- Earn credits by helping peers
- Spend credits to get help from advanced students
- Creates a peer tutoring economy
- English
- हिंदी (Hindi)
- தமிழ் (Tamil)
- తెలుగు (Telugu)
- বাংলা (Bengali)
Both UI and voice support for all languages.
- Data Layer: SQLite for structured data, IndexedDB for blobs
- Sync Layer: Yjs CRDT for conflict-free merging
- Network Layer: Works offline, syncs when online
- P2P Layer: Bluetooth/Wi-Fi Direct for device-to-device sync
User Question
↓
RAG Retrieval (ChromaDB-lite)
↓
Context + Question → Prompt
↓
Local AI Model (Gemma/Phi-3)
↓
Response
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
MIT License - see LICENSE for details.
- NCERT for public domain textbooks
- Vosk for offline speech recognition
- Piper for offline TTS
- llama.cpp for efficient inference
- The open-source community
- 📧 Email: support@peer.org
- 💬 Discord: Join our community
- 🐛 Issues: GitHub Issues
- Support for more Indian languages (Kannada, Malayalam, Marathi)
- Offline video lessons
- Handwriting recognition for math problems
- Integration with government education portals
- Solar-powered ESP32 version
- Mesh networking for multi-device sync
Built with love for rural education in India
"Empowering every student, everywhere, even offline"