# wujunwei928/parse-video architecture

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

- Interactive diagram: https://gitdiagram.com/wujunwei928/parse-video
- Repository: https://github.com/wujunwei928/parse-video

## Overview

##### Main Components
- API Web Server: At the heart of the project is the API server built with Gin (see main.go). This component handles incoming HTTP requests, routes them to the appropriate handler, and serves both JSON responses (for API calls) as well as rendered HTML pages (using the templates provided in the “templates” folder).
- Utility Functions: The “utils” package provides helper functions that support both the API server and parsing logic. It should be depicted as a reusable component used by other parts of the system.
- Docker Container: The project includes a Dockerfile and GitHub workflows for building and deploying Docker images. Represent the Docker container as the hosting environment for the application.

##### Relationships and Interactions
- Incoming requests (from a browser or API client) hit the API Web Server.
- Depending on the endpoint, the server will:
- Render a front-end page (using templates from “templates/index.tmpl”)
- Invoke specific functions in the Parser Module to process video share URLs or video IDs.
- The Parser Module communicates with external video platforms (using resty for HTTP requests) and parses responses (using gjson and goquery) to extract video links, author information, and other metadata.
- The Utility functions can be invoked by both the server and parser for shared tasks.
- The final processed data is returned as a JSON response or rendered to the front-end.
- The entire application is containerized using Docker, which ensures a consistent runtime environment.

##### Architectural Patterns and Design Principles
- Layered/MVC-like Structure: Although not strictly MVC, the clear separation between the API (controller layer), the parser logic (model/business logic), and the template-driven view shows a modular architecture.
- Extensibility: The parser package's structure (with a dedicated file for each platform) allows easy extension to support additional platforms.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client (HTTP Request)"]:::client

    subgraph "Golang Video De-Watermark Service"
        API["API Server (Gin)"]:::api
        Templates["Templates (HTML)"]:::template
        Util["Utility Functions"]:::util

        subgraph "Parser Modules"
            Douyin["Parser – Douyin"]:::parser
            Acfun["Parser – Acfun"]:::parser
            Kuaishou["Parser – Kuaishou"]:::parser
        end
    end

    ExtGin["Gin Library"]:::ext
    ExtResty["Resty Library"]:::ext
    ExtGjson["GJSON Library"]:::ext
    ExtGoquery["GoQuery Library"]:::ext
    Docker["Docker Container"]:::docker
    DockerWF["Docker Workflow"]:::docker

    Client -->|"SendsRequest"| API
    API -->|"Renders"| Templates
    API -->|"CallsParser"| Douyin
    API -->|"CallsParser"| Acfun
    API -->|"CallsParser"| Kuaishou
    API -->|"Uses"| Util
    Douyin -->|"CallsUtil"| Util
    Acfun -->|"CallsUtil"| Util
    Kuaishou -->|"CallsUtil"| Util
    API -->|"Uses"| ExtGin
    Douyin -->|"HTTPParse"| ExtResty
    Douyin -->|"HTTPParse"| ExtGjson
    Douyin -->|"HTTPParse"| ExtGoquery
    Acfun -->|"HTTPParse"| ExtResty
    Acfun -->|"HTTPParse"| ExtGjson
    Acfun -->|"HTTPParse"| ExtGoquery
    Kuaishou -->|"HTTPParse"| ExtResty
    Kuaishou -->|"HTTPParse"| ExtGjson
    Kuaishou -->|"HTTPParse"| ExtGoquery
    API -->|"DeployedOn"| Docker
    API -->|"CI/CD"| DockerWF

    click API "https://github.com/wujunwei928/parse-video/blob/main/main.go"
    click Templates "https://github.com/wujunwei928/parse-video/blob/main/templates/index.tmpl"
    click Douyin "https://github.com/wujunwei928/parse-video/blob/main/parser/douyin.go"
    click Acfun "https://github.com/wujunwei928/parse-video/blob/main/parser/acfun.go"
    click Kuaishou "https://github.com/wujunwei928/parse-video/blob/main/parser/kuaishou.go"
    click Util "https://github.com/wujunwei928/parse-video/blob/main/utils/utils.go"
    click Docker "https://github.com/wujunwei928/parse-video/tree/main/Dockerfile"
    click DockerWF "https://github.com/wujunwei928/parse-video/blob/main/.github/workflows/docker.yml"
    click ExtGin "https://github.com/wujunwei928/parse-video/blob/main/go.mod"
    click ExtResty "https://github.com/wujunwei928/parse-video/blob/main/go.mod"
    click ExtGjson "https://github.com/wujunwei928/parse-video/blob/main/go.mod"
    click ExtGoquery "https://github.com/wujunwei928/parse-video/blob/main/go.mod"

    classDef client fill:#ffdead,stroke:#000,stroke-width:2px;
    classDef api fill:#87cefa,stroke:#000,stroke-width:2px;
    classDef template fill:#f0e68c,stroke:#000,stroke-width:2px;
    classDef util fill:#daa520,stroke:#000,stroke-width:2px;
    classDef parser fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef ext fill:#ffc0cb,stroke:#000,stroke-width:2px;
    classDef docker fill:#ffa500,stroke:#000,stroke-width:2px;
```
