This guide is intended for developers who want to understand, modify, or contribute to the XcelerateDL codebase.
git clone https://github.com/yourusername/XcelerateDL.git
cd XcelerateDL
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
pip install -e .
pip install pytest pytest-asyncio flake8 black isort mypy
# Start with auto-reload for API development
python -m app.main --api-only --host 127.0.0.1 --port 8000
# Start GUI mode
python -m app.main --gui
XcelerateDL/
├─ app/ # Main application code
│ ├─ api/ # API endpoints
│ │ └─ downloads.py # Download-related endpoints
│ ├─ models/ # Data models
│ │ ├─ __init__.py
│ │ └─ download.py # Download and related models
│ ├─ services/ # Business logic
│ │ ├─ downloader.py # Download manager service
│ │ └─ ws_manager.py # WebSocket manager
│ ├─ static/ # Static assets for web UI
│ │ ├─ css/ # CSS styles
│ │ │ └─ style.css
│ │ ├─ js/ # JavaScript code
│ │ │ └─ script.js
│ │ └─ images/ # UI images
│ ├─ templates/ # HTML templates
│ │ └─ index.html # Main UI template
│ ├─ gui.py # GUI implementation
│ ├─ main.py # Application entry point
├─ docs/ # Documentation
├─ downloads/ # Default download directory
├─ tests/ # Test files
├─ pyproject.toml # Project metadata and dependencies
├─ README.md # Project overview
app/main.py)The application entry point handles:
app/api/downloads.py)The API layer defines endpoints for:
app/services/downloader.py)The core component responsible for:
app/services/ws_manager.py)Handles real-time communication:
app/models/download.py)Defines Pydantic models for:
app/templates/index.html, app/static/js/script.js)The web interface provides:
app/gui.py)Integrates the web UI into a desktop application using Eel.
git checkout -b feature/your-feature-name
black app/
isort app/
flake8 app/
mypy app/
git add .
git commit -m "Add feature: your feature description"
The download engine is the most complex part of XcelerateDL. When modifying it:
_download_file and _download_youtube methodsWhen adding new API endpoints:
Example:
@router.post("/new-endpoint", response_model=MyResponseModel)
async def my_new_endpoint(request: MyRequestModel):
"""
Description of what this endpoint does.
Additional details about parameters, behavior, etc.
"""
# Implementation
return {"result": "success"}
Write unit tests for individual components:
# Example test for a downloader method
import pytest
from app.services.downloader import download_manager
@pytest.mark.asyncio
async def test_get_file_info():
# Setup
url = "https://example.com/test.zip"
# Execute
filename, size = await download_manager.get_file_info(url)
# Assert
assert filename == "test.zip"
assert isinstance(size, int)
Test interactions between components:
@pytest.mark.asyncio
async def test_add_and_pause_download():
# Setup
request = CreateDownloadRequest(url="https://example.com/test.zip")
# Execute
download = await download_manager.add_download(request)
await download_manager.pause_download(download.id)
# Assert
assert download_manager.get_download(download.id).status == DownloadStatus.PAUSED
# Run all tests
pytest
# Run specific test file
pytest tests/test_downloader.py
# Run tests with coverage report
pytest --cov=app tests/
Enable debug logging for more detailed information:
import logging
logging.basicConfig(level=logging.DEBUG)
Use these techniques for debugging async code:
print(f"{time.time()}: Starting download")
import asyncio
asyncio.get_event_loop().set_debug(True)
task = asyncio.create_task(some_function())
# Later
print(f"Task done: {task.done()}, cancelled: {task.cancelled()}")
Tips for optimizing bandwidth usage:
Tips for managing memory usage:
pyproject.toml