Skip to content

Ankit-Kumar20/murf-manim-hack

Repository files navigation

Mona

An AI-powered educational platform that creates comprehensive learning experiences through animated visualizations, written articles, audio narration, and interactive conversations. Built with Next.js and integrated with multiple AI services for generating educational content.

🎯 Features

  • 🎬 Video Generation: Create Manim-powered mathematical animations with synchronized audio narration
  • πŸ“ Article Generation: Generate structured educational articles with AI-powered content
  • 🎡 Audio Narration: Convert articles to natural speech using Murf AI's text-to-speech
  • πŸ’¬ Interactive Chatbot: Engage in conversational learning with AI-powered explanations
  • 🌐 Multilingual Support: Translate content and generate audio in multiple languages
  • 🎨 Visual Learning: Dynamic mathematical visualizations using Manim animation engine
  • πŸ“š Content Library: Browse and manage generated educational materials
  • πŸ”’ Secure Sandbox: Execute code safely in isolated E2B containers
  • ⚑ Real-time Generation: Dynamic content creation based on user input
  • 🎭 Modern UI: Responsive interface with shader backgrounds and smooth animations

πŸ“± Pages & Routes

  • Home (/) - Landing page with service overview and quick actions
  • Explain (/explain/[topic]) - Generate animated videos for mathematical concepts
  • Article (/article) - Create structured educational articles
  • Library (/library) - Browse and manage generated content
  • Translation Demo (/translation-demo) - Test multilingual capabilities
  • Loading (/loading) - Processing states during content generation

πŸ›  Tech Stack

  • Frontend: Next.js 15, React 19, TypeScript
  • Styling: Tailwind CSS 4, Paper Design Shaders, Motion (animations)
  • AI Services:
    • OpenRouter: Primary AI provider (GPT-4, Gemini, Claude)
    • Google AI: Alternative AI provider for enhanced responses
    • Murf AI: Professional text-to-speech and voice synthesis
  • Sandbox & Execution: E2B Code Interpreter for secure code execution
  • Animation: Manim (Mathematical Animation Engine) for video generation
  • Storage: Vercel Blob for file storage and delivery
  • Package Manager: Bun (with npm fallback)
  • Development: ESLint, Turbopack for fast builds

πŸš€ Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/Ankit-Kumar20/murf-manim-hack.git
    cd murf-manim-hack
  2. Install dependencies

    bun install
    # or
    npm install
  3. Environment Setup Create a .env.local file with your API keys:

    E2B_API_KEY=your_e2b_api_key
    OPENROUTER_API_KEY=your_openrouter_api_key
    MURF_AI_API_KEY=your_murf_ai_api_key
    BLOB_READ_WRITE_TOKEN=your_vercel_blob_token
  4. Run the development server

    bun dev
    # or
    npm run dev
  5. Open your browser Navigate to http://localhost:3000

🐳 E2B Sandbox Setup

This project uses a custom E2B sandbox environment with Manim pre-installed.

Sandbox Template: q6wznn8hq65ffgkd0tqh

The sandbox includes:

  • Python 3.10
  • Manim with all dependencies
  • FFmpeg for video processing
  • Cairo and Pango for rendering

Building the Sandbox Template

If you need to rebuild the sandbox template:

e2b template build

The template configuration is defined in:

  • e2b.Dockerfile - Docker configuration with Manim installation
  • e2b.toml - E2B template configuration

πŸ“ Project Structure

