π΅ 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 <repository-url>
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)