A free, open-source Django calculus tutor that shows step-by-step solutions for derivatives, integrals, and limits. Includes an AI chatbot powered by a self-hosted open-weight LLM (Llama 3.2 3B via Ollama).
Live: https://calaun.org · License: MIT · Status: personal open-source project (not a non-profit;)
- Step-by-step solutions for derivatives, integrals, and limits
- AI chatbot sidebar that explains calculus concepts (powered by self-hosted Ollama; streams per-step answers progressively)
- Reference page with common formulas and "try it" links
The results page shows step-by-step solutions with an AI chatbot sidebar:
- Click any step to expand/collapse details
- Ask the chatbot to explain concepts or clarify steps
- Chatbot is context-aware and sees the current solution
- Python 3.9+ (tested with Python 3.12)
- pip
- (Optional) Ollama running locally for the AI chatbot
-
Create a virtual environment:
python3 -m venv env source env/bin/activate -
Install dependencies:
pip install --upgrade pip pip install -r requirements.txt
-
Set up the AI chatbot (optional but recommended):
# Install Ollama from https://ollama.com, then: ollama pull llama3.2:3b # Set LLM_MODEL=llama3.2:3b in your .env (or whichever model you pulled). # LLM_BASE_URL defaults to http://localhost:11434/v1, so no other env vars # are needed for local dev.
-
Run the development server:
python manage.py runserver
-
Visit http://127.0.0.1:8000
Enter calculus expressions like:
Derivatives:
diff(x^5, x)- Power rulediff(sin(x^2), x)- Chain rulediff(x^2 * ln(x), x)- Product rule
Integrals:
integrate(x^3, x)- Power ruleintegrate(x*exp(x), x)- Integration by partsintegrate(1/(x^2 - 1), x)- Partial fractions
Limits:
limit(sin(x)/x, x, 0)- Fundamental trig limitlimit((1 + 1/x)^x, x, oo)- Definition of elimit((x^2 - 4)/(x - 2), x, 2)- Indeterminate form
The chatbot talks to any OpenAI-compatible chat-completions endpoint via env vars (LLM_BASE_URL, LLM_API_KEY, LLM_MODEL). Production runs an open-weight model on self-hosted Ollama (currently Llama 3.2 3B). It:
- Explains calculus concepts and rules
- Understands the current solution steps as context
- Streams per-step answers: when the student asks about multiple steps in one message, each step's answer reaches the browser as soon as it's generated, instead of waiting for all of them
- Uses proper LaTeX formatting in responses
See chatbot/README.md for routing details and HTTP API shape.
python manage.py test # Run all tests
python -m pytest logic/ # Run logic tests only
python -m pytest chatbot/ # Run chatbot tests only- Backend: Django 4.2
- Math Engine: SymPy
- AI Chatbot: Ollama + Llama 3.2 3B (self-hosted, OpenAI-compatible API; NDJSON streaming response)
- Frontend: Vanilla ES6 JavaScript, MathJax 3, CSS custom properties
- Database: SQLite (dev) / PostgreSQL (prod via DATABASE_URL)
├── app/ # Django app (views, URLs, template tags)
├── chatbot/ # AI chatbot module
│ ├── llm_chat.py # Chatbot client (OpenAI-compatible, defaults to local Ollama)
│ └── README.md # Chatbot documentation
├── logic/ # Math solving logic
│ ├── diffsteps.py # Derivative steps
│ ├── intsteps.py # Integral steps
│ ├── limitsteps.py # Limit steps (including exponential forms)
│ └── resultsets.py # Result card definitions
├── static/
│ ├── css/modern.css # Modern CSS with custom properties
│ └── js/app.js # ES6 JavaScript (ChatSidebar, Collapsible)
├── templates/ # HTML5 templates
└── mathtutor/ # Django settings
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this project helpful and want to chip in, you can:
- Use GitHub Sponsors (one-time or recurring)
- Email rbeauvile@calaun.org with any other ideas
CaLaun is a open-source project, not a 501(c)(3), so contributions are not tax-deductible.