β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                          # Next.js app directory
β”‚   β”‚   β”œβ”€β”€ api/                      # API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ chatbot/              # Conversational AI endpoint
β”‚   β”‚   β”‚   β”œβ”€β”€ code-execution/       # Code execution in sandbox
β”‚   β”‚   β”‚   β”œβ”€β”€ generate-article/     # Article generation
β”‚   β”‚   β”‚   β”œβ”€β”€ generate-audio/       # Text-to-speech audio generation
β”‚   β”‚   β”‚   β”œβ”€β”€ generate-lesson/      # Lesson plan generation
β”‚   β”‚   β”‚   β”œβ”€β”€ generate-manim/       # Manim code generation
β”‚   β”‚   β”‚   β”œβ”€β”€ test-env/             # Environment testing
β”‚   β”‚   β”‚   β”œβ”€β”€ test-voices/          # Voice testing
β”‚   β”‚   β”‚   β”œβ”€β”€ translate/            # Translation services
β”‚   β”‚   β”‚   └── voices/               # Voice options
β”‚   β”‚   β”œβ”€β”€ article/                  # Article generation pages
β”‚   β”‚   β”œβ”€β”€ explain/                  # Concept explanation pages
β”‚   β”‚   β”œβ”€β”€ library/                  # Content library
β”‚   β”‚   β”œβ”€β”€ translation-demo/         # Translation demonstration
β”‚   β”‚   β”œβ”€β”€ loading/                  # Loading states
β”‚   β”‚   β”œβ”€β”€ layout.tsx                # Root layout
β”‚   β”‚   β”œβ”€β”€ page.tsx                  # Homepage
β”‚   β”‚   β”œβ”€β”€ globals.css               # Global styles
β”‚   β”‚   └── favicon.ico               # App favicon
β”‚   β”œβ”€β”€ components/                   # React components
β”‚   β”‚   β”œβ”€β”€ ArticleDisplay.tsx        # Article rendering
β”‚   β”‚   β”œβ”€β”€ ConceptInputForm.tsx      # Input forms
β”‚   β”‚   β”œβ”€β”€ ContentModeSelector.tsx   # Content type selection
β”‚   β”‚   β”œβ”€β”€ EnhancedArticleDisplay.tsx # Advanced article display
β”‚   β”‚   β”œβ”€β”€ EnhancedLessonBreakdown.tsx # Lesson components
β”‚   β”‚   β”œβ”€β”€ Footer.tsx                # Site footer
β”‚   β”‚   β”œβ”€β”€ LanguageSelector.tsx      # Language selection
β”‚   β”‚   β”œβ”€β”€ LessonArticleDisplay.tsx  # Lesson article display
β”‚   β”‚   β”œβ”€β”€ LessonBreakdown.tsx       # Lesson breakdown
β”‚   β”‚   β”œβ”€β”€ Navbar.tsx                # Navigation
β”‚   β”‚   β”œβ”€β”€ ShaderBackground.tsx      # Background effects
β”‚   β”‚   β”œβ”€β”€ SimpleEnhancedArticleDisplay.tsx # Simplified display
β”‚   β”‚   β”œβ”€β”€ SubmittedTopicTitle.tsx   # Topic display
β”‚   β”‚   β”œβ”€β”€ TypewriterText.tsx        # Animated text
β”‚   β”‚   └── VideoWithAudio.tsx        # Video with audio sync
β”‚   └── utils/                        # Utility functions
β”‚       β”œβ”€β”€ blobStorage.ts            # File storage utilities
β”‚       β”œβ”€β”€ clearCache.ts             # Cache management
β”‚       β”œβ”€β”€ formatManimCode.ts        # Manim code formatting
β”‚       β”œβ”€β”€ lessonBreakdown.ts        # Lesson processing
β”‚       β”œβ”€β”€ murfTTS.ts                # Text-to-speech integration
β”‚       β”œβ”€β”€ sandbox.ts                # E2B sandbox integration
β”‚       β”œβ”€β”€ structuredManimGenerator.ts # Manim code generation
β”‚       β”œβ”€β”€ translation.ts            # Translation utilities
β”‚       └── voiceNarration.ts         # Voice narration
β”œβ”€β”€ public/                           # Static assets
β”‚   β”œβ”€β”€ audio/                        # Generated audio files
β”‚   β”œβ”€β”€ videos/                       # Generated video files
β”‚   β”œβ”€β”€ *.svg                         # UI icons
β”‚   └── *.ico                         # Favicons
β”œβ”€β”€ e2b.Dockerfile                    # E2B sandbox configuration
β”œβ”€β”€ e2b.toml                          # E2B template settings
β”œβ”€β”€ StringTheoryScene.py              # Example Manim scene
└── package.json                      # Dependencies and scripts

πŸ”§ API Endpoints

Core Generation Endpoints

/api/generate-manim

Generates Manim animation code for mathematical concepts.

Request:

{
  "topic": "quadratic functions",
  "details": "Show the graph transformation"
}

Response:

