A sophisticated web-based environment for developing, rendering, and refining Manim animations directly from your browser. Inspired by 3Blue1Brown, this platform provides a seamless experience for creating complex mathematical animations without the overhead of local environment configuration.
Manim Code Editor bridges the gap between writing Python animation scripts and rendering them. It features an intelligent dual-architecture system designed for scalability, pairing a lightweight, globally distributed frontend with a robust, asynchronous Python rendering engine.
- Glassmorphism Interface: A modern, adaptive user interface built with Tailwind CSS v4, supporting both light and dark themes.
- Integrated Editor: A VS Code-style editing environment utilizing Monaco Editor for Python syntax highlighting and code completion.
- Instant Preview: Seamlessly view rendered
.mp4Manim outputs directly within the workspace. - AI Assistance: An integrated AI chat interface designed to help generate and modify Manim code from natural language prompts.
For contributors, understanding how the pieces fit together is crucial. Manim Code Editor uses a dual-architecture setup to solve a specific problem: Manim is a heavy Python library that requires system-level dependencies (FFmpeg, LaTeX, Cairo), which makes it impossible to run in standard serverless environments (like Vercel or AWS Lambda).
To solve this, we decoupled the application into two distinct environments.
sequenceDiagram
participant User as Client Browser
participant FE as Next.js (Vercel)
participant DB as Supabase
participant API as FastAPI (Docker)
participant Worker as Celery Worker
User->>FE: Click "Render Animation"
FE->>DB: Save Python Code
FE->>API: POST /render {code}
API->>Worker: Dispatch Celery Task
API-->>FE: Return task_id (Status: Processing)
loop Polling
FE->>API: GET /status/{task_id}
end
Worker->>Worker: Sandbox Execute Manim
Worker->>DB: Upload rendered .mp4
Worker-->>API: Task Complete
API-->>FE: Return .mp4 URL
FE-->>User: Display Video
- Hosting: Vercel (Edge Network)
- Purpose: Handles the user interface, authentication, and state management. Because it's deployed on Vercel, it scales infinitely and handles traffic spikes effortlessly.
- Key Components:
- Uses Monaco Editor for the code editing experience.
- Polls the backend when a render is requested to update the UI with progress.
- Hosting: Dockerized environment on a dedicated VPS (e.g., DigitalOcean).
- Purpose: Safely executes user-submitted Python code and generates animations.
- The "Traffic Jam" Problem: Rendering video is CPU-intensive. If 50 users click "Render" simultaneously, a standard API would crash.
- The Solution:
- The FastAPI server instantly accepts the request and places it into a Redis Queue.
- A Celery Worker picks up jobs one by one (based on CPU availability), ensuring the server never runs out of memory.
- We enforce Code Sandboxing (stripping out dangerous imports like
osorsubprocess) and Timeouts to prevent malicious code execution.
- PostgreSQL: Stores user accounts, OAuth identities, and saved project code.
- Storage Buckets: Holds the final
.mp4files generated by the Celery worker, serving them back to the Next.js frontend via a public URL.
.
├── app/ # Next.js 15 Frontend
│ ├── src/app/ # App Router Pages (Editor, Creator, Auth)
│ ├── src/components/ # Reusable UI Components
│ ├── public/ # Static Assets
│ └── package.json # Frontend Dependencies
│
├── backend/ # Python FastAPI Rendering Server
│ ├── main.py # API endpoints and rate limiting
│ ├── worker.py # Celery tasks for executing manim safely
│ ├── requirements.txt # Python dependencies
│ └── docker-compose.yml# Container orchestration
│
├── .gitignore
└── README.md
- Navigate to the frontend directory:
cd app - Install dependencies:
npm install
- Run the development server:
npm run dev
- Access the application at
http://localhost:3000.
- Navigate to the backend directory:
cd backend - Start the Docker containers (FastAPI, Celery, Redis):
docker-compose up --build
- The API will be available at
http://localhost:8000.
I welcome contributions to the Manim Code Editor! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name. - Commit your changes with clear, descriptive messages:
git commit -m 'Add some feature'. - Push to your branch:
git push origin feature/your-feature-name. - Open a Pull Request against the
mainbranch.
Please ensure your code follows the existing style and includes appropriate documentation.
If you encounter a bug, have a feature request, or need help, please open an issue in the GitHub repository. When submitting an issue, please include:
- A clear and descriptive title.
- Steps to reproduce the issue (if reporting a bug).
- Details about your environment (OS, browser, etc.).
- Any relevant error logs or screenshots.
This project is open-source and available under the MIT License.
Developed by Mansoju Vivekananda.