# codewithcrescent/yt-downloader-web architecture

> Architecture diagram of the GitHub repository codewithcrescent/yt-downloader-web, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codewithcrescent/yt-downloader-web
- Repository: https://github.com/codewithcrescent/yt-downloader-web

## Overview

This Django application turns supported social-media URLs into downloadable media: a visitor submits a URL, asynchronous work extracts metadata and format choices, the visitor selects a format, and a second task downloads and packages the file for token-based delivery. The repository also tracks visits and supports share links; expired delivery files are purged on a schedule. The graph reflects the sampled views and task code; routes and several subsystems are represented only at the directory level where their implementation was not sampled.

Main entry points: [`downloader/views.py`](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/views.py) (HTTP views), [`downloader/models.py`](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/models.py) (Download records), [`downloader/tasks.py`](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/tasks.py) (Download task), [`downloader/media_downloader.py`](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/media_downloader.py) (Media extractor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_views["HTTP views<br/>[views.py]"]
  node_routes["URL routes<br/>[urls.py]"]
  node_pages["Web pages"]
end

subgraph group_processing["Media processing"]
  node_info_task["Metadata task<br/>[tasks.py]"]
  node_download_task["Download task<br/>[tasks.py]"]
  node_media_downloader["Media extractor"]
  node_broker["Celery broker"]
end

subgraph group_state["State and delivery"]
  node_models[("Download records<br/>[models.py]")]
  node_delivery["Delivery and purge<br/>[delivery.py]"]
  node_media_files[("Temporary media files")]
  node_database[("Application database")]
end

subgraph group_operations["Tracking and cleanup"]
  node_visit_tracking["Visit tracking<br/>[middleware.py]"]
  node_share_links["Share links<br/>[views.py]"]
end

node_visitor(("Visitor"))
node_platforms(("Media platforms"))
node_redis[("Redis")]

node_visitor -->|"requests"| node_routes
node_routes -->|"dispatches"| node_views
node_views -->|"renders"| node_pages
node_views -->|"dispatches metadata"| node_info_task
node_info_task -->|"extracts metadata"| node_media_downloader
node_media_downloader -->|"fetches media info"| node_platforms
node_info_task -->|"saves metadata"| node_models
node_views -->|"checks task status"| node_broker
node_info_task -->|"returns result"| node_broker
node_views -->|"dispatches download"| node_download_task
node_download_task -->|"downloads media"| node_media_downloader
node_media_downloader -->|"downloads media"| node_platforms
node_download_task -->|"writes packaged file"| node_media_files
node_download_task -->|"updates delivery state"| node_models
node_views -->|"checks download status"| node_broker
node_views -->|"reads delivery record"| node_models
node_views -->|"streams file"| node_media_files
node_views -->|"creates share link"| node_share_links
node_share_links -->|"stores share link"| node_database
node_models -->|"reads and writes"| node_database
node_visit_tracking -->|"records visits"| node_models
node_views -->|"enqueues tasks"| node_redis
node_broker -->|"uses broker"| node_redis
node_download_task -->|"purges expired files"| node_delivery
node_delivery -->|"clears expired records"| node_models
node_delivery -->|"deletes expired files"| node_media_files

click node_views "https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/views.py"
click node_routes "https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/urls.py"
click node_pages "https://github.com/codewithcrescent/yt-downloader-web/tree/main/templates/downloader"
click node_info_task "https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/tasks.py"
click node_download_task "https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/tasks.py"
click node_media_downloader "https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/media_downloader.py"
click node_models "https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/models.py"
click node_delivery "https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/delivery.py"
click node_visit_tracking "https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/middleware.py"
click node_share_links "https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/views.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_views,node_routes,node_pages toneBlue
class node_info_task,node_download_task,node_media_downloader,node_broker,node_redis toneAmber
class node_models,node_delivery,node_media_files,node_database toneMint
class node_visit_tracking,node_share_links toneRose
class node_visitor,node_platforms toneIndigo
```

## Components

### Web experience

- [HTTP views](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/views.py): `downloader/views.py`
- [URL routes](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/urls.py): `downloader/urls.py`
- [Web pages](https://github.com/codewithcrescent/yt-downloader-web/tree/main/templates/downloader): `templates/downloader`

### Media processing

- [Metadata task](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/tasks.py): `downloader/tasks.py`
- [Download task](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/tasks.py): `downloader/tasks.py`
- [Media extractor](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/media_downloader.py): `downloader/media_downloader.py`
- **Celery broker**

### State and delivery

- [Download records](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/models.py): `downloader/models.py`
- [Delivery and purge](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/delivery.py): `downloader/delivery.py`
- **Temporary media files**
- **Application database**

### Tracking and cleanup

- [Visit tracking](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/middleware.py): `downloader/middleware.py`
- [Share links](https://github.com/codewithcrescent/yt-downloader-web/blob/main/downloader/views.py): `downloader/views.py`

### Other components

- **Visitor**
- **Media platforms**
- **Redis**

## Connections

- Visitor → URL routes: requests
- URL routes → HTTP views: dispatches
- HTTP views → Web pages: renders
- HTTP views → Metadata task: dispatches metadata
- Metadata task → Media extractor: extracts metadata
- Media extractor → Media platforms: fetches media info
- Metadata task → Download records: saves metadata
- HTTP views → Celery broker: checks task status
- Metadata task → Celery broker: returns result
- HTTP views → Download task: dispatches download
- Download task → Media extractor: downloads media
- Media extractor → Media platforms: downloads media
- Download task → Temporary media files: writes packaged file
- Download task → Download records: updates delivery state
- HTTP views → Celery broker: checks download status
- HTTP views → Download records: reads delivery record
- HTTP views → Temporary media files: streams file
- HTTP views → Share links: creates share link
- Share links → Application database: stores share link
- Download records → Application database: reads and writes
- Visit tracking → Download records: records visits
- HTTP views → Redis: enqueues tasks
- Celery broker → Redis: uses broker
- Download task → Delivery and purge: purges expired files
- Delivery and purge → Download records: clears expired records
- Delivery and purge → Temporary media files: deletes expired files
