For Business OwnersEngineering Sri Lanka's FirstAI-Native Learning Ecosystem
Client Case Study: ZisuGen | A comprehensive breakdown of multi-agent LLM orchestration, bitemporal RAG search, high-concurrency database isolation, and extreme cloud cost optimization.

The Paradigm Shift: EdTech Re-Imagined from Scratch
Tuition education in Sri Lanka remains highly traditional, relying on chaotic WhatsApp groups, physical class cards, and fragmented ecosystems. While tutors face a perpetual crisis of content piracy, students struggle with unpersonalized learning, and parents are left completely blind to actual educational progression.
ZisuGen was engineered to dismantle these inefficiencies. It is not a simple "AI wrapper" or standard LMS; it is a fully integrated, multi-tenant ERP, CRM, and AI-Native learning ecosystem. Built on a hybrid architecture combining serverless scalability with relational data integrity, ZisuGen serves as a case study of how custom software can digitize complex real-world workflows.
Architectural Core Stack
From Disaster Relief to Enterprise EdTech: The Sisu Diriya Era
ZisuGen's codebase dates back to December 6, 2025, originally conceived as a rapid-response disaster relief initiative named Sisu Diriya (Student Courage) following the catastrophic Cyclone Ditwah. Children across rural Sri Lanka had lost books, school supplies, and teachers.
To connect donors with children, we engineered a sophisticated Bipartite Geo-Spatial Matching Feed Algorithm. The system parsed unstructured donation/request posts using AI to extract entity metadata (e.g., "Grade 10 Science Textbook in Galle") and dynamically calculated optimal matches:
// Geo-Spatial Matching Radius Expansion Loop
const MATCHING_RADII = [5, 30, 100]; // in kilometers
for (const radius of MATCHING_RADII) {
const match = await locateNearestDonor(studentGeo, bookMetadata, radius);
if (match) { await dispatchRealtimeAlerts(match); break; }
}
Though the disaster relief window closed as schools began physical recovery in early 2026, the core engine—the AI matching, the real-time push notification telemetry, and the deep understanding of student workflows—became the robust foundation for ZisuGen.
The Bipartite Match Formula
Sisu Diriya calculated matches using a combined scoring matrix of geographical distance, subject urgency, and donor validation levels:
This ensured that critical requests in remote areas were prioritized and matched with high-trust donors.
High-Concurrency Identity, Security & Data Models
Hybrid Authentication
Identity begins at the edge with Firebase Authentication (supporting Google Sign-In and mobile OTP). However, authorization is handled by our Node.js middleware. By parsing the auth token, the backend cross-references our PostgreSQL database via the Firebase Admin SDK to check active student/teacher enrollments, role privileges, and issues a secure, HttpOnly JWT cookie with a 7-Day Sliding Window Protocol to prevent login friction.
Polymorphic Schema
Anticipating loads of 100,000+ concurrent students sitting for national examinations simultaneously, traditional SQL JOINs on the auth path would bottleneck performance. ZisuGen uses a Flattened Polymorphic User Schema (Single Table Inheritance). All roles (Student, Teacher, Parent) occupy a single, heavily indexed User table, yielding O(1) time complexity for initial profile hydration.
Data Store Separation
We optimized cloud billing and latency by splitting storage based on state persistence characteristics. **80%** of the application state (financial transactions, syllabi vector chunks, user profiles) sits in **Cloud SQL PostgreSQL**. The remaining real-time data points (MCQ Game Arena, live attendance triggers, real-time message flags) run on **Firebase Realtime Database** for sub-second synchronization.
Bitemporal RAG Vector Architecture & Legacy Transcoding
To combat hallucination tendencies in localized education curricula, ZisuGen operates a custom RAG (Retrieval-Augmented Generation) pipeline over a vector database powered by Cloud SQL PostgreSQL and the pgvector extension.
1. Bitemporal Version Control
National syllabi change every few years. To prevent the AI from generating answers based on outdated curriculum standards, our `KnowledgeChunk` vector schema implements a Bitemporal Data Architecture (`validFromYear` and `validUntilYear`). Active syllabi are assigned a temporal infinity value (`9999`). When a new syllabus is ingested, the pipeline automatically mutates the overlapping legacy chunks' expiration timestamps.
2. Legacy Font Transcoding Pipeline
Over 70% of historical Sri Lankan educational materials and past papers are stored in PDFs using non-Unicode, legacy fonts (such as FM Abaya and Bamini). Feeding raw extractions to vector models yields garbage output. We engineered a transcoding middleware that dynamically converts these legacy strings into standardized Unicode, sanitizes line breaks, and routes them to gemini-embedding-2 for vectorization.
RAG Processing Pipeline
Cosine Distance query optimization:
WHERE country = 'LK' AND valid_until_year = 9999
ORDER BY embedding <=> $1 LIMIT 5;
Note: Pre-filtering on country and temporal validity limits comparison to relevant namespaces, optimizing response latency to < 90ms.
Autonomous Agentic Swarms & Multi-Vendor Pipelines
Instead of relying on single LLM invocations, ZisuGen coordinates specialized autonomous swarms. Tasks are dynamically routed depending on cognitive requirements and cost governance thresholds.
01ZisuPedia Authoring Swarm
To generate high-quality educational encyclopedia articles, ZisuPedia employs a 4-Stage Routing Pipeline:
- Stage 1: Sanitization (Gemini 2.5 Flash)Extracts keywords, targets key concepts, and structure templates, generating a precise Table of Contents (TOC).
- Stage 2: Context Retrieval LayerTriggers localized pgvector vector queries and external real-time scrapes using the Tavily search API.
- Stage 3: Deep Drafting (Gemini 3.1 Pro)Utilizes deep reasoning to draft section-by-section based on the TOC, bypassing token limit truncation.
- Stage 4: Verification AgentPerforms a final validation pass mapping content against official syllabus blueprints before database publication.
02ZisuDraft Pro & Humanizer Pipeline
For university students, generating draft papers requires highly specific formatting and absolute protection against AI detectors that misidentify student drafts. ZisuDraft implements a unique **Multi-Vendor Model Orchestration**:
- 1Initial Drafting (Groq + LLaMA 3.3 70B)Offloaded to LLaMA 3.3 on Groq via high-speed API endpoints to output long-form drafts segment by segment.
- 2Asset Generation (Gemini Image Model)Programmatically compiles graphs, mathematical figures, and diagrammatic visuals matching the written concepts.
- 3The Humanizer Agent (Gemini 3.1 Pro)Injects the LLaMA text and visual metadata into a final Gemini 3.1 Pro prompt configured with custom journalistic and academic styles. By mixing training datasets, the output achieves an AI-detection score of **1% to 3%** (ZeroGPT baseline) while keeping strict formatting logic.
The Tuition ERP: Subdomain Routing & AI Slip Validation
Edge Subdomain Routing
To empower educators to build their personal brand, ZisuGen assigns each verified teacher a custom subdomain (e.g., `physics.zisugen.lk`). We engineered edge routing logic using **Cloudflare Workers**. The worker intercepts incoming edge requests, identifies the subdomain namespace, and rewrites the request to the dynamic user route in our central Next.js server without deployment overhead or DNS delays.
AI Slip Verification & Hash-Matching
Manual bank slip verification is slow and open to fraud. ZisuGen uses Gemini Vision models to analyze uploaded slip screenshots for structural indicators (image manipulation, cropped dates, overlaying text, edited values). Once verified, the slip is hashed using a perceptual hashing algorithm. If a student attempts to re-upload the same slip for another month, the database immediately flags the duplicate hash block.
Decentralized Logistics (Tute Control)
High-volume tuition relies heavily on physical notes (Tutes). ZisuGen's logistics engine tracks printing/ink costs, binding expenses, and paper costs to calculate precise P&L margins. When a student collects material, staff scan their digital ID pass via the web application. The system cross-references active monthly fee cards and logs the disbursement in real-time, preventing stock leakage.
Auditory Learning Engines & Noise-Gated DSP
EdTech should accommodate students who spend hours daily commuting on public transport. ZisuGen incorporates the **Auditory Learning Engine** (ZisuAudio), generating bilingual podcasts and audio dramas (dramatizing classical school plays like Sinhabahu with distinct voice profiles).
To enable hands-free voice interactions inside noisy environments, our Live Voice websocket interface (connecting directly to the Gemini Live API model) utilizes a custom Digital Signal Processing (DSP) pipeline.
- •Voice Activity Detection (VAD): Configured with hangover frames and exponential smoothing to detect speech patterns.
- •Hard Noise Gate (Threshold 6): Aggressively suppresses ambient background noises common in public transit environments.
- •Progressive Audio Streaming: Audio generation is chunked. As the first segment is computed, it begins playing immediately, yielding a latency of < 200ms.
Live Voice Connection
Gemini Live Server-Sent WebSockets
Micro-Psychometric Telemetry & Megascale Scaling
The Micro-Psychometric Data Moat
Standard LMS engines evaluate students based on lagging indicators (final marks, attendance lists). ZisuGen logs how a student learns, capturing micro-interactions per learning session:
- •Cognitive Hesitation: Latency metrics measuring exactly how long a student hesitates before picking an MCQ answer option.
- •Doubt Mapping (Option Switching): Capturing the patterns of users toggling between specific choices before submitting, indicating conceptual confusion.
- •Interactive Friction Points: Timestamp logging tracking when a student pauses video playbacks to trigger the AI Tutor.
Google Cloud Run Auto-Scaling Model
Weekly island-wide mock exams represent a significant concurrency challenge, spiking traffic exponentially at 9:00 AM every Sunday. To mitigate the **Thundering Herd** problem, we modeled scale using:
Docker containers on Cloud Run scale horizontally instantly, capping compute resources at 400 active instances. Our serverless footprint ensures a minimal baseline cost of just **Rs. 0.14 per student / hour** during exams.
Next.js 14 / React PWA
Edge routing, dynamic metadata, and offline-first service workers
Node.js (Dockerized)
Microservices containerized and auto-scaled via Google Cloud Run
Cloud SQL PostgreSQL
Active transaction engine with pgvector for localized embedding spaces
Firebase Suite
Firebase RTDB for latency-critical tasks, Firebase Storage for asset storage
Gemini 3.1 Pro & Flash API
Multi-agent authoring, Socratic tutoring, and transcript fetching pipelines
Cloudflare Workers & CDN
Edge rewrite routing for teacher subdomains and network egress optimization
Redefining EdTech in Emerging Markets
ZisuGen is currently live, hosting over 50 real, active daily users in its testing phase. By combining advanced AI-native pipelines with rigorous operational control, the platform has successfully eliminated the geographical and economic barriers of private tutoring.
From a development perspective, ZisuGen showcases the future of engineering. By using the Google Antigravity AI Agent IDE, the entire platform—from database architecture to complex multi-agent swarms—was built, verified, and deployed in a rapid **2-month sprint**.
Build your next system
Looking to engineer your own AI-Native SaaS?
At SoftGen, we transform complex business requirements and raw architectural ideas into secure, scalable, production-grade applications. Contact us today.
Related Articles
Continue reading more insights from SoftGen

