Write a App in python with Flask. Make sure that you do not override the existing main.py Use existing classes but if a chnae is needed make sure main.py works as before. Look at Main.py to understand the function. Write all files in folder src/server/ Use the checklist to write the app. start on the first task. make sure each task is finished. mark a finished task with x, and save it. Stop if all Task are finshed before you start the app run conda activate AniWorld set ANIME_DIRECTORY="\\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien" cd src\server make sure you run the command on the same powershell terminal. otherwiese this do not work. AniWorld Web App Feature Checklist [] Reorganize the Project [] Move files and create folders as described in the list below [] fix import issues python files [] fix paths and usings [] run tests and fix issues [] run app and check for javascript issues ``` AniWorld/ # Project root ├── .github/ # GitHub configuration and workflows │ ├── workflows/ # CI/CD pipelines │ ├── ISSUE_TEMPLATE/ # Issue templates │ ├── PULL_REQUEST_TEMPLATE.md # PR template │ └── copilot-instructions.md # Copilot coding guidelines ├── .vscode/ # VS Code configuration │ ├── settings.json # Editor settings │ ├── launch.json # Debug configurations │ └── extensions.json # Recommended extensions ├── docs/ # Project documentation │ ├── api/ # API documentation │ │ ├── openapi.yaml # OpenAPI specification │ │ ├── endpoints.md # Endpoint documentation │ │ └── examples/ # API usage examples │ ├── architecture/ # Architecture documentation │ │ ├── clean-architecture.md # Clean architecture overview │ │ ├── database-schema.md # Database design │ │ └── security.md # Security implementation │ ├── deployment/ # Deployment guides │ │ ├── docker.md # Docker deployment │ │ ├── production.md # Production setup │ │ └── troubleshooting.md # Common issues │ ├── development/ # Development guides │ │ ├── setup.md # Development environment setup │ │ ├── contributing.md # Contribution guidelines │ │ └── testing.md # Testing strategies │ └── user/ # User documentation │ ├── installation.md # Installation guide │ ├── configuration.md # Configuration options │ └── usage.md # User manual ├── docker/ # Docker configuration │ ├── Dockerfile # Main application Dockerfile │ ├── Dockerfile.dev # Development Dockerfile │ ├── docker-compose.yml # Production compose │ ├── docker-compose.dev.yml # Development compose │ └── nginx/ # Nginx configuration │ ├── nginx.conf # Main nginx config │ └── ssl/ # SSL certificates ├── scripts/ # Utility and automation scripts │ ├── setup/ # Setup scripts │ │ ├── install-dependencies.py # Dependency installation │ │ ├── setup-database.py # Database initialization │ │ └── create-config.py # Configuration file creation │ ├── maintenance/ # Maintenance scripts │ │ ├── backup-database.py # Database backup │ │ ├── cleanup-files.py # File system cleanup │ │ └── migrate-data.py # Data migration │ ├── deployment/ # Deployment scripts │ │ ├── deploy.sh # Deployment automation │ │ ├── health-check.py # Health monitoring │ │ └── update-service.py # Service updates │ └── development/ # Development utilities │ ├── generate-test-data.py # Test data generation │ ├── run-tests.sh # Test execution │ └── code-quality.py # Code quality checks ├── src/ # Source code root │ ├── main.py # Original CLI entry point (preserve existing) │ ├── server/ # Flask web application │ │ ├── app.py # Flask application factory │ │ ├── wsgi.py # WSGI entry point for production │ │ ├── config.py # Configuration management │ │ ├── requirements.txt # Python dependencies │ │ ├── .env.example # Environment variables template │ │ │ │ │ ├── core/ # Core business logic (Clean Architecture) │ │ │ ├── __init__.py │ │ │ ├── entities/ # Domain entities │ │ │ │ ├── __init__.py │ │ │ │ ├── anime.py # Anime entity │ │ │ │ ├── episode.py # Episode entity │ │ │ │ ├── series.py # Series entity │ │ │ │ ├── download.py # Download entity │ │ │ │ └── user.py # User entity │ │ │ ├── interfaces/ # Domain interfaces │ │ │ │ ├── __init__.py │ │ │ │ ├── repositories.py # Repository contracts │ │ │ │ ├── services.py # Service contracts │ │ │ │ ├── providers.py # Provider contracts │ │ │ │ └── notifications.py # Notification contracts │ │ │ ├── use_cases/ # Business use cases │ │ │ │ ├── __init__.py │ │ │ │ ├── search_anime.py # Search functionality │ │ │ │ ├── download_episodes.py # Download management │ │ │ │ ├── rescan_library.py # Library scanning │ │ │ │ ├── manage_queue.py # Queue management │ │ │ │ ├── authenticate_user.py # Authentication │ │ │ │ └── schedule_operations.py # Scheduled tasks │ │ │ └── exceptions/ # Domain exceptions │ │ │ ├── __init__.py │ │ │ ├── anime_exceptions.py │ │ │ ├── download_exceptions.py │ │ │ ├── auth_exceptions.py │ │ │ └── config_exceptions.py │ │ │ │ │ ├── infrastructure/ # External concerns implementation │ │ │ ├── __init__.py │ │ │ ├── database/ # Database layer │ │ │ │ ├── __init__.py │ │ │ │ ├── models.py # SQLAlchemy models │ │ │ │ ├── repositories.py # Repository implementations │ │ │ │ ├── connection.py # Database connection │ │ │ │ └── migrations/ # Database migrations │ │ │ │ ├── __init__.py │ │ │ │ ├── v001_initial.py │ │ │ │ └── v002_add_scheduling.py │ │ │ ├── providers/ # Anime providers │ │ │ │ ├── __init__.py │ │ │ │ ├── base_provider.py # Abstract provider │ │ │ │ ├── aniworld_provider.py # AniWorld implementation │ │ │ │ ├── provider_factory.py # Provider factory │ │ │ │ └── http_client.py # HTTP client wrapper │ │ │ ├── file_system/ # File system operations │ │ │ │ ├── __init__.py │ │ │ │ ├── directory_scanner.py # Directory operations │ │ │ │ ├── file_manager.py # File operations │ │ │ │ ├── path_resolver.py # Path utilities │ │ │ │ └── cleanup_service.py # File cleanup │ │ │ ├── external/ # External integrations │ │ │ │ ├── __init__.py │ │ │ │ ├── notification_service.py # Notifications │ │ │ │ ├── webhook_service.py # Webhook handling │ │ │ │ ├── discord_notifier.py # Discord integration │ │ │ │ └── telegram_notifier.py # Telegram integration │ │ │ ├── caching/ # Caching layer │ │ │ │ ├── __init__.py │ │ │ │ ├── redis_cache.py # Redis implementation │ │ │ │ ├── memory_cache.py # In-memory cache │ │ │ │ └── cache_manager.py # Cache coordination │ │ │ └── logging/ # Logging infrastructure │ │ │ ├── __init__.py │ │ │ ├── formatters.py # Log formatters │ │ │ ├── handlers.py # Log handlers │ │ │ └── fail2ban_logger.py # Security logging │ │ │ │ │ ├── application/ # Application services layer │ │ │ ├── __init__.py │ │ │ ├── services/ # Application services │ │ │ │ ├── __init__.py │ │ │ │ ├── anime_service.py # Anime business logic │ │ │ │ ├── download_service.py # Download coordination │ │ │ │ ├── search_service.py # Search orchestration │ │ │ │ ├── auth_service.py # Authentication service │ │ │ │ ├── scheduler_service.py # Task scheduling │ │ │ │ ├── queue_service.py # Queue management │ │ │ │ ├── config_service.py # Configuration service │ │ │ │ └── monitoring_service.py # System monitoring │ │ │ ├── dto/ # Data Transfer Objects │ │ │ │ ├── __init__.py │ │ │ │ ├── anime_dto.py # Anime DTOs │ │ │ │ ├── download_dto.py # Download DTOs │ │ │ │ ├── search_dto.py # Search DTOs │ │ │ │ ├── user_dto.py # User DTOs │ │ │ │ └── config_dto.py # Configuration DTOs │ │ │ ├── validators/ # Input validation │ │ │ │ ├── __init__.py │ │ │ │ ├── anime_validators.py │ │ │ │ ├── download_validators.py │ │ │ │ ├── auth_validators.py │ │ │ │ └── config_validators.py │ │ │ └── mappers/ # Data mapping │ │ │ ├── __init__.py │ │ │ ├── anime_mapper.py │ │ │ ├── download_mapper.py │ │ │ └── user_mapper.py │ │ │ │ │ ├── web/ # Web presentation layer │ │ │ ├── __init__.py │ │ │ ├── controllers/ # Flask blueprints │ │ │ │ ├── __init__.py │ │ │ │ ├── auth_controller.py # Authentication routes │ │ │ │ ├── anime_controller.py # Anime management │ │ │ │ ├── download_controller.py # Download management │ │ │ │ ├── config_controller.py # Configuration management │ │ │ │ ├── api/ # REST API endpoints │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── v1/ # API version 1 │ │ │ │ │ │ ├── __init__.py │ │ │ │ │ │ ├── anime.py # Anime API │ │ │ │ │ │ ├── downloads.py # Download API │ │ │ │ │ │ ├── search.py # Search API │ │ │ │ │ │ ├── queue.py # Queue API │ │ │ │ │ │ └── health.py # Health checks │ │ │ │ │ └── middleware/ # API middleware │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── auth.py # API authentication │ │ │ │ │ ├── rate_limit.py # Rate limiting │ │ │ │ │ └── cors.py # CORS handling │ │ │ │ └── admin/ # Admin interface │ │ │ │ ├── __init__.py │ │ │ │ ├── dashboard.py # Admin dashboard │ │ │ │ ├── system.py # System management │ │ │ │ └── logs.py # Log viewer │ │ │ ├── middleware/ # Web middleware │ │ │ │ ├── __init__.py │ │ │ │ ├── auth_middleware.py # Session management │ │ │ │ ├── error_handler.py # Error handling │ │ │ │ ├── logging_middleware.py # Request logging │ │ │ │ ├── security_headers.py # Security headers │ │ │ │ └── csrf_protection.py # CSRF protection │ │ │ ├── templates/ # Jinja2 templates │ │ │ │ ├── base/ # Base templates │ │ │ │ │ ├── layout.html # Main layout │ │ │ │ │ ├── header.html # Header component │ │ │ │ │ ├── footer.html # Footer component │ │ │ │ │ ├── sidebar.html # Sidebar navigation │ │ │ │ │ └── modals.html # Modal dialogs │ │ │ │ ├── auth/ # Authentication pages │ │ │ │ │ ├── login.html # Login page │ │ │ │ │ ├── logout.html # Logout confirmation │ │ │ │ │ └── session_expired.html # Session timeout │ │ │ │ ├── anime/ # Anime management │ │ │ │ │ ├── list.html # Anime list view │ │ │ │ │ ├── search.html # Search interface │ │ │ │ │ ├── details.html # Anime details │ │ │ │ │ ├── grid.html # Grid view │ │ │ │ │ └── cards.html # Card components │ │ │ │ ├── downloads/ # Download management │ │ │ │ │ ├── queue.html # Download queue │ │ │ │ │ ├── progress.html # Progress display │ │ │ │ │ ├── history.html # Download history │ │ │ │ │ └── statistics.html # Download stats │ │ │ │ ├── config/ # Configuration pages │ │ │ │ │ ├── settings.html # Main settings │ │ │ │ │ ├── providers.html # Provider config │ │ │ │ │ ├── scheduler.html # Schedule config │ │ │ │ │ └── notifications.html # Notification setup │ │ │ │ ├── admin/ # Admin interface │ │ │ │ │ ├── dashboard.html # Admin dashboard │ │ │ │ │ ├── system.html # System info │ │ │ │ │ ├── logs.html # Log viewer │ │ │ │ │ └── users.html # User management │ │ │ │ └── errors/ # Error pages │ │ │ │ ├── 404.html # Not found │ │ │ │ ├── 500.html # Server error │ │ │ │ ├── 403.html # Forbidden │ │ │ │ └── maintenance.html # Maintenance mode │ │ │ └── static/ # Static assets │ │ │ ├── css/ # Stylesheets │ │ │ │ ├── app.css # Main application styles │ │ │ │ ├── themes/ # Theme system │ │ │ │ │ ├── light.css # Light theme │ │ │ │ │ ├── dark.css # Dark theme │ │ │ │ │ └── auto.css # Auto theme switcher │ │ │ │ ├── components/ # Component styles │ │ │ │ │ ├── cards.css # Card components │ │ │ │ │ ├── forms.css # Form styling │ │ │ │ │ ├── buttons.css # Button styles │ │ │ │ │ ├── tables.css # Table styling │ │ │ │ │ ├── modals.css # Modal dialogs │ │ │ │ │ ├── progress.css # Progress bars │ │ │ │ │ └── notifications.css # Toast notifications │ │ │ │ ├── pages/ # Page-specific styles │ │ │ │ │ ├── auth.css # Authentication pages │ │ │ │ │ ├── anime.css # Anime pages │ │ │ │ │ ├── downloads.css # Download pages │ │ │ │ │ └── admin.css # Admin pages │ │ │ │ └── vendor/ # Third-party CSS │ │ │ │ ├── bootstrap.min.css │ │ │ │ └── fontawesome.min.css │ │ │ ├── js/ # JavaScript files │ │ │ │ ├── app.js # Main application script │ │ │ │ ├── config.js # Configuration object │ │ │ │ ├── components/ # JavaScript components │ │ │ │ │ ├── search.js # Search functionality │ │ │ │ │ ├── download-manager.js # Download management │ │ │ │ │ ├── theme-switcher.js # Theme switching │ │ │ │ │ ├── modal-handler.js # Modal management │ │ │ │ │ ├── progress-tracker.js # Progress tracking │ │ │ │ │ ├── notification-manager.js # Notifications │ │ │ │ │ ├── anime-grid.js # Anime grid view │ │ │ │ │ ├── queue-manager.js # Queue operations │ │ │ │ │ └── settings-manager.js # Settings UI │ │ │ │ ├── utils/ # Utility functions │ │ │ │ │ ├── api.js # API communication │ │ │ │ │ ├── websocket.js # WebSocket handling │ │ │ │ │ ├── validators.js # Client-side validation │ │ │ │ │ ├── formatters.js # Data formatting │ │ │ │ │ ├── storage.js # Local storage │ │ │ │ │ └── helpers.js # General helpers │ │ │ │ ├── pages/ # Page-specific scripts │ │ │ │ │ ├── auth.js # Authentication page │ │ │ │ │ ├── anime-list.js # Anime list page │ │ │ │ │ ├── download-queue.js # Download queue page │ │ │ │ │ ├── settings.js # Settings page │ │ │ │ │ └── admin.js # Admin pages │ │ │ │ └── vendor/ # Third-party JavaScript │ │ │ │ ├── bootstrap.bundle.min.js │ │ │ │ ├── jquery.min.js │ │ │ │ └── socket.io.min.js │ │ │ ├── images/ # Image assets │ │ │ │ ├── icons/ # Application icons │ │ │ │ │ ├── favicon.ico │ │ │ │ │ ├── logo.svg │ │ │ │ │ ├── download.svg │ │ │ │ │ ├── search.svg │ │ │ │ │ ├── settings.svg │ │ │ │ │ └── anime.svg │ │ │ │ ├── backgrounds/ # Background images │ │ │ │ │ ├── hero.jpg │ │ │ │ │ └── pattern.svg │ │ │ │ ├── covers/ # Anime cover placeholders │ │ │ │ │ ├── default.jpg │ │ │ │ │ └── loading.gif │ │ │ │ └── ui/ # UI graphics │ │ │ │ ├── spinner.svg │ │ │ │ └── progress-bg.png │ │ │ └── fonts/ # Custom fonts │ │ │ ├── Segoe-UI/ # Windows 11 font │ │ │ └── icons/ # Icon fonts │ │ │ │ │ ├── shared/ # Shared utilities and constants │ │ │ ├── __init__.py │ │ │ ├── constants/ # Application constants │ │ │ │ ├── __init__.py │ │ │ │ ├── enums.py # Enumerations │ │ │ │ ├── messages.py # User messages │ │ │ │ ├── config_keys.py # Configuration keys │ │ │ │ ├── file_types.py # Supported file types │ │ │ │ ├── status_codes.py # HTTP status codes │ │ │ │ └── error_codes.py # Application error codes │ │ │ ├── utils/ # Utility functions │ │ │ │ ├── __init__.py │ │ │ │ ├── validators.py # Input validation │ │ │ │ ├── formatters.py # Data formatting │ │ │ │ ├── crypto.py # Encryption utilities │ │ │ │ ├── file_utils.py # File operations │ │ │ │ ├── string_utils.py # String manipulation │ │ │ │ ├── date_utils.py # Date/time utilities │ │ │ │ ├── network_utils.py # Network operations │ │ │ │ └── system_utils.py # System information │ │ │ ├── decorators/ # Custom decorators │ │ │ │ ├── __init__.py │ │ │ │ ├── auth_required.py # Authentication decorator │ │ │ │ ├── rate_limit.py # Rate limiting decorator │ │ │ │ ├── retry.py # Retry decorator │ │ │ │ ├── cache.py # Caching decorator │ │ │ │ └── logging.py # Logging decorator │ │ │ └── middleware/ # Shared middleware │ │ │ ├── __init__.py │ │ │ ├── request_id.py # Request ID generation │ │ │ ├── timing.py # Request timing │ │ │ └── compression.py # Response compression │ │ │ │ │ └── resources/ # Localization resources │ │ ├── __init__.py │ │ ├── en/ # English resources │ │ │ ├── messages.json # UI messages │ │ │ ├── errors.json # Error messages │ │ │ └── validation.json # Validation messages │ │ ├── de/ # German resources │ │ │ ├── messages.json │ │ │ ├── errors.json │ │ │ └── validation.json │ │ └── fr/ # French resources │ │ ├── messages.json │ │ ├── errors.json │ │ └── validation.json │ │ │ └── cli/ # Command line interface (existing main.py integration) │ ├── __init__.py │ ├── commands/ # CLI commands │ │ ├── __init__.py │ │ ├── download.py # Download commands │ │ ├── search.py # Search commands │ │ ├── rescan.py # Rescan commands │ │ └── config.py # Configuration commands │ └── utils/ # CLI utilities │ ├── __init__.py │ ├── progress.py # Progress display │ └── formatting.py # Output formatting │ ├── tests/ # Test files │ ├── __init__.py │ ├── conftest.py # Pytest configuration │ ├── fixtures/ # Test fixtures and data │ │ ├── __init__.py │ │ ├── anime_data.json # Test anime data │ │ ├── config_data.json # Test configuration │ │ ├── database_fixtures.py # Database test data │ │ └── mock_responses.json # Mock API responses │ ├── unit/ # Unit tests │ │ ├── __init__.py │ │ ├── core/ # Core layer tests │ │ │ ├── test_entities.py │ │ │ ├── test_use_cases.py │ │ │ └── test_exceptions.py │ │ ├── application/ # Application layer tests │ │ │ ├── test_services.py │ │ │ ├── test_dto.py │ │ │ └── test_validators.py │ │ ├── infrastructure/ # Infrastructure tests │ │ │ ├── test_repositories.py │ │ │ ├── test_providers.py │ │ │ └── test_file_system.py │ │ ├── web/ # Web layer tests │ │ │ ├── test_controllers.py │ │ │ ├── test_middleware.py │ │ │ └── test_api.py │ │ └── shared/ # Shared component tests │ │ ├── test_utils.py │ │ ├── test_validators.py │ │ └── test_decorators.py │ ├── integration/ # Integration tests │ │ ├── __init__.py │ │ ├── api/ # API integration tests │ │ │ ├── test_anime_api.py │ │ │ ├── test_download_api.py │ │ │ └── test_auth_api.py │ │ ├── database/ # Database integration tests │ │ │ ├── test_repositories.py │ │ │ └── test_migrations.py │ │ ├── providers/ # Provider integration tests │ │ │ ├── test_aniworld_provider.py │ │ │ └── test_provider_factory.py │ │ └── services/ # Service integration tests │ │ ├── test_download_service.py │ │ ├── test_search_service.py │ │ └── test_scheduler_service.py │ ├── e2e/ # End-to-end tests │ │ ├── __init__.py │ │ ├── web_interface/ # Web UI E2E tests │ │ │ ├── test_login_flow.py │ │ │ ├── test_search_flow.py │ │ │ ├── test_download_flow.py │ │ │ └── test_admin_flow.py │ │ ├── api/ # API E2E tests │ │ │ ├── test_full_workflow.py │ │ │ └── test_error_scenarios.py │ │ └── performance/ # Performance tests │ │ ├── test_load.py │ │ ├── test_stress.py │ │ └── test_concurrency.py │ └── utils/ # Test utilities │ ├── __init__.py │ ├── mock_server.py # Mock HTTP server │ ├── test_database.py # Test database utilities │ ├── assertions.py # Custom assertions │ └── fixtures.py # Test fixture helpers │ ├── config/ # Configuration files │ ├── production/ # Production configuration │ │ ├── config.json # Main production config │ │ ├── logging.json # Production logging config │ │ └── security.json # Security settings │ ├── development/ # Development configuration │ │ ├── config.json # Development config │ │ ├── logging.json # Development logging │ │ └── test_data.json # Test data configuration │ ├── testing/ # Testing configuration │ │ ├── config.json # Test environment config │ │ └── pytest.ini # Pytest configuration │ └── docker/ # Docker environment configs │ ├── production.env # Production environment │ ├── development.env # Development environment │ └── testing.env # Testing environment │ ├── data/ # Data storage │ ├── database/ # Database files │ │ ├── anime.db # SQLite database (development) │ │ └── backups/ # Database backups │ ├── logs/ # Application logs │ │ ├── app.log # Main application log │ │ ├── error.log # Error log │ │ ├── access.log # Access log │ │ ├── security.log # Security events │ │ └── downloads.log # Download activity log │ ├── cache/ # Cache files │ │ ├── covers/ # Cached anime covers │ │ ├── search/ # Cached search results │ │ └── metadata/ # Cached metadata │ └── temp/ # Temporary files │ ├── downloads/ # Temporary download files │ └── uploads/ # Temporary uploads │ ├── tools/ # Development tools │ ├── code_analysis/ # Code quality tools │ │ ├── run_linting.py # Linting automation │ │ ├── check_coverage.py # Coverage analysis │ │ └── security_scan.py # Security scanning │ ├── database/ # Database tools │ │ ├── backup.py # Database backup utility │ │ ├── restore.py # Database restore utility │ │ ├── migrate.py # Migration runner │ │ └── seed.py # Database seeding │ ├── monitoring/ # Monitoring tools │ │ ├── health_check.py # Health monitoring │ │ ├── performance_monitor.py # Performance tracking │ │ └── log_analyzer.py # Log analysis │ └── deployment/ # Deployment tools │ ├── build.py # Build automation │ ├── package.py # Packaging utility │ └── release.py # Release management │ ├── .env.example # Environment variables template ├── .gitignore # Git ignore rules ├── .gitattributes # Git attributes ├── .editorconfig # Editor configuration ├── .flake8 # Flake8 configuration ├── .pre-commit-config.yaml # Pre-commit hooks ├── pyproject.toml # Python project configuration ├── requirements.txt # Main dependencies ├── requirements-dev.txt # Development dependencies ├── requirements-test.txt # Testing dependencies ├── pytest.ini # Pytest configuration ├── docker-compose.yml # Docker compose configuration ├── Dockerfile # Docker image configuration ├── README.md # Project documentation ├── CHANGELOG.md # Version history ├── LICENSE # Project license ├── CONTRIBUTING.md # Contribution guidelines └── instruction.md # This file with implementation guidelines ```