XcelerateDL

XcelerateDL Architecture

This document describes the architectural design of XcelerateDL, including its components, data flow, and design principles.

System Overview

XcelerateDL is built on a modern, modular architecture designed for performance, scalability, and extensibility. The application follows a layered architecture pattern with clear separation of concerns.

Architecture Diagram

Core Components

FastAPI Backend

The FastAPI backend serves as the foundation of XcelerateDL, providing:

Key files:

Download Manager

The Download Manager is the heart of XcelerateDL, responsible for:

Key files:

WebSocket Manager

The WebSocket Manager handles real-time communication with clients:

Key files:

Data Models

The data models provide strict typing and validation:

Key files:

User Interfaces

XcelerateDL provides two user interfaces:

  1. Web UI:
    • Built with HTML, CSS, and JavaScript
    • Communicates with the backend via RESTful API and WebSockets
    • Provides full download management capabilities
  2. Desktop GUI:
    • Uses Eel to wrap the web interface in a desktop application
    • Provides a native-like experience while reusing the web UI code

Key files:

Data Flow

Download Process

  1. User submits a URL for download through UI or API
  2. API endpoint receives request and validates input
  3. Download Manager creates a new download entry with ‘queued’ status
  4. If slots are available, Download Manager starts downloading the file: a. For regular files: Uses aiohttp for asynchronous downloading b. For YouTube: Uses yt-dlp in a separate process
  5. Progress updates are sent via WebSockets to connected clients
  6. When download completes, status is updated and notifications are sent

Bandwidth Management

  1. Download Manager maintains global bandwidth settings
  2. Based on allocation mode (equal, priority, custom): a. Calculates bandwidth limits for each active download b. Applies rate limiting during download
  3. Periodically recalculates bandwidth allocation as downloads complete

Scheduling System

  1. Scheduler task runs at specified intervals
  2. Checks for downloads scheduled to start: a. For one-time schedules: Starts at specific date/time b. For recurring schedules: Checks recurrence pattern
  3. Handles peak hours throttling if configured
  4. Processes failed scheduled downloads for retry

Design Patterns

XcelerateDL implements several design patterns:

Singleton Pattern

The Download Manager is implemented as a singleton to ensure a single instance manages all downloads.

# Singleton instance
download_manager = DownloadManager()

Observer Pattern

WebSockets implement the observer pattern, with clients as observers of download state changes.

Factory Pattern

Download process selection acts as a factory pattern, creating the appropriate downloader (regular or YouTube) based on URL type.

Repository Pattern

Download state persistence implements a repository pattern for saving and loading downloads.

Asynchronous Processing

XcelerateDL heavily utilizes asyncio for non-blocking operations:

File Storage and Persistence

Downloaded files are organized by category:

downloads/
├─ compressed/
├─ programs/
├─ videos/
├─ music/
├─ pictures/
├─ documents/
├─ youtube/
└─ other/

Download state is persisted in JSON files:

Error Handling and Recovery

XcelerateDL implements robust error handling:

Scalability Considerations

While designed primarily as a desktop/single-user application, XcelerateDL’s architecture allows for potential scaling:

Future Architecture Enhancements

Potential architectural improvements include: