Data and AI¶
Databases¶
Databases run on Azure Database for PostgreSQL Flexible Server with private access. Staging and production are separate servers.
| Database | Owns | Written by |
|---|---|---|
| App database | Users, courses, assignments, chat, subscriptions, practice sessions and attempts. The erp schema holds Campus data. |
Backend, via the main and ERP Alembic chains |
kwiloai_memory |
Learner profiles and onboarding preferences, planned mastery and concept tables | Backend, via its own Alembic chain |
knowledge_base_status |
The past-paper question bank (exam_chapters, exam_questions) and the NCERT textbook catalogue |
The ingestion pipeline. Both backends only read it. |
| Consumer database | Learner product data: users, study plans, attempts, scores, subscriptions | kwiloai-b2c backend, its own Alembic chain |
The question bank is a foreign schema to the app: its models sit on a separate declarative base so Alembic never tries to manage it. If it's unreachable, the Practice Hub returns an empty state instead of an error.
Textbook chapter text is stored as chunk files in Azure Blob storage, indexed by the textbook catalogue. Study Plan and quick reads fetch a chapter by key. No similarity search is involved when the chapter is already known.
Media (uploads, generated images, student photos) goes to the Azure Blob uploads container and is served by SAS URL, resized through imgproxy at img.kwilo.ai.
AI services¶
Chatbot microservice¶
kwiloai_chatbot does all LLM work: the tutor, generation agents (mock tests, assignments, presentations, study plan chapters), tool use and retrieval. The backend proxies requests to it over server-sent events and applies policy around it: capability checks, quota charge and refund, persistence and labelling.
Model routing: Gemini is primary, with Claude and GPT-4o as fallbacks. Image generation tries Imagen, then Gemini, then DALL-E.
Eval service¶
kwiloai_eval_service runs long or CPU-heavy work off the request path, fed by Azure Service Bus with deterministic message IDs and trace propagation. It writes results back to Postgres and the backend polls. Current jobs: the timetable solver (OR-Tools CP-SAT) and evaluation workloads.
Retrieval¶
Uploaded documents (the institutional knowledge base and Learner My Space) go through one pipeline: upload to Blob, OCR, chunk, embed, store vectors tagged with owner and visibility. Retrieval filters by institution scope, and for personal documents by owner_user_id.
Handwritten grading¶
Answer sheets use document intelligence for OCR, header and roll-number mapping, then LLM evaluation against the rubric and model answer. The result is a suggested mark with confidence that faculty accept or edit.