Anim is a web platform that lets users create explainer videos using a single prompt. This was made possible by a popular python library called Manim which lets you generate animated videos from python code.
This project uses a FastAPI backend along with the Claude and Redis to efficiently generate and run Manim code.
The LLM response (which contains the Manim code) is streamed to the frontend via WebSockets and a video generation job is pushed to a Redis queue (list) after the Manim code generation is complete. The backend runs a task manager which pulls jobs from the Redis queue and executes them according to the CPU capactiy of the server.
The frontend after having the LLM response streamed, polls the backend for video generation status whose value the backend fetches from the Redis data store.
Redis is being used here a queue as well as a single source of truth for the video generation status which helps manage job processing across multiple servers.
The code for this section can be found in backend/app/chat/task_processing.py and backend/app/chat/route.py.
Before running the project locally, ensure you have the following installed:
- Python 3.13+ (for the backend)
- Node.js 20+ (for the frontend)
- PostgreSQL (for the database)
- Redis (for task queue and caching)
- Manim dependencies (FFmpeg, LaTeX, Cairo, Pango, etc.)
For detailed instructions on installing Manim and its dependencies for your operating system, please refer to the official Manim installation guide.
macOS (using Homebrew):
brew install postgresql@16 redis
brew services start postgresql@16
brew services start redisUbuntu/Debian:
sudo apt-get update && sudo apt-get install -y \
postgresql \
postgresql-contrib \
redis-server
sudo systemctl start postgresql
sudo systemctl start redis-servergit clone <repository-url>
cd anim- Sign up for a free account at Clerk
- Create a new application
- Get your API keys from the dashboard:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY(Frontend)CLERK_SECRET_KEY(Backend & Frontend)
- Create an AWS account at AWS Console
- Create an S3 bucket for video storage
- Create an IAM user with S3 access and generate access keys
- Note down:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_S3_BUCKET(your bucket name)AWS_BUCKET_REGION(e.g.,us-east-1)
Get an API key from one of these providers:
- Claude: Anthropic Console
- Google AI: Google AI Studio
Create a PostgreSQL database for the project:
psql postgres
CREATE DATABASE anim;
CREATE USER anim_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE anim TO anim_user;
\qOr use a hosted PostgreSQL service (e.g., Aiven, AWS RDS, DigitalOcean, Supabase).
cd backend
pip install -r requirements.txt
cp .env.example .env
alembic upgrade headRequired environment variables in .env:
LLM=CLAUDE
CLAUDE_API_KEY=your_claude_api_key
GOOGLE_API_KEY=your_google_api_key
FRONTEND_URL=http://localhost:3000
DB_URI=postgresql://username:password@host:port/database
ASYNC_DB_URI=postgresql+asyncpg://username:password@host:port/database
CLERK_SECRET_KEY=your_clerk_secret_key
REDIS_URL=redis://localhost:6379/0
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_S3_BUCKET=your_s3_bucket_name
AWS_BUCKET_REGION=your_aws_region
DOCKER_CONTAINER=FALSE
ENVIRONMENT=DEVELOPMENTcd ../frontend
npm install
cp .env.example .envRequired environment variables in .env:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
NEXT_PUBLIC_API_URL=http://localhost:8000/api
NEXT_PUBLIC_BASE_SOCKET_URL=ws://localhost:8000/apiYou'll need to run two separate processes in different terminal windows:
cd backend
uvicorn app.main:app --reload --port 8000The backend API will be available at http://localhost:8000
The task manager for processing video generation jobs starts automatically with the backend server.
cd frontend
npm run devThe frontend will be available at http://localhost:3000
Issue: Manim fails to render videos
- Ensure FFmpeg is installed:
ffmpeg -version - Ensure LaTeX is installed:
latex --version - Check that Cairo and Pango are installed properly
Issue: Redis connection errors
- Verify Redis is running:
redis-cli ping - Check the
REDIS_URLin your.envfile
Issue: Database connection errors
- Ensure PostgreSQL is running and accessible
- Verify the
DB_URIandASYNC_DB_URIin your.envfile - Run database migrations:
alembic upgrade head
Issue: WebSocket connection fails
- Ensure the backend is running on port 8000
- Check CORS settings in
backend/app/main.py - Verify
NEXT_PUBLIC_BASE_SOCKET_URLin.env
