An AI-powered educational platform that transforms mathematical equations into animated Indian cultural geometry โ with a built-in multilingual AI Teacher powered by Gemma.
"280 million Indian students study in regional languages โ yet almost every math visualisation tool speaks only English and uses only Western metaphors. KalaSutra AI changes that."
๐ Table of Contents (click to expand)
Mathematics is the single most failed subject across Indian board exams. Three systemic gaps make it worse:
| Gap | Impact |
|---|---|
| ๐ Abstraction | Static textbooks cannot show how changing sin(4ฮธ) โ sin(8ฮธ) transforms the geometry. Students memorise formulas without understanding shapes. |
| ๐ Language Barrier | 280M+ students study in Hindi, Bengali, Tamil, or Telugu โ yet quality visual math resources exist almost exclusively in English. |
| ๐ญ Cultural Disconnect | Global EdTech defaults to Western visual metaphors. Indian students don't see their own cultural geometry (Rangoli, Kolam, Mandala) reflected in math education. |
| Segment | Users |
|---|---|
| Primary | Class 9โ12 students ยท JEE / NEET aspirants ยท Engineering undergraduates |
| Secondary | Mathematics teachers ยท Coaching institutes ยท Parents |
KalaSutra AI is a full-stack educational tool that turns any mathematical equation into an interactive learning experience rooted in Indian culture.
A student types an equation. The system responds with:
Equation โ Animated Cultural Artwork + AI Teacher Explanation + Quiz + Real-Life Connection
(Rangoli / Mandala / (in their own (2 auto-generated (contextualised
Kolam / Alpana) language) questions) analogy)
This is not a chatbot. This is not "Chat with PDF". This is a purpose-built learning loop โ equation โ visualisation โ explanation โ assessment โ in one seamless interface.
| Feature | What It Does | |
|---|---|---|
| ๐งฎ | Equation Interpreter | SymPy-powered parser handles polar, parametric, and algebraic equations. Extracts variables, functions, and symmetry order automatically. |
| ๐จ | Cultural Geometry Generator | Renders equations as Rangoli, Mandala, Kolam, or Alpana artwork โ culturally familiar Indian geometric art forms. |
| ๐ฌ | Animated SVG Canvas | Framer Motion draws each geometric layer sequentially โ circles, petals, dots, spirals, polygons โ creating a compelling visual reveal. |
| ๐ง | AI Teacher Panel | Gemma explains why the shape looks the way it does, in the student's own language. Concise (โค40 words), pedagogically targeted. |
| ๐ | 5 Indian Languages | English ยท Hindi (เคนเคฟเคเคฆเฅ) ยท Bengali (เฆฌเฆพเฆเฆฒเฆพ) ยท Tamil (เฎคเฎฎเฎฟเฎดเฏ) ยท Telugu (เฐคเฑเฐฒเฑเฐเฑ) |
| ๐ | AI Quiz Generator | 2 auto-generated questions per equation (MCQ + short answer) to reinforce understanding immediately. |
| ๐ | Real-Life Connections | Contextualises every concept โ satellite dishes, clock gears, manhole covers โ so math feels tangible. |
| ๐ | Parameter Playground | Change any coefficient and instantly see how symmetry, petal count, and geometry evolve. |
| ๐ฅ | SVG Export | Download the generated artwork as a production-quality scalable vector file. |
Once the app is running, paste any of these equations into the KalaSutra Canvas:
| Equation | What You'll See | Recommended Theme |
|---|---|---|
r = sin(8*theta) |
๐ธ 8-petal Polar Rose with 8-fold symmetry | Rangoli |
r = cos(12*theta) |
๐บ 12-petal Rose โ intricate circular pattern | Mandala |
r = theta |
๐ Archimedean Spiral โ expanding outward | Kolam |
r = 1 + sin(theta) |
๐ Cardioid โ heart-shaped curve | Alpana |
r = sin(theta) * cos(theta) |
๐ผ 4-petal flower | Rangoli |
๐ก Pro-tip: Change the coefficient of
theta(e.g.,8โ6insin(8*theta)) to watch the symmetry transform in real time!
graph TD
subgraph Browser ["๐ React 19 Frontend (Vite + Tailwind)"]
direction LR
A["๐ Equation Editor<br/>(Left Pane)"]
B["๐จ SVG Canvas<br/>(Center Pane)"]
C["๐จโ๐ซ AI Teacher<br/>(Right Pane)"]
end
subgraph Backend ["โก FastAPI Backend"]
direction LR
D["1๏ธโฃ Equation Parser<br/>(SymPy)"]
E["2๏ธโฃ Gemma Engine<br/>(google-genai)"]
F["3๏ธโฃ Response Validator<br/>(Pydantic)"]
end
G[("๐ง Gemma 4 26B (MoE)<br/>(gemma-4-26b-a4b-it)")]
A -->|"HTTP POST<br/>/api/generate"| D
D -->|"Parsed properties"| E
E -->|"Prompt + Schema"| G
G -->|"Structured JSON"| F
F -->|"Response"| B
F -->|"Response"| C
classDef frontend fill:#eef2ff,stroke:#6366f1,stroke-width:2px,color:#1e1b4b
classDef backend fill:#f0fdf4,stroke:#22c55e,stroke-width:2px,color:#14532d
classDef model fill:#eff6ff,stroke:#3b82f6,stroke-width:3px,color:#1e3a8a
class A,B,C frontend
class D,E,F backend
class G model
| Step | Phase | What Happens |
|---|---|---|
| 1 | Input | User enters an equation (e.g., r = sin(8ฮธ)), selects a cultural theme and language. |
| 2 | Parse | The backend's SymPy-based parser extracts equation type, free variables, trig functions, and symmetry order. |
| 3 | Reason | Parsed data is sent to Gemma 4 26B (MoE) with a strict Pydantic schema enforcing structured JSON output. |
| 4 | Respond | Gemma returns a GemmaTeachingResponse โ concept, explanation, quiz, real-life connection, and rendering instructions. |
| 5 | Render | React frontend populates the AI Teacher panel and animates the SVG canvas layer by layer using Framer Motion. |
Gemma is not a wrapper. It is the reasoning core of the entire application, performing 5 distinct roles in a single structured inference call:
flowchart LR
A["๐ Parsed<br/>Equation"] --> B{"๐ง Gemma 4 26B<br/>(Single Inference Call)"}
B --> C["๐จโ๐ฌ Mathematician<br/>(Type, Symmetry)"]
B --> D["๐ฃ๏ธ Teacher<br/>(Multilingual Explanation)"]
B --> E["๐ Storyteller<br/>(Real-life Analogy)"]
B --> F["๐ Quiz Creator<br/>(2 Targeted Questions)"]
B --> G["๐จ Geometry Architect<br/>(SVG Layers)"]
C --> H["๐ฆ GemmaTeachingResponse<br/>(Pydantic-Validated JSON)"]
D --> H
E --> H
F --> H
G --> H
classDef input fill:#f3f4f6,stroke:#9ca3af,stroke-width:2px,color:#111827
classDef model fill:#eff6ff,stroke:#3b82f6,stroke-width:3px,color:#1e3a8a
classDef roles fill:#fdf4ff,stroke:#d946ef,stroke-width:2px,color:#701a75
classDef output fill:#f0fdf4,stroke:#22c55e,stroke-width:2px,color:#14532d
class A input
class B model
class C,D,E,F,G roles
class H output
We enforce deterministic structured output using response_mime_type="application/json" with a strict response_schema=GemmaTeachingResponse Pydantic model. This means every response is machine-parseable and UI-ready โ no regex extraction, no post-processing hacks.
Key insight: This architecture cleanly separates reasoning (Gemma) from rendering (React/SVG), keeping the system modular, testable, and language-agnostic.
We evaluated every available Gemma variant. Here's why gemma-4-26b-a4b-it won:
| Factor | Why This Variant Fits |
|---|---|
| Structured JSON Output | Supports response_schema via the Google GenAI SDK โ critical for our multi-role output (explanation + quiz + rendering) in a single deterministic call. |
| Multilingual Strength | Strong performance across Hindi, Bengali, Tamil, and Telugu โ serving our target audience of 280M+ regional-language students. |
| MoE Efficiency | Activates only 4B of 26B parameters per token โ fast inference ideal for an interactive tool where students expect real-time feedback. |
| Math Reasoning | Sufficient depth to analyse polar/parametric equations, extract symmetry properties, and generate pedagogically accurate explanations. |
| Instruction-Tuned | The -it variant reliably follows complex multi-constraint prompts (e.g., "explain in โค40 words in Tamil while also producing geometry layer instructions"). |
Why Not Other Variants? (click to expand)
| Variant | Reason for Rejection |
|---|---|
| Gemma 2B / 4B | Insufficient reasoning depth for math concept extraction + quiz generation + geometry instructions in a single structured call. |
| Gemma 27B Dense | Higher latency per token vs. the 26B MoE variant, with no significant quality gain for our structured-output use case. |
| Gemma 31B Dense | Overkill โ the MoE variant offers a better latency/quality tradeoff for interactive educational applications. |
| Technology | Version | Role |
|---|---|---|
| Python | 3.9+ | Core language |
| FastAPI | Latest | REST API framework with auto-generated OpenAPI docs |
| Pydantic | v2 | Request / response validation & structured output schema for Gemma |
| google-genai | Latest | Official Google GenAI Python SDK |
| Gemma 4 26B (MoE) | gemma-4-26b-a4b-it |
Primary LLM inference engine |
| SymPy | 1.13+ | Symbolic math parsing & equation analysis |
| Uvicorn | Latest | ASGI server |
| Technology | Version | Role |
|---|---|---|
| React | 19 | UI framework |
| TypeScript | 6.0 | Type safety across all components |
| Vite | 8 | Build tooling & dev server |
| TailwindCSS | 3.4 | Utility-first styling |
| Framer Motion | 12 | SVG path draw animations |
| Axios | 1.18 | HTTP client |
| Lucide React | 1.24 | Icon library |
KalaSutra AI/
โโโ README.md # This file
โโโ LICENSE # MIT License
โโโ CODE_OF_CONDUCT.md # Contributor Covenant v2.1
โโโ CONTRIBUTING.md # Contribution guidelines
โโโ SECURITY.md # Security policy
โโโ logo.png # Project logo
โ
โโโ backend/
โ โโโ README.md # Backend-specific documentation
โ โโโ requirements.txt # Python dependencies
โ โโโ .env # API key (not committed)
โ โโโ app/
โ โโโ main.py # FastAPI entry point + CORS
โ โโโ api/
โ โ โโโ generate.py # POST /api/generate endpoint
โ โโโ gemma/
โ โ โโโ engine.py # Gemma inference + prompt engineering
โ โโโ parser/
โ โ โโโ equation.py # SymPy equation parser
โ โโโ schemas/
โ โโโ models.py # Pydantic models (request / response)
โ
โโโ frontend/
โโโ README.md # Frontend-specific documentation
โโโ index.html # HTML entry point + SEO meta tags
โโโ package.json # Node.js dependencies
โโโ src/
โโโ App.tsx # Root component โ layout, state, API calls
โโโ main.tsx # Vite entry point
โโโ index.css # Tailwind base + Inter font
โโโ types/
โ โโโ index.ts # Shared TypeScript type definitions
โโโ components/
โโโ EquationEditor.tsx # Left pane โ equation input form
โโโ Preview.tsx # Center pane โ animated SVG canvas
โโโ AITeacherPanel.tsx # Right pane โ AI Teacher, quiz, symmetry
| Requirement | Version |
|---|---|
| Python | 3.9+ |
| Node.js | 18+ |
| Gemma API Key | Get one free โ |
git clone https://github.com/dasouvik122005/KalaSutra-AI.git
cd KalaSutra-AIcd backend
# Create and activate virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS / Linux
# Install dependencies
pip install -r requirements.txt
# Configure API key
echo GEMINI_API_KEY=your_key_here > .env
# Start the server
uvicorn app.main:app --reload
โ ๏ธ Never commit your.envfile. It is already in.gitignore.
| Service | URL |
|---|---|
| REST API | http://localhost:8000 |
| Swagger UI | http://localhost:8000/docs |
# Open a new terminal
cd frontend
npm install
npm run devThe application will be available at http://localhost:5173
Generates teaching materials and rendering instructions for a given equation.
Request
{
"equation": "r = sin(8*theta)",
"theme": "rangoli",
"complexity": "medium",
"language": "English"
}| Field | Type | Required | Options | Default |
|---|---|---|---|---|
equation |
string |
โ | Any math expression | โ |
theme |
string |
โ | rangoli ยท mandala ยท kolam ยท alpana |
โ |
complexity |
string |
โ | low ยท medium ยท high |
medium |
language |
string |
โ | English ยท Hindi ยท Bengali ยท Tamil ยท Telugu |
English |
Response Body (200 OK) โ click to expand
{
"data": {
"concept": "Polar Rose Curve",
"symmetry": "8-fold",
"difficulty": "Medium",
"explanation": "The number 8 in sin(8ฮธ) creates 8 petals evenly distributed around the origin.",
"real_life_connection": "Used in antenna design to produce directional signal patterns.",
"quiz": [
{
"question": "What determines the number of petals in r = sin(nฮธ)?",
"type": "mcq",
"options": ["The coefficient n of ฮธ", "The amplitude", "The frequency", "The phase"],
"answer": "The coefficient n of ฮธ"
},
{
"question": "What symmetry does r = sin(8ฮธ) exhibit?",
"type": "short_answer",
"options": null,
"answer": "8-fold rotational symmetry"
}
],
"rendering": {
"canvas": { "width": 1000, "height": 1000, "background": "none" },
"layers": [
{ "type": "circle", "radius": 220, "stroke": "#e0e7ff", "fill": "none", "stroke_width": 1 },
{ "type": "petal", "count": 8, "radius": 200, "stroke": "#6366f1", "fill": "#e0e7ff", "stroke_width": 1.5 },
{ "type": "dots", "count": 8, "radius": 200, "dot_radius": 5, "stroke": "#4f46e5", "fill": "#4f46e5" }
],
"pattern": "8-Petal Rose Rangoli"
}
}
}{ "status": "ok" }| Language | Native Script | Code |
|---|---|---|
| English | English | English |
| Hindi | เคนเคฟเคเคฆเฅ | Hindi |
| Bengali | เฆฌเฆพเฆเฆฒเฆพ | Bengali |
| Tamil | เฎคเฎฎเฎฟเฎดเฏ | Tamil |
| Telugu | เฐคเฑเฐฒเฑเฐเฑ | Telugu |
Contributions are welcome! Please read our Contributing Guide and Code of Conduct before getting started.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m 'feat: add your feature' - Push to your branch:
git push origin feature/your-feature - Open a Pull Request
This project is licensed under the MIT License โ see the LICENSE file for details.
Built with โค๏ธ for the Google โ Build with Gemma Kaggle Competition
Powered by Gemma 4 26B (MoE) โ Bridging Mathematics and Culture, one equation at a time.