{
  "success": true,
  "code": "from manim import *\n\nclass QuadraticFunction(Scene):\n    def construct(self):\n        ...",
  "explanation": "This animation demonstrates..."
}

/api/generate-article

Creates structured educational articles with AI-generated content.

Request:

{
  "topic": "machine learning",
  "audience": "beginners",
  "sections": ["introduction", "basics", "applications"]
}

/api/generate-lesson

Generates comprehensive lesson plans with breakdown and activities.

/api/generate-audio

Converts articles to speech using Murf AI's text-to-speech.

Request:

{
  "articleContent": {
    "title": "Introduction to Algebra",
    "introduction": "...",
    "sections": [...],
    "conclusion": "..."
  },
  "languages": ["en", "es"],
  "voiceOptions": {
    "voice": "en-US-female-1",
    "speed": 1.0
  }
}

Interactive Features

/api/chatbot

Provides conversational AI for educational topics with session management.

Request:

{
  "message": "Explain derivatives",
  "sessionId": "unique-session-123",
  "topic": "calculus"
}

/api/translate

Translates text and articles to multiple languages.

Request:

{
  "type": "article",
  "targetLanguage": "es",
  "data": {
    "articleContent": {...}
  }
}

Utility Endpoints

/api/code-execution

Executes code safely in E2B sandbox environment.

/api/voices

Retrieves available voice options for text-to-speech.

/api/test-voices

Tests voice synthesis with sample text.

/api/test-env

Environment testing and validation.

πŸ’‘ Usage Examples

Creating Educational Videos

  1. Navigate to /explain
  2. Enter a mathematical concept (e.g., "quadratic equations")
  3. Choose visualization options
  4. Generate Manim animation with AI narration

Generating Articles

  1. Go to /article
  2. Specify topic and audience level
  3. Select article structure
  4. Generate comprehensive educational content

Multilingual Content

  1. Create content in any supported language
  2. Use translation API to convert to multiple languages
  3. Generate audio narration in target languages
  4. Access content library for all versions

Interactive Learning

  1. Use chatbot for conversational explanations
  2. Generate lesson breakdowns with activities
  3. Create video + audio combinations
  4. Save everything to your personal library

🎨 Components

Core UI Components

  • ConceptInputForm - Interactive form for submitting concepts to visualize
  • ContentModeSelector - Toggle between different content generation modes
  • LanguageSelector - Select target languages for translation
  • Navbar - Main navigation component
  • Footer - Site footer with links

Content Display Components

  • ArticleDisplay - Basic article rendering
  • EnhancedArticleDisplay - Advanced article display with formatting
  • SimpleEnhancedArticleDisplay - Lightweight article display
  • LessonArticleDisplay - Specialized display for lesson content
  • LessonBreakdown - Interactive lesson breakdown component
  • EnhancedLessonBreakdown - Advanced lesson breakdown with activities

Interactive Components

  • VideoWithAudio - Synchronized video and audio playback
  • TypewriterText - Animated typewriter text effect
  • SubmittedTopicTitle - Displays current topic being processed
  • ShaderBackground - Dynamic WebGL shader background effects

πŸ”’ Security Features

  • Sandboxed Execution: All code runs in isolated E2B containers
  • Input Validation: Robust validation of user inputs
  • Rate Limiting: API endpoints are rate-limited
  • Error Handling: Comprehensive error handling and logging

πŸ› Troubleshooting

Common Issues

  1. E2B Sandbox Fails to Start

    • Ensure your E2B API key is valid
    • Check that the template q6wznn8hq65ffgkd0tqh exists
    • Rebuild the template if necessary
  2. Manim Import Errors

    • Verify the sandbox template includes all Manim dependencies
    • Check the Docker build logs for any installation issues
  3. API Key Errors

    • Ensure all required environment variables are set
    • Verify API keys are valid and have sufficient quotas

Testing the Sandbox

Test the Manim environment using the example scene:

python StringTheoryScene.py

Or use the built-in API testing endpoints:

  • /api/test-env - Environment validation
  • /api/test-voices - Voice synthesis testing

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Commit your changes: git commit -m 'Add feature'
  4. Push to the branch: git push origin feature-name
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Links

Documentation

Related Tools

Development

πŸ“§ Support

For support, please open an issue on GitHub or contact the development team.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages