# epctex-support/dailymotion-video-downloader architecture

> Architecture diagram of the GitHub repository epctex-support/dailymotion-video-downloader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/epctex-support/dailymotion-video-downloader
- Repository: https://github.com/epctex-support/dailymotion-video-downloader

## Overview

##### Project type and purpose
- This is an Apify “actor” (serverless scraping job) whose sole purpose is to download videos from Dailymotion by navigating to user-provided URLs, scraping the video URLs, and storing results in an Apify dataset.

##### (minimal) file structure
- We only have a README.md, which tells us that the project:
- Accepts a JSON input with startUrls, quality, proxy config, and optional mapping functions
- Uses residential proxies (Apify Proxy or custom)
- Runs inside the Apify platform using the Apify SDK
- Outputs each video’s source URL + download URL into an Apify dataset

##### README for additional insights
- The actor:
- Launches with Apify.run() or equivalent
- For each URL in startUrls: opens the page via proxy, waits for video elements
- Optionally applies user-supplied extendOutputFunction/customMapFunction
- Saves each result item into an Apify dataset
- The Apify dataset is persisted via Apify API (Key-Value Store / Dataset)

a. Main components
- User (CLI / HTTP API / Web console)
- Apify Platform Runtime
- Actor code (implements crawler + parser)
- Proxy layer (Apify Proxy or custom residential proxies)
- Dailymotion.com (external website)
- Data storage: Apify Dataset / Key-Value Store
- Apify API (for fetching results)

b. Relationships and interactions
1. User submits JSON input → Apify Platform
2. Apify Platform spins up actor
3. Actor code calls HTTP client through Proxy layer → Dailymotion.com
4. Dailymotion returns HTML/video stream
5. Actor parser/DOM routines extract downloadUrl & metadata
6. Actor pushes items into Apify Dataset (via Apify API)
7. After completion, User fetches results via Apify API or Web UI

c. Architectural patterns & design principles
- Pipeline / Stream processing: Input → Fetch → Parse → Store
- Separation of concerns:
- Input handling
- Network requests (through proxies)
- Extraction logic (extendOutputFunction)
- Output persistence
- Serverless / Function-as-a-Service: actor code is event-driven

d. Key technologies / frameworks
- Node.js & Apify SDK
- Residential proxy servers (Apify Proxy)
- Cheerio / Puppeteer (implicit for HTML parsing)
- Apify Dataset & Key-Value Store (persistence)
- Apify REST API

##### Essential details to capture
- Input schema (startUrls, quality, proxy config, plugins)
- Proxy requirement (residential)
- Extraction pipeline stages
- Storage in Apify dataset
- Retrieval via Apify API

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Components
    User["User (CLI/HTTP/Web)"]:::external
    Documentation["Project Documentation"]:::external
    ApifyRuntime["Apify Platform Runtime"]:::compute

    subgraph "Actor Code" 
        direction TB
        Crawler["Crawler & Parser"]:::compute
        Extend["extendOutputFunction (optional)"]:::compute
        Map["customMapFunction (optional)"]:::compute
    end

    Proxy["Apify Proxy / Custom Residential Proxy"]:::network
    Dailymotion["Dailymotion.com"]:::network
    ApifyAPI["Apify REST API"]:::external
    Dataset["Apify Dataset / Key-Value Store"]:::storage

    %% Data Flow
    User -->|"submit JSON input"| ApifyRuntime
    ApifyRuntime -->|"invoke actor"| Crawler
    Crawler -->|"fetch HTML/video"| Proxy
    Proxy -->|"relay request"| Dailymotion
    Dailymotion -->|"return HTML/video"| Proxy
    Proxy -->|"response"| Crawler
    Crawler -->|"push items"| ApifyAPI
    ApifyAPI -->|"persist items"| Dataset
    User -->|"fetch results"| ApifyAPI

    %% Plugin Calls
    Crawler -->|“invoke extendOutputFunction”| Extend
    Crawler -->|“invoke customMapFunction”| Map

    %% Click Events
    click Documentation "https://github.com/epctex-support/dailymotion-video-downloader/blob/main/README.md"

    %% Styles
    classDef compute fill:#AEDDF0,stroke:#333,stroke-width:1px
    classDef network fill:#C3F0C1,stroke:#333,stroke-width:1px
    classDef storage fill:#FFD59E,stroke:#333,stroke-width:1px
    classDef external fill:#F5F5F5,stroke:#333,stroke-width:1px
```
