# IPTV Manager Service A FastAPI-based service for managing IPTV playlists and channel priorities. The application provides secure endpoints for user authentication, channel management, and playlist generation. ## โœจ Features - **JWT Authentication**: Secure login using AWS Cognito - **Channel Management**: CRUD operations for IPTV channels - **Playlist Generation**: Create M3U playlists with channel priorities - **Stream Monitoring**: Background checks for channel availability - **Priority Management**: Set channel priorities for playlist ordering ## ๐Ÿ› ๏ธ Technology Stack - **Backend**: Python 3.11, FastAPI - **Database**: PostgreSQL (SQLAlchemy ORM) - **Authentication**: AWS Cognito - **Infrastructure**: AWS CDK (API Gateway, Lambda, RDS) - **Testing**: Pytest with 85%+ coverage - **CI/CD**: Pre-commit hooks, Alembic migrations ## ๐Ÿš€ Getting Started ### Prerequisites - Python 3.11+ - Docker - AWS CLI (for deployment) ### Installation ```bash # Clone repository git clone https://github.com/your-repo/iptv-manager-service.git cd iptv-manager-service # Setup environment python -m venv venv source venv/bin/activate pip install -r requirements.txt cp .env.example .env # Update with your values # Run installation script ./scripts/install.sh ``` ### Running Locally ```bash # Start development environment ./scripts/start_local_dev.sh # Stop development environment ./scripts/stop_local_dev.sh ``` ## โ˜๏ธ AWS Deployment The infrastructure is defined in CDK. Use the provided scripts: ```bash # Deploy AWS infrastructure ./scripts/deploy.sh # Destroy AWS infrastructure ./scripts/destroy.sh # Create Cognito test user ./scripts/create_cognito_user.sh # Delete Cognito user ./scripts/delete_cognito_user.sh ``` Key AWS components: - API Gateway - Lambda functions - RDS PostgreSQL - Cognito User Pool ## ๐Ÿค– Continuous Integration/Deployment This project includes a Gitea Actions workflow (`.gitea/workflows/deploy.yml`) for automated deployment to AWS. The workflow is fully compatible with GitHub Actions and can be easily adapted by: 1. Placing the workflow file in the `.github/workflows/` directory 2. Setting up the required secrets in your CI/CD environment: - `AWS_ACCESS_KEY_ID` - `AWS_SECRET_ACCESS_KEY` - `AWS_DEFAULT_REGION` The workflow automatically deploys the infrastructure and application when changes are pushed to the main branch. ## ๐Ÿ“š API Documentation Access interactive docs at: - Swagger UI: `http://localhost:8000/docs` - ReDoc: `http://localhost:8000/redoc` ### Key Endpoints | Endpoint | Method | Description | | ------------- | ------ | --------------------- | | `/auth/login` | POST | User authentication | | `/channels` | GET | List all channels | | `/playlist` | GET | Generate M3U playlist | | `/priorities` | POST | Set channel priority | ## ๐Ÿงช Testing Run the full test suite: ```bash pytest ``` Test coverage includes: - Authentication workflows - Channel CRUD operations - Playlist generation logic - Stream monitoring - Database operations ## ๐Ÿ“‚ Project Structure ```txt iptv-manager-service/ โ”œโ”€โ”€ app/ # Core application โ”‚ โ”œโ”€โ”€ auth/ # Cognito authentication โ”‚ โ”œโ”€โ”€ iptv/ # Playlist logic โ”‚ โ”œโ”€โ”€ models/ # Database models โ”‚ โ”œโ”€โ”€ routers/ # API endpoints โ”‚ โ”œโ”€โ”€ utils/ # Helper functions โ”‚ โ””โ”€โ”€ main.py # App entry point โ”œโ”€โ”€ infrastructure/ # AWS CDK stack โ”œโ”€โ”€ docker/ # Docker configs โ”œโ”€โ”€ scripts/ # Deployment scripts โ”œโ”€โ”€ tests/ # Comprehensive tests โ”œโ”€โ”€ alembic/ # Database migrations โ”œโ”€โ”€ .gitea/ # Gitea CI/CD workflows โ”‚ โ””โ”€โ”€ workflows/ โ””โ”€โ”€ ... # Config files ``` ## ๐Ÿ“ License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.