A Manim animation generator rebuilt with Motia - the event-driven backend framework. This version demonstrates how to structure a video generation pipeline using Motia's Step primitives.
Detailed Step-by-Step Guide available here
This application uses Motia's event-driven architecture to process animation requests asynchronously:
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β GenerateApi ββββββΊβ AnalyzeConcept ββββββΊβ GenerateCode β
β (API Step) β β (Event Step) β β (Event Step) β
β POST /api/gen β β LaTeX/template β β AI or template β
βββββββββββββββββββ ββββββββββββββββββββ ββββββββββ¬βββββββββ
β
ββββββββββββββββββββ β
β StoreResult ββββββββββββββββ€
β (Event Step) β β
β Stores results β βΌ
ββββββββββββββββββββ βββββββββββββββββββ
β² β RenderVideo β
β β (Event Step) β
ββββββββββββββββββ Runs Manim CLI β
βββββββββββββββββββ
βββββββββββββββββββ
β JobStatusApi β
β (API Step) β
β GET /api/jobs/* β
βββββββββββββββββββ
- animation.requested - Client submits concept via
POST /api/generate - concept.analyzed - Concept analyzed (LaTeX? Template match? Need AI?)
- code.generated - Manim Python code generated
- video.rendered / video.failed - Video rendered or error occurs
- Client polls
GET /api/jobs/:jobIduntil complete
βββ src/
β βββ api/
β β βββ generate.step.ts # POST /api/generate
β β βββ job-status.step.ts # GET /api/jobs/:jobId
β β βββ refine.step.ts # POST /api/refine
β βββ events/
β β βββ analyze-concept.step.ts
β β βββ generate-code.step.ts
β β βββ render-video.step.ts
β β βββ store-result.step.ts
β βββ services/
β β βββ job-store.ts # State management
β β βββ manim-templates.ts # Pre-built templates
β β βββ openai-client.ts # AI code generation
β β βββ nlu-classifier.ts # Intent classification
β β βββ scene-composer.ts # Scene graph builder
β β βββ prompt-engine.ts # Multi-stage prompting
β β βββ style-presets.ts # Visual style configs
β βββ types/
β βββ nlu.types.ts # NLU type definitions
β βββ scene.types.ts # Scene graph types
βββ skills/ # Animation skills
β βββ math-visualizer/
β βββ animation-composer/
β βββ visual-storyteller/
β βββ motion-graphics/
βββ public/
β βββ index.html # Frontend UI
β βββ videos/ # Generated videos
βββ motia.config.ts # Motia configuration
βββ package.json
βββ tsconfig.json
- Node.js 18+
- Python 3.10+
- Manim Community Edition
- FFmpeg
- LaTeX distribution (texlive)
# Navigate to motia directory
cd motia
# Install dependencies (will run motia install via postinstall)
npm install
# Add OpenAI and UUID dependencies
npm install openai uuid zod
# Configure environment
cp .env.example .env
# Edit .env with your OpenAI API key
# Generate types
npm run generate-types
# Start development server
npm run dev# Required
OPENAI_API_KEY=your-openai-api-key
# Optional
OPENAI_MODEL=gpt-4o-mini # Default model for code generation- Start the server:
npm run dev - Open http://localhost:3000
- Enter a mathematical concept or LaTeX expression
- Click "Generate Animation"
- Wait for the video to render (poll status automatically)
Start animation generation.
{
"concept": "Demonstrate the Pythagorean theorem",
"quality": "low"
}Response:
{
"success": true,
"jobId": "uuid",
"status": "processing"
}Check job status.
Response (completed):
{
"jobId": "uuid",
"status": "completed",
"video_url": "/videos/uuid.mp4",
"code": "from manim import *...",
"used_ai": false,
"render_quality": "low"
}The generator uses an NLU (Natural Language Understanding) pipeline to transform natural language into animations:
User Input β NLU Classifier β Scene Composer β Prompt Engine β Manim Code β Video
Install animation skills for enhanced generation:
# Using SkillKit (Recommended) - Install all skills
npx skillkit install rohitg00/manim-video-generator/skills
# Or install individual skills
skillkit install rohitg00/manim-video-generator/skills/math-visualizer
skillkit install rohitg00/manim-video-generator/skills/motion-graphics
skillkit install rohitg00/manim-video-generator/skills/animation-composer
skillkit install rohitg00/manim-video-generator/skills/visual-storyteller
# Using skills.sh (alternative)
npx skills add rohitg00/manim-video-generator/Available skills:
- math-visualizer - Equations, proofs, graphs, geometric concepts, concept decomposition
- animation-composer - Multi-act scenes, transitions, camera control, scene planning, layout validation
- visual-storyteller - Step-by-step explanations, narratives, CLEAR framework, process visualization
- motion-graphics - Kinetic typography, logos, title sequences, audio sync, web export, thumbnails
- shared - Core animations library, easing reference (used by all skills)
Choose a visual style when generating:
{
"prompt": "Visualize the Pythagorean theorem",
"style": "3blue1brown"
}Available styles: 3blue1brown, minimalist, playful, corporate, neon
Iteratively refine generated animations:
curl -X POST http://localhost:3000/api/refine \
-H "Content-Type: application/json" \
-d '{"jobId": "uuid", "refinement": "make colors warmer", "preserveElements": true}'- Pythagorean theorem
- Quadratic functions
- Trigonometry (unit circle)
- 3D surface plots
- Sphere/Cube geometry
- Derivatives & Integration
- Matrix operations & Eigenvalues
- Complex numbers
- Differential equations
Here are some examples of complex mathematical animations generated using our tool:
This animation demonstrates complex number transformations, showing how functions map points in the complex plane. Watch as the visualization reveals the geometric interpretation of complex operations.
A sophisticated 3D visualization showing multivariable calculus concepts. The animation illustrates surface integrals and vector fields in three-dimensional space, making abstract concepts tangible.
This animation brings differential equations to life by visualizing solution curves and phase spaces. Watch how the system evolves over time, revealing the underlying mathematical patterns.
Experience linear transformations in action! This visualization demonstrates how matrices transform space, showing concepts like eigenvectors, rotations, and scaling in an intuitive way.
These examples showcase the power of our tool in creating complex mathematical visualizations. Each animation is generated from a simple text description, demonstrating the capability to:
- Render sophisticated 3D scenes with proper lighting and perspective
- Create smooth transitions between mathematical concepts
- Visualize abstract mathematical relationships
- Handle multiple mathematical objects with precise timing
- Generate publication-quality animations for educational purposes
The original Flask app handled everything synchronously. With Motia:
- Async Processing - Long-running renders don't block the API
- Event-Driven - Each step is decoupled and independently scalable
- Type Safety - Zod schemas validate inputs/outputs
- Observability - Built-in tracing via Motia Workbench
- Multi-Language - Python steps can be added alongside TypeScript
# Build and run with docker-compose
docker-compose up -d
# Or build manually
docker build -t manim-generator-motia .
docker run -p 3000:3000 \
-e OPENAI_API_KEY=your-key \
-v $(pwd)/public/videos:/app/public/videos \
manim-generator-motia- Connect Repository: Link your GitHub repo to Sevalla
- Configure Build:
- Build Command:
npm run build - Start Command:
motia start - Dockerfile Path:
motia/Dockerfile
- Build Command:
- Set Environment Variables:
OPENAI_API_KEY- Your OpenAI API keyOPENAI_MODEL- (optional) gpt-4o-miniNODE_ENV- production
- Deploy: Sevalla will build and deploy automatically
The frontend (public/index.html) is served by Motia from the same origin as the API:
- Frontend: Served at
/(root) - API Endpoints:
/api/generate,/api/jobs/:jobId - Generated Videos:
/videos/*.mp4
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Motia Server β
β (port 3000) β
β β
β βββββββββββββββ βββββββββββββββββββββββββββββββ β
β β Express β β Motia Steps β β
β β Middleware β β β β
β β β β /api/generate β GenerateApiβ β
β β GET / β β /api/jobs/* β JobStatusApiβ β
β β (index.html) β β β
β β β β Events: β β
β β /videos/* β β β AnalyzeConcept β β
β β (static) β β β GenerateCode β β
β β β β β RenderVideo β β
β βββββββββββββββ βββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
For horizontal scaling, configure Redis adapter in motia.config.ts:
import { config } from 'motia'
export default config({
adapters: {
state: {
type: 'redis',
options: { host: 'redis', port: 6379 }
},
events: {
type: 'redis',
options: { host: 'redis', port: 6379 }
}
}
})View the workflow in Motia Workbench:
npm run dev
# Open http://localhost:3000/workbenchThe app exposes a health endpoint for container orchestration:
curl http://localhost:3000/health
# {"status":"healthy","timestamp":"2024-..."}- Created by Rohit Ghumare
- Powered by Manim Community
- Special thanks to:
- 3Blue1Brown for creating Manim
- Sevalla for deployment and support
- Manim Community for their excellent documentation and support
- Motia for the event-driven framework
MIT License - See LICENSE for details.




