A full-stack graph visualization service that renders beautiful animations using Manim.
- Next.js 14 (App Router)
- TypeScript
- Tailwind CSS
- shadcn/ui components
- FastAPI + Uvicorn
- Python 3.11
- PostgreSQL database
- SQLAlchemy 2.0 (async) + asyncpg
- Alembic migrations
- Celery + Redis for task queue
- Manim for rendering (in Docker container)
- Docker Compose orchestration
- Local file storage with shared volumes
- Pydantic v2 for settings
- ruff + black + pytest for code quality
- ✅ AI-powered animation planning with Gemini
- ✅ Natural language prompts for graph creation
- ✅ Asynchronous rendering with Celery workers
- ✅ Real-time job status polling
- ✅ Clean animations with rounded rectangles and smooth transitions
- ✅ Video playback in browser
- ✅ View LLM-generated animation plan, code, and logs
- ✅ Validate and sanitize user inputs
- ✅ PostgreSQL persistence with migrations
┌─────────────┐
│ Next.js │ (port 3000)
│ Frontend │
└──────┬──────┘
│ HTTP
▼
┌─────────────┐
│ FastAPI │ (port 8000)
│ API │
└──────┬──────┘
│
├─────► PostgreSQL (port 5432)
│
└─────► Redis (port 6379)
│
▼
┌─────────────┐
│ Celery │
│ Worker │
└──────┬──────┘
│
▼
┌─────────────┐
│ Manim │
│ Renderer │
└─────────────┘
- Docker Desktop (Windows/macOS) or Docker Engine (Linux)
- Docker Compose v2.0+
- Git
git clone <your-repo-url>
cd AnimaStudioWindows PowerShell:
Copy-Item .env.example .envmacOS/Linux:
cp .env.example .envEdit .env and add your Gemini API key:
GEMINI_API_KEY=your-actual-api-key-hereGet your free API key at: https://aistudio.google.com/app/apikey
Windows PowerShell:
docker-compose up --buildmacOS/Linux:
docker-compose up --buildThis command will:
- Build all Docker images
- Start PostgreSQL, Redis, API, Worker, Manim, and Frontend
- Create necessary volumes and networks
Open a new terminal and run:
Windows PowerShell:
docker exec -it anima_api alembic upgrade headmacOS/Linux:
docker exec -it anima_api alembic upgrade headOpen your browser and navigate to:
The API documentation is available at:
-
Enter a natural language prompt describing your desired graph, e.g.:
Explain cache miss with client server cache dbor
Show login flow: user -> frontend -> api -> database -
Click "Generate Graph Animation"
-
The AI (Gemini) will create a structured animation plan with nodes, edges, and animation steps
-
Wait for rendering to complete (status updates automatically)
-
Watch the rendered video with smooth animations
-
Expand sections to view:
- LLM Animation Plan - Structured plan generated by AI
- Generated Code - Safe Manim code produced from the plan
- Logs - Execution details
System Architecture:
Microservices: API Gateway connects to Auth Service and User Service, both connect to Database
Data Flow:
Explain cache miss with client server cache db
Process Flow:
Show login flow: user -> frontend -> api -> database
Network Topology:
Create a star network with central router and 4 clients
Algorithm:
Binary search tree: insert 5, then 3, then 7, highlight the path
- AI Planning: Gemini analyzes your prompt and generates a structured
AnimationPlan(JSON) - Safe Codegen: Our controlled code generator creates Manim Python code from the plan
- Rendering: Manim renders the animation in an isolated Docker container
- Delivery: Video is stored and served for playback
Important: The AI only creates the animation plan (nodes, edges, steps). The actual Python code is generated by our safe, deterministic code generator - never by the LLM.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/health |
Health check |
| POST | /api/jobs |
Create rendering job |
| GET | /api/jobs/{id} |
Get job status and details |
| GET | /api/videos/{file} |
Serve rendered video file |
AnimaStudio/
├── backend/
│ ├── alembic/
│ │ ├── versions/
│ │ │ └── 001_initial_migration.py
│ │ ├── env.py
│ │ └── script.py.mako
│ ├── app/
│ │ ├── api/
│ │ │ └── routes.py
│ │ ├── core/
│ │ │ └── config.py
│ │ ├── db/
│ │ │ ├── base.py
│ │ │ └── session.py
│ │ ├── models/
│ │ │ └── job.py
│ │ ├── schemas/
│ │ │ └── job.py
│ │ ├── worker/
│ │ │ ├── celery_app.py
│ │ │ └── tasks.py
│ │ └── main.py
│ ├── Dockerfile
│ ├── requirements.txt
│ ├── pyproject.toml
│ └── alembic.ini
├── frontend/
│ ├── app/
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ └── page.tsx
│ ├── components/
│ │ └── ui/
│ │ ├── button.tsx
│ │ ├── card.tsx
│ │ ├── textarea.tsx
│ │ ├── alert.tsx
│ │ └── collapsible.tsx
│ ├── lib/
│ │ └── utils.ts
│ ├── Dockerfile
│ ├── package.json
│ ├── tsconfig.json
│ ├── next.config.js
│ ├── tailwind.config.ts
│ └── postcss.config.js
├── docker/
│ └── manim/
│ └── Dockerfile
├── outputs/
│ └── .gitkeep
├── docker-compose.yml
├── .env.example
├── .gitignore
└── README.md
Run tests:
docker exec -it anima_api pytestFormat code:
docker exec -it anima_api black app/
docker exec -it anima_api ruff check app/Create new migration:
docker exec -it anima_api alembic revision --autogenerate -m "description"Install dependencies locally (optional for IDE support):
cd frontend
npm installView API logs:
docker logs -f anima_apiView worker logs:
docker logs -f anima_workerView all services:
docker-compose logs -fSolution:
- Ensure Docker Desktop is running
- Check ports 3000, 8000, 5432, 6379 are not in use
- Run:
docker-compose down -vthendocker-compose up --build
Solution:
# Wait for PostgreSQL to be ready
docker-compose down
docker-compose up -d postgres
# Wait 10 seconds
docker-compose up -d api workerSolution:
# Reset database
docker-compose down -v
docker-compose up -d postgres
# Wait 10 seconds
docker exec -it anima_api alembic upgrade head
docker-compose up -dSolution:
# Ensure manim-renderer is built
docker-compose build manim-renderer
docker-compose up -d manim-renderer
docker-compose restart workerSolution:
- Check browser console for errors
- Verify file exists:
ls outputs/ - Check API logs:
docker logs anima_api - Ensure video file permissions:
docker exec -it anima_api ls -la /app/outputs
Solution:
- Check
.envhasNEXT_PUBLIC_API_URL=http://localhost:8000 - Verify API is running:
curl http://localhost:8000/api/health - Rebuild frontend:
docker-compose up --build web
Solution:
# Check Redis connection
docker exec -it anima_redis redis-cli ping
# Should return "PONG"
# Restart worker
docker-compose restart worker
# Check worker logs
docker logs -f anima_workerWindows PowerShell / macOS / Linux:
docker-compose downRemove volumes (
docker-compose down -vThis is a local development setup. For production:
- Use managed PostgreSQL (e.g., AWS RDS, Azure Database)
- Use managed Redis (e.g., AWS ElastiCache, Azure Cache)
- Configure proper CORS origins
- Add authentication/authorization
- Use production-grade reverse proxy (nginx)
- Implement rate limiting
- Add monitoring and logging (e.g., Sentry, DataDog)
- Use environment-specific
.envfiles - Enable HTTPS/TLS
- Scale workers horizontally based on load
MIT
Pull requests welcome! Please ensure:
- Code passes
ruffandblackchecks - Tests are included for new features
- Documentation is updated
Built with ❤️ using FastAPI, Next.js, and Manim