# senhan07/v2ph architecture

> Architecture diagram of the GitHub repository senhan07/v2ph, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/senhan07/v2ph
- Repository: https://github.com/senhan07/v2ph

## Overview

##### Project type and purpose
- This is a CLI-driven, open-source Python “scraping” tool whose sole purpose is to log in to V2PH, iterate through model albums, pull out image URLs, and download the images.
- The README confirms it’s not a web service or full-stack app but a standalone script with these capabilities:
- Album URL scraping by model name
- Image URL extraction per album
- Image downloading via aria2c
- Account token management, headless Selenium automation, proxy support stub

##### File structure
Top-level:
- main.py – the entry-point CLI orchestrator
- requirements.txt – dependency list (Selenium, requests, etc.)
- accounts/ – JSON files representing login credentials & token state
- albums_url/ – output folder for scraped album URLs
module/ package:
- driver.py – Selenium WebDriver wrapper (Chrome headless toggles)
- proxy.py – stub for proxy support
- login.py, create_accounts.py, history.py – account lifecycle & token reset
- scrape_album.py – fetches album page URLs by model name
- get_image.py – visits album pages to extract image URLs
- download_image.py – invokes aria2c or HTTP download logic
- user.py – parses CLI arguments and routes commands

##### Extract architecture hints from the README
- Token-bucket style account rotation: track “last login” and “tokens left” in JSON
- Sequential pipeline: album → image URL → download
- External dependencies: V2PH website, ChromeDriver, aria2c utility

##### Detail is critical
- Module separately rather than lumping them together
- File storage locations and formats
- Retry/account-rotation loops in the Account Manager

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Subgraphs and modules
    subgraph "CLI Layer"
        direction TB
        User["User / CLI Interface"]:::internal
        CLI["CLI Argument Parser & Command Router"]:::internal
        Orchestrator["Orchestrator / Controller Logic"]:::internal
    end

    subgraph "Account Manager Module"
        direction TB
        CreateAcc["Account Creation"]:::internal
        LoginMod["Login & Token Management"]:::internal
        HistoryMod["Account History (token usage)"]:::internal
        ProxyStub["Proxy Support Stub"]:::internal
    end

    subgraph "Scraper Module A"
        direction TB
        ScrapeAlbum["Scrape Album URLs"]:::internal
        DriverA["Selenium WebDriver Wrapper"]:::internal
    end

    subgraph "Scraper Module B"
        direction TB
        GetImage["Extract Image URLs"]:::internal
        DriverB["Selenium WebDriver Wrapper"]:::internal
    end

    subgraph "Downloader Module"
        direction TB
        DownloadImg["Image Download Logic"]:::internal
    end

    ConsoleColors["Console Output Styling"]:::internal

    %% Data stores
    AccountsStore["Accounts JSON Store"]:::data
    AlbumsStore["Album URLs Output"]:::data
    ImagesStore["Images Directory"]:::data

    %% External services
    V2PH["V2PH Website"]:::external
    Aria2c["aria2c External Tool"]:::external

    %% Connections
    User -->|"invokes CLI"| CLI
    CLI -->|"routes commands"| Orchestrator
    Orchestrator -->|"request session/token"| CreateAcc
    Orchestrator --> CreateAcc
    Orchestrator --> LoginMod
    Orchestrator --> HistoryMod
    Orchestrator --> ProxyStub

    CreateAcc -->|"reads/writes JSON"| AccountsStore
    LoginMod --> AccountsStore
    HistoryMod --> AccountsStore
    ProxyStub --> AccountsStore

    Orchestrator -->|"start album scrape"| ScrapeAlbum
    ScrapeAlbum --> DriverA
    DriverA -->|"HTTP GET"| V2PH
    V2PH -->|"album URLs"| ScrapeAlbum
    ScrapeAlbum -->|"write URLs"| AlbumsStore

    Orchestrator -->|"start image extract"| GetImage
    GetImage --> DriverB
    DriverB -->|"HTTP GET"| V2PH
    V2PH -->|"image URLs"| GetImage
    GetImage -->|"write URLs"| AlbumsStore

    Orchestrator -->|"start download"| DownloadImg
    DownloadImg --> Aria2c
    Aria2c -->|"downloads images"| ImagesStore

    Orchestrator --> ConsoleColors
    CLI --> ConsoleColors

    %% Click Events
    click User "https://github.com/senhan07/v2ph/blob/main/main.py"
    click CLI "https://github.com/senhan07/v2ph/blob/main/module/user.py"
    click Orchestrator "https://github.com/senhan07/v2ph/blob/main/main.py"
    click CreateAcc "https://github.com/senhan07/v2ph/blob/main/module/create_accounts.py"
    click LoginMod "https://github.com/senhan07/v2ph/blob/main/module/login.py"
    click HistoryMod "https://github.com/senhan07/v2ph/blob/main/module/history.py"
    click ProxyStub "https://github.com/senhan07/v2ph/blob/main/module/proxy.py"
    click ScrapeAlbum "https://github.com/senhan07/v2ph/blob/main/module/scrape_album.py"
    click DriverA "https://github.com/senhan07/v2ph/blob/main/module/driver.py"
    click GetImage "https://github.com/senhan07/v2ph/blob/main/module/get_image.py"
    click DriverB "https://github.com/senhan07/v2ph/blob/main/module/driver.py"
    click DownloadImg "https://github.com/senhan07/v2ph/blob/main/module/download_image.py"
    click ConsoleColors "https://github.com/senhan07/v2ph/blob/main/module/colors.py"
    click AccountsStore "https://github.com/senhan07/v2ph/tree/main/accounts/"
    click AlbumsStore "https://github.com/senhan07/v2ph/tree/main/albums_url/"
    click Aria2c "https://github.com/senhan07/v2ph/blob/main/requirements.txt"
    click V2PH "https://github.com/senhan07/v2ph/blob/main/README.md"

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef data fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
```
