A scalable, microservice-based application that converts video files to MP3 audio format. Built with Python Flask, this system leverages asynchronous processing with RabbitMQ, MongoDB for file storage, and JWT-based authentication to provide a robust video-to-audio conversion service.
Perfect for: Content creators, podcasters, developers learning microservice architecture, or anyone needing reliable video-to-audio conversion at scale.
- π¬ Video Upload & Processing: Support for multiple video formats (MP4, AVI, MOV, etc.)
- π΅ High-Quality Audio Extraction: Converts videos to MP3 with customizable quality settings
- π JWT Authentication: Secure user authentication and authorization
- π§ Email Notifications: Automatic email alerts when conversion is complete
- β‘ Asynchronous Processing: Non-blocking video processing using RabbitMQ
- ποΈ GridFS Storage: Efficient handling of large video and audio files
- π³ Containerized: Fully dockerized for easy deployment
- π RESTful API: Clean, well-documented API endpoints
- ποΈ Microservice Architecture: Scalable, maintainable service separation
The application follows a microservice architecture with four main components:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β API Gateway β β Auth Service β β Notification β
β (Flask API) ββββββ (JWT Auth) β β Service β
β β β β β (Email Alerts) β
βββββββββββ¬ββββββββ βββββββββββββββββββ βββββββββββ¬ββββββββ
β β
β βββββββββββββββββββ β
ββββββββββββββββ RabbitMQ βββββββββββββββ
β Message Broker β
βββββββββββ¬ββββββββ
β
βββββββββββ΄ββββββββ
β Converter β
β Service β
β (VideoβAudio) β
βββββββββββββββββββ
β
βββββββββββ΄ββββββββ
β MongoDB β
β (GridFS Storage)β
βββββββββββββββββββ
- Python 3.9+ - Core programming language
- Flask - Web framework for API services
- MoviePy - Video processing and audio extraction
- PyMongo - MongoDB integration
- Pika - RabbitMQ client
- PyJWT - JSON Web Token handling
- MongoDB - Document database with GridFS for file storage
- MySQL - Relational database for user management
- RabbitMQ - Asynchronous message processing
- Docker - Containerization
- Docker Compose - Multi-container orchestration
- Gmail SMTP - Email notification delivery
- Python 3.9+
- Docker & Docker Compose
- Git
git clone https://github.com/yourusername/video-to-audio-converter.git
cd video-to-audio-converterCreate .env files for each service:
Gateway Service (.env)
MONGO_HOST=mongodb://mongo:27017
MONGO_DB=videos
AUTH_SVC_ADDRESS=auth:5000
RABBIT_MQ_HOST=rabbitmq
RABBIT_MQ_PORT=5672
RABBIT_MQ_USER=guest
RABBIT_MQ_PASSWORD=guestAuth Service (.env)
MYSQL_HOST=mysql
MYSQL_USER=auth_user
MYSQL_PASSWORD=your_password
MYSQL_DB=auth
JWT_SECRET=your_jwt_secret_keyNotification Service (.env)
GMAIL_ADDRESS=your_email@gmail.com
GMAIL_PASSWORD=your_app_password
RABBIT_MQ_HOST=rabbitmq
MP3_QUEUE=mp3Converter Service (.env)
MONGO_HOST=mongodb://mongo:27017
MONGO_DB=videos
RABBIT_MQ_HOST=rabbitmq
MP3_QUEUE=mp3# Build and start all services
docker-compose up --build
# Run in background
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Start individual services
python src/gateway/app.py
python src/auth/server.py
python src/converter/consumer.py
python src/notification/server.pyPOST /login
Authorization: Basic base64(username:password)Response: JWT Token
POST /validate
Authorization: Bearer <jwt_token>POST /upload
Authorization: Bearer <jwt_token>
Content-Type: multipart/form-data
Form Data:
- file: video file (MP4, AVI, MOV, etc.)GET /download?fid=<file_id>
Authorization: Bearer <jwt_token>Response: MP3 file download
# Login and get JWT token
curl -X POST http://localhost:5000/login \
-H "Authorization: Basic $(echo -n 'username:password' | base64)"
# Response: JWT token# Upload video file
curl -X POST http://localhost:5000/upload \
-H "Authorization: Bearer <your_jwt_token>" \
-F "file=@/path/to/your/video.mp4"
# Response: Upload confirmation# Download MP3 file
curl -X GET "http://localhost:5000/download?fid=<file_id>" \
-H "Authorization: Bearer <your_jwt_token>" \
-o converted_audio.mp3- Upload: User uploads video via API Gateway
- Queue: Video processing job added to RabbitMQ
- Convert: Converter service extracts audio using MoviePy
- Store: MP3 file saved to MongoDB GridFS
- Notify: Email notification sent to user
- Download: User downloads MP3 via provided file ID
- MP4, AVI, MOV, WMV, FLV, MKV
- Maximum file size: 500MB (configurable)
- Format: MP3
- Quality: 128kbps (default, configurable)
- Sample Rate: 44.1kHz
- video: Input queue for video processing
- mp3: Output queue for notification service
# Run unit tests
python -m pytest tests/
# Run with coverage
python -m pytest --cov=src tests/
# Integration tests
python -m pytest tests/integration/- RabbitMQ Management: http://localhost:15672
- MongoDB Compass: mongodb://localhost:27017
- Application Logs: Available via
docker-compose logs
- Use environment-specific configuration
- Implement proper logging and monitoring
- Set up SSL/TLS certificates
- Configure load balancing for high availability
- Use managed database services (MongoDB Atlas, AWS RDS)
- Implement file size limits and validation
- Horizontal: Deploy multiple converter instances
- Vertical: Increase container resources
- Queue Management: Monitor RabbitMQ performance
- Storage: Use cloud storage solutions (AWS S3, Google Cloud Storage)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 style guidelines
- Write unit tests for new features
- Update documentation as needed
- Ensure Docker containers build successfully
This project is licensed under the MIT License - see the LICENSE file for details.
β If this project helped you, please consider giving it a star!
Built with β€οΈ using Python, Flask, MongoDB, and RabbitMQ