๐ต Video to MP3 Converter
A modern, scalable microservices-based video to MP3 conversion platform built with FastAPI, featuring user authentication, file processing, and email notifications.
๐๏ธ Architecture
This project follows a microservices architecture pattern with the following services:
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Gateway โ โ Auth Service โ โ Media Service โ
โ (Port 8000) โโโโโบโ (Port 5000) โ โ (Port 7000) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Convertor โ โ Notification โ โ RabbitMQ โ
โ Service โ โ Service โ โ Message โ
โ (Port 4000) โ โ (Port 6000) โ โ Broker โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ MongoDB โ โ PostgreSQL โ โ Mongo Express โ
โ (Port 27017) โ โ (Port 5433) โ โ (Port 8081) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
๐ Features
- User Authentication: JWT-based authentication with registration and login
- Video Upload: Secure file upload with GridFS storage
- Video Processing: Asynchronous video to MP3 conversion using FFmpeg
- Email Notifications: Automated welcome and conversion completion emails
- API Gateway: Centralized routing and request handling
- Microservices: Scalable, independent service architecture
- Message Queuing: RabbitMQ for asynchronous communication
- Database Support: PostgreSQL for user data, MongoDB for file storage
๐ ๏ธ Tech Stack
Backend Services
- FastAPI - Modern, fast web framework for building APIs
- Python 3.13 - Programming language
- SQLModel - Database ORM with type safety
- Pydantic - Data validation and settings management
Databases
- PostgreSQL 17 - Relational database for user management
- MongoDB 6.0 - Document database with GridFS for file storage
Message Queue
- RabbitMQ 3.12 - Message broker for asynchronous communication
Media Processing
- FFmpeg - Video/audio processing and conversion
Email Service
- FastAPI-Mail - Email sending capabilities
Infrastructure
- Docker & Docker Compose - Containerization and orchestration
- Uvicorn - ASGI server for FastAPI applications
๐ Project Structure
video-mp3-convertor/
โโโ docker-compose.dev.yml # Development environment setup
โโโ services/
โโโ auth/ # Authentication service
โ โโโ src/
โ โ โโโ auth/ # Auth module
โ โ โ โโโ routes.py # API endpoints
โ โ โ โโโ service.py # Business logic
โ โ โ โโโ schema.py # Data models
โ โ โ โโโ utils.py # Utilities (JWT, hashing)
โ โ โโโ db/ # Database configuration
โ โโโ requirements.txt
โโโ convertor/ # Video conversion service
โ โโโ main.py # Service entry point
โ โโโ mp3_consumer.py # RabbitMQ consumer
โ โโโ requirements.txt
โโโ gateway/ # API Gateway
โ โโโ main.py # Proxy service
โ โโโ requirements.txt
โโโ media/ # Media handling service
โ โโโ src/
โ โ โโโ media/ # Media module
โ โ โ โโโ routes.py # Upload/download endpoints
โ โ โ โโโ service.py # File operations
โ โ โโโ auth.py # Authentication middleware
โ โโโ requirements.txt
โโโ notification/ # Email notification service
โโโ src/
โ โโโ consumer/ # Message consumers
โ โ โโโ mp3_consumer.py # Conversion notifications
โ โ โโโ user_consumer.py # Welcome emails
โ โโโ mail.py # Email configuration
โโโ requirements.txt
๐ Quick Start
Prerequisites
- Docker and Docker Compose
- Git
Installation
- Clone the repository
git clone https://github.com/fu-ry17/video-mp3-convertor
cd video-mp3-convertor
- Start the services
docker-compose -f docker-compose.dev.yml up --build
-
Access the services
- API Gateway: http://localhost:8000
- Auth Service: http://localhost:5000
- Media Service: http://localhost:7000
- RabbitMQ Management: http://localhost:15672 (admin/pass)
- Mongo Express: http://localhost:8081 (admin/pass)
๐ API Documentation
Authentication Endpoints
Register User
POST /auth/sign-up
Content-Type: application/json
{
"email": "user@example.com",
"password": "securepassword"
}
Login User
POST /auth/sign-in
Content-Type: application/json
{
"email": "user@example.com",
"password": "securepassword"
}
Verify Token
GET /auth/verify
Authorization: Bearer <access_token>
Media Endpoints
Upload Video
POST /media/upload
Authorization: Bearer <access_token>
Content-Type: multipart/form-data
file: <video_file>
Download MP3
GET /media/download/{file_id}
Authorization: Bearer <access_token>
๐ Workflow
- User Registration/Login: Users authenticate through the auth service
- Video Upload: Users upload videos through the media service
- File Storage: Videos are stored in MongoDB using GridFS
- Message Queue: Upload event triggers RabbitMQ message
- Video Processing: Convertor service processes videos to MP3 using FFmpeg
- Notification: Email notification sent when conversion is complete
- Download: Users can download converted MP3 files
๐ณ Docker Services
| Service | Port | Description |
|---|---|---|
| Gateway | 8000 | API Gateway and routing |
| Auth | 5000 | User authentication |
| Media | 7000 | File upload/download |
| Convertor | 4000 | Video processing |
| Notification | 6000 | Email notifications |
| PostgreSQL | 5433 | User database |
| MongoDB | 27017 | File storage |
| RabbitMQ | 5672 | Message broker |
| RabbitMQ Management | 15672 | Message queue UI |
| Mongo Express | 8081 | MongoDB UI |
๐ง Environment Variables
Auth Service
-
JWT_SECRET: Secret key for JWT token generation -
DATABASE_URL: PostgreSQL connection string -
RABBITMQ_URL: RabbitMQ connection string
Media Service
-
RABBITMQ_URL: RabbitMQ connection string -
MONGODB_URL: MongoDB connection string -
AUTH_URL: Auth service URL for token validation
Convertor Service
-
RABBITMQ_URL: RabbitMQ connection string -
MONGODB_URL: MongoDB connection string
Gateway Service
-
AUTH_URL: Auth service URL -
MEDIA_URL: Media service URL
๐งช Development
Running Individual Services
Each service can be run independently:
# Auth Service
cd services/auth
python -m uvicorn src.main:app --host 0.0.0.0 --port 5000
# Media Service
cd services/media
python -m uvicorn src.main:app --host 0.0.0.0 --port 7000
# Gateway Service
cd services/gateway
python -m uvicorn main:app --host 0.0.0.0 --port 8000
Database Migrations
The auth service uses SQLModel with automatic table creation. For production, consider using Alembic for migrations.
๐ Security Features
- JWT-based authentication with access and refresh tokens
- Password hashing using bcrypt
- Token-based authorization for protected endpoints
- Secure file upload with validation
- Environment-based configuration
๐ Scalability
- Microservices architecture allows independent scaling
- Message queue enables asynchronous processing
- Stateless services for horizontal scaling
- Database separation for different data types
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฏ Future Enhancements
- [ ] WebSocket support for real-time conversion progress
- [ ] Multiple output formats (WAV, AAC, etc.)
- [ ] Batch processing capabilities
- [ ] User dashboard with conversion history
- [ ] File size and format validation
- [ ] Rate limiting and usage quotas
- [ ] Cloud storage integration (AWS S3, Google Cloud)
- [ ] Kubernetes deployment configuration
- [ ] Monitoring and logging with Prometheus/Grafana
- [ ] CI/CD pipeline setup
Built with โค๏ธ using FastAPI and modern Python practices
Top comments (0)