Grio AI Education Platform - Technical Architecture Overview
Document Type: Internal Technical Specification Last Updated: 2026-03-24 Status: Active Development Audience: Engineering Team
1. System Overview
Grio is built on a 6-layer architecture designed for scalability, offline resilience, and strict curriculum governance. Each layer is independent but communicates through well-defined contracts.
Architecture Layers
┌─────────────────────────────────────────────────────────┐
│ CLIENT LAYER │
│ Classroom (TV+PC) | Student Web/Mobile | Teacher Portal│
└──────────────────────┬──────────────────────────────────┘
│ HTTPS/WebSocket
┌──────────────────────▼──────────────────────────────────┐
│ API GATEWAY │
│ Auth | Rate Limit | Routing | Request Validation │
└──────────────────────┬──────────────────────────────────┘
│ gRPC/REST
┌──────────────────────▼──────────────────────────────────┐
│ BACKEND SERVICES LAYER │
│ User | Session | Learning | Assessment | Content | Analytics
└──────────────────────┬──────────────────────────────────┘
│
┌──────────────────────┴──────────────────────────────────┐
│ AI & CURRICULUM ENGINE LAYER │
│ Intent Detection | RAG | Tutoring Logic | Mode Router │
└──────────────────────┬──────────────────────────────────┘
│
┌──────────────────────┴──────────────────────────────────┐
│ DATA LAYER │
│ PostgreSQL | Qdrant | MinIO | Redis │
└──────────────────────┬──────────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────────┐
│ INTEGRATION LAYER (Future) │
│ Ministry Systems | UNEB | School Management │
└─────────────────────────────────────────────────────────┘2. Client Layer
2.1 Classroom Interface (TV + Mini PC)
Primary Use: Real-time classroom instruction via browser-based application.
UI Structure: - Top Bar (Context Lock): Displays current curriculum context: Class → Subject → Topic → Subtopic. Read-only indicator of system constraints. - Center Panel (Learning Area): Main content delivery. Mode-dependent rendering (Teach → Explore → Practice → Revision). - Avatar Position: Character positioning varies by learning mode and engagement state. - Bottom Mode Bar: Visual indicator + toggle controls for Learn/Explore/Practice/Revision modes. Teach mode locked by default.
Key Constraints: - Browser-based (Chromium, Firefox, Safari supported) - Requires persistent network connection during lessons - WebSocket for real-time teacher control (pause, advance, broadcast messages) - Touch-enabled for interactive elements
2.2 Student Interface (Web + Mobile)
Primary Use: Home learning, progress tracking, content review.
Dashboard Components: - Continue Learning: Resume interrupted lessons (session state from Classroom or home) - Subject List: Categorized by enrolled classes - Progress Tracking: Visual indicators (% complete per topic, streaks, badges) - Responsive Design: Mobile-first for offline-capable caching
2.3 Teacher Portal (Web Dashboard)
Administrative Functions: - Class management (roster, section grouping) - Content upload (curriculum override, supplementary materials) - Assignment creation and distribution - Real-time classroom control (monitor student responses during Practice Mode) - Performance analytics (class-wide progress, individual learner reports) - Session review (playback of classroom interactions for training purposes)
2.4 Admin Interface (Future Phase)
Planned for school administration and ministry-level reporting.
3. Backend Architecture
3.1 API Gateway
Responsibilities: - Authentication: JWT token validation, session management - Authorization: Role-based access control (RBAC) enforcement - Rate Limiting: Per-user, per-endpoint quotas (prevent abuse) - Routing: Service discovery, load balancing - Request Validation: Schema enforcement, sanitization - Protocol Support: REST (primary), gRPC (internal service-to-service)
Stack: Nginx or AWS API Gateway (production) → Django REST middleware (staging)
3.2 Core Microservices
Each service owns its data schema. Services communicate via REST APIs or gRPC.
User Service
- Manages authentication (JWT issue/refresh), user profiles, role assignment
- Handles multi-tenancy (school-level isolation)
- Endpoints:
POST /auth/login,POST /auth/refresh,GET /users/{id},PATCH /users/{id}
Classroom Session Service
- Manages session lifecycle (create, update, close)
- Tracks current lesson, mode, progress within lesson
- Stores interaction history for each classroom
- Endpoints:
POST /sessions,GET /sessions/{id},PATCH /sessions/{id}/mode,POST /sessions/{id}/interactions
Learning Service
- Orchestrates lesson delivery logic
- Manages learning mode transitions
- Retrieves curriculum content from Content Service
- Calls AI Engine for responses
- Endpoints:
GET /lessons/{id},POST /lessons/{id}/next-step,GET /topics/{id}/progress
Assessment Service
- Evaluates student responses (Practice Mode)
- Computes scores, generates feedback
- Tracks mastery of individual objectives
- Endpoints:
POST /assessments/evaluate,GET /assessments/{id}/results
Content Service
- Serves curriculum hierarchy: Curriculum → Class → Subject → Topic → Subtopic → Lesson → LessonContent
- Manages content metadata (learning objectives, prerequisites)
- Supports content versioning and overrides
- Endpoints:
GET /curriculums,GET /classes/{id}/subjects,GET /subjects/{id}/topics,GET /lessons/{id}
Analytics Service
- Aggregates engagement metrics, learning progress, anomalies
- Powers teacher dashboards and reporting
- Integrates with Data Layer (PostgreSQL + Redis)
- Endpoints:
GET /analytics/class/{id},GET /analytics/student/{id}/progress
3.3 Backend Stack
- Language: Python 3.11+
- Framework: Django 4.2+ with Django REST Framework
- Authentication: JWT (PyJWT) + OAuth 2.0 (optional SSO integration)
- Task Queue: Celery + Redis (async operations, scheduled jobs)
- Container: Docker + Docker Compose (local), Kubernetes (production)
3.4 API Patterns (RESTful)
GET /classes # List enrolled classes
GET /classes/{classId}/subjects # Subjects for a class
GET /subjects/{subjectId}/topics # Topics within subject
GET /topics/{topicId} # Topic detail + learning objectives
GET /lessons/{lessonId} # Full lesson content
POST /lessons/{lessonId}/start-teach # Begin Teach Mode
POST /sessions/{sessionId}/respond # Submit student response
GET /sessions/{sessionId}/progress # Current session progress4. AI Architecture (3 Layers)
4.1 Base Layer: Language Model
Phase 1 (Current): OpenAI API (GPT-4/3.5-turbo) via official SDK Phase 2+ (Future): Self-hosted LLaMA 2/Mistral 7B for cost optimization and offline capability
Selection Criteria: - Output quality (instruction-following, mathematical reasoning) - Latency (<2 seconds for classroom interactivity) - Cost efficiency at scale - Context window (minimum 4K for curriculum + chat history)
4.2 Middle Layer: RAG (Retrieval-Augmented Generation)
Architecture: - Vector Store: Qdrant (open-source, scalable vector database) - Embedding Model: OpenAI text-embedding-3-small or MiniLM (self-hosted) - Curriculum Embeddings: All curriculum content (topics, examples, definitions) pre-embedded at content publish time
RAG Flow: 1. Student query or system prompt triggers retrieval 2. Embed user input using same model as curriculum embeddings 3. Query Qdrant with top-k semantic search (k=5-10 results) 4. Return relevant curriculum context to prompt construction
Critical: RAG is MANDATORY. AI responses must never be generated without curriculum context. Enforced at prompt construction layer.
4.3 Top Layer: Grio Tutoring Engine
Custom orchestration logic that combines intent detection, mode routing, and curriculum constraints.
AI Flow (Per User Input)
Student Input (text/voice)
↓
Intent Detection
├─ Teach Mode action (e.g., "next step")
├─ Explore Mode query (e.g., "what is photosynthesis?")
├─ Practice Mode response (e.g., answer to multiple choice)
└─ Out-of-scope (e.g., "tell me a joke")
↓
Mode Identification + Curriculum Context Retrieval
├─ Current topic/subtopic from session state
└─ RAG query for relevant learning content
↓
System Prompt Construction
├─ Base prompt (role: age-appropriate tutor)
├─ Curriculum constraints (stay within topic, follow learning path)
├─ Mode rules (e.g., Practice Mode: only feedback, no hints)
└─ Conversation history (last 5 exchanges)
↓
LLM Request (OpenAI API or self-hosted)
↓
Post-Processing
├─ Content safety scan (filter offensive/off-topic)
├─ Response truncation (max 150 tokens for classroom)
└─ Format to UI (markdown → HTML, inject avatar gestures)
↓
UI Output → Classroom/Student DeviceSystem Prompt Manager
Centralized, versioned system prompts for each combination of: - Age group (Primary 1-3, 4-6; Secondary 1-2, 3-4) - Curriculum (Uganda NCDC, Zambia ZEC, Kenya CBC) - Learning mode (Teach, Explore, Practice, Revision) - Subject domain (Mathematics, English, Science, etc.)
Constraints Enforced: - Topic-locking: never stray from current topic without explicit permission - Age-appropriate language and examples - Curriculum-aligned learning objectives only - Avoid hallucinations (verified facts from curriculum only)
Teaching Strategy (Grio Approach)
Each structured lesson follows: 1. Review: Recap prerequisites (bullet points, 30 seconds) 2. Introduce: New concept explanation (plain language, one analogy) 3. Examples: 2-3 concrete examples (contextualized to student’s environment) 4. Questions: Socratic questioning to check understanding (1-2 probing questions) 5. Practice: Guided practice (worksheet-style, immediate feedback)
Modes shortcut this: Explore skips steps 1 & 5; Practice starts at step 5; Revision shows only step 1.
5. Curriculum Engine
5.1 Hierarchy
Curriculum (Uganda NCDC, Zambia ZEC, Kenya CBC, etc.)
└─ Class (Primary 1, Secondary 2, etc.)
└─ Subject (Mathematics, English, Science)
└─ Topic (Fractions, Photosynthesis)
└─ Subtopic (Equivalent Fractions, Plant Adaptation)
└─ Lesson (Understanding Equivalent Fractions)
└─ LessonContent
├─ Text blocks
├─ Examples (AI-generated or static)
├─ Practice questions
├─ Video references (future)
└─ Learning objectives5.2 Multi-Curriculum Support
- Uganda NCDC: Primary 1-6, Secondary 1-4
- Zambia ZEC: Primary 1-7, Secondary 1-4
- Kenya CBC: Grade 1-6 (Primary), Form 1-4 (Secondary)
Each curriculum version is independently versioned. Schema supports curriculum overrides by teachers.
5.3 Content Types
- Text: Explanations, definitions (author-written, reviewed)
- Examples: Contextualized scenarios (local currency, familiar objects)
- Practice Questions: Multiple choice, short answer (with expected answers)
- AI-Generated Explanations: On-demand, constrained by prompt (future enhancement)
- Videos: Embedded or linked (Phase 2)
5.4 Learning Objectives Mapping
Every lesson, topic, and question maps to one or more learning objectives from the national curriculum. This ensures: - Student progress tracks mastery of official objectives - Teacher reports align with ministry expectations - Assessment rubrics are standardized
6. Learning Modes System
6.1 Teach Mode
Default for Classroom
- Structured lesson delivery with explicit steps
- Student sees one question/prompt at a time
- “Next” button advances to next step (teacher controls pace or auto-advance)
- AI response generated from tutoring engine
- No chat interface; linear progression
6.2 Explore Mode
Student-driven Q&A
- Free-form chat/voice interface
- Student asks questions about current topic
- AI provides contextual answers (curriculum-anchored via RAG)
- Can branch into adjacent topics if semantically related
- Conversation history retained in session
6.3 Practice Mode
Assessment-focused
- One question per screen
- Multiple choice or short answer
- Immediate feedback (correct/incorrect + explanation)
- No hints (enforced; prevents answer-guessing)
- Score computed per question, aggregated for mastery tracking
6.4 Revision Mode
Rapid recall
- Bullet-point summaries of topic (auto-generated from curriculum)
- Rapid-fire flashcard-style questions
- Minimal explanation (reinforce memory)
- Speed-based scoring (faster correct answers = higher score)
6.5 Exam Prep Mode (Planned)
- Past papers retrieval
- Timed test conditions
- Scoring aligned with official exam rubrics
7. Data Architecture
7.1 PostgreSQL (Primary Relational DB)
Tables (Core): - users (id, email, role, school_id, created_at) - schools (id, name, region, subscription_tier) - classes (id, school_id, name, grade, teacher_id) - student_enrollments (student_id, class_id, enrollment_date) - curriculums (id, country_code, version, status) - curriculum_structure (id, curriculum_id, class_id, subject_id, topic_id, subtopic_id, lesson_id) - lessons (id, content, learning_objectives, metadata_json) - student_progress (student_id, lesson_id, status, score, last_accessed) - classroom_sessions (id, class_id, lesson_id, mode, start_time, end_time, interactions_count) - session_interactions (id, session_id, student_id, input, ai_response, timestamp)
Multi-Tenancy: Row-Level Security (PostgreSQL) enforces school isolation.
7.2 Qdrant (Vector Database)
Purpose: Semantic search for curriculum content during RAG
Collections: - curriculum_embeddings (one document per curriculum lesson + example) - Metadata: curriculum_id, class_id, topic_id, content_type, version
Operations: - Batch upsert on curriculum content changes - Similarity search (cosine) on student queries - TTL policies for old/deprecated content versions
7.3 MinIO (S3-Compatible Object Storage)
Use Cases: - Lesson media (images, PDFs, videos) - Student work samples (scanned worksheets) - Session transcripts/recordings (future)
Buckets: - curriculum-assets (immutable, versioned) - student-uploads (private per student) - session-media (classroom recordings)
7.4 Redis (Caching Layer)
Use Cases: - Session state caching (reduces PostgreSQL queries during rapid interactions) - Rate limit counters (API Gateway) - Temporary curriculum context (current lesson, topic, student progress snapshot) - Task queue (Celery)
TTL: 1 hour for session data, 24 hours for curriculum snapshots
8. Integration Layer (Future Phase)
Planned integrations with external systems:
- Ministry of Education Systems: Curriculum publication, reporting dashboards
- UNEB / Exam Bodies: Past papers retrieval, official learning objectives
- School Management Systems (SMS): Rostering (automated student/teacher sync), attendance
Design Principle: Integrations are decoupled via adapters. Core platform functions independently.
9. Cross-Cutting Concerns
9.1 Authentication & Authorization
Authentication: - JWT tokens (issued by User Service upon login) - Token refresh: 15-minute access token, 7-day refresh token - OAuth 2.0 support (optional, for SSO with school systems)
Authorization (RBAC): - Super Admin: Full platform access (Grio staff) - School Admin: School-level user management, curriculum overrides, analytics - Teacher: Class management, lesson delivery control, student progress view - Student: Access own progress, enroll in classes, Explore/Practice modes - Independent Learner: Trial/freemium (limited class enrollments)
Enforcement: API Gateway validates token + route → role mapping on every request.
9.2 Multi-Tenancy
Model: Row-Level Security (RLS) in PostgreSQL
- All tables have
school_idcolumn - PostgreSQL policies restrict row visibility by school
- Student cannot see data from other schools
- Teacher cannot view classes outside their school
Application Level: - API Gateway injects school_id from JWT into request context - All queries automatically filtered by school
9.3 Grio Continuity (Session State Persistence)
Students can switch between Classroom → Home → Holidays without losing progress:
- Classroom Session: Stored in classroom-session service + Redis
- Student Home Session: Mirrors classroom progress (via API call at lesson end)
- Session Resume: Student selects “Continue Learning” → fetches last incomplete lesson
- Offline Syncing (Future): Mobile app caches session state; syncs when online
Mechanism: - Session state object: { lesson_id, subtopic_id, step_in_lesson, mode, last_response_time } - Updated in real-time to PostgreSQL (async via Celery task) - Upon lesson completion, session closes; student can resume next lesson
10. Critical Engineering Rules
Rule 1: AI Must NEVER Run Without Curriculum Context (RAG Enforced)
Implementation: - Every AI request requires curriculum_context_id parameter (enforced at API Gateway) - Prompt construction layer queries Qdrant before calling LLM - If RAG returns no results, return fallback response (e.g., “I’m not sure. Let’s review the lesson together.”) instead of asking LLM to improvise - Logging/monitoring alerts if RAG query returns zero results (content gap detected)
Rule 2: All Services Must Be Containerized
- Every microservice: dedicated Dockerfile
docker-compose.ymlfor local development (all services + databases)- Kubernetes manifests (production) with resource limits, health checks, rolling updates
- Container registry: Docker Hub or ECR (private)
Rule 3: System Must Support Offline Extension (Design Now)
Current platform is online-only, but architecture permits future offline mode:
- Curriculum content must be serializable to lightweight JSON/SQLite (not tied to PostgreSQL)
- Session state uses common schema (not database-specific)
- Service boundaries allow for local-only services (e.g., Teach Mode engine runs locally)
- Media storage (MinIO) design allows for local cache of frequently-used assets
Rule 4: AI Logic, Curriculum Engine, Application Logic Must Be Separate Services
- AI Service: Isolated container, only handles LLM/RAG/prompt construction
- Curriculum Service: Manages content hierarchy, versioning, embeddings
- Application Logic (Learning Service): Orchestrates mode transitions, progress updates
- Separation Benefits: Independent scaling, version control, testing, potential offline deployment
Rule 5: Classroom Always Starts in Teach Mode, Never Chat
- UI disables mode toggle at session start
- First student input in classroom must be within Teach Mode structure (no free-chat queries)
- Teacher can authorize mode switch to Explore (future: per-student, per-topic permissions)
- Ensures pedagogical integrity and prevents off-task behavior during instruction
Deployment Architecture (Reference)
Local Development:
docker-compose up -d # Starts all services, DBs, cachesStaging (AWS/GCP): - ECS/GKE for container orchestration - RDS for PostgreSQL, Elasticache for Redis - S3 for media (MinIO mock locally)
Production (Future): - Kubernetes cluster (self-managed or managed service) - CDN for static assets (teacher portal, videos) - Monitoring: Prometheus + Grafana, ELK stack for logs
Glossary
- RAG: Retrieval-Augmented Generation (retrieve curriculum context before LLM inference)
- RLS: Row-Level Security (PostgreSQL feature for multi-tenancy)
- RBAC: Role-Based Access Control
- LLM: Large Language Model
- Qdrant: Vector database optimized for similarity search
- Curriculum Context: Topic + subtopic + learning objectives for current lesson
- Session State: Persistent data tracking student’s position in a lesson (lesson_id, step, mode, responses)
End of Document
Last reviewed: 2026-03-24 Next review: 2026-06-24 (or upon major architecture change)