# fly-sem/wechatvideodownloader-pro architecture

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

- Interactive diagram: https://gitdiagram.com/fly-sem/wechatvideodownloader-pro
- Repository: https://github.com/fly-sem/wechatvideodownloader-pro

## Overview

##### Project type and purpose
- This is a cross-platform desktop application built with Electron.
- It embeds a React-based renderer (UI) and a Node.js main process that:
- Installs and manages TLS certificates
- Sets up a local HTTP(S) proxy to intercept WeChat video requests
- Executes OS-specific registry or shell scripts (Windows VBS, Mac sudo)
- Invokes OpenSSL and decryption routines to handle encrypted video streams
- The goal is to capture, preview, decrypt, and download WeChat Video Channel streams on Win/Mac.

##### File structure
- Top-level:
- electron/ – Main-process modules (cert, proxyServer, decrypt, ipc, setProxy, utils)
- src/ – Renderer (React) components and FSM logic (App.jsx, fsm.js, etc.)
- config-overrides.js & webpack.electron.js – Build-time configuration for Electron and React
- Key patterns:
- Separation of Electron main (Node context) vs. React renderer (Browser context)
- Proxy server module in main, IPC channels between main and renderer
- OS-level scripts under public/regedit-vbs and OpenSSL under public/openssl
- Deployment-related: package.json, pnpm-lock.yaml, .prettierrc, .gitignore

##### README for additional insights
- Confirms automatic certificate installation and proxy configuration
- Walks through user flow: init → play video → capture URL → preview → download
- Notes OS differences: Windows uses VBS registry scripts; Mac copies sudo commands
- Mentions encrypted-video support in V2.x

##### Detail but avoid over-fragmentation
- IPC channel explicitly
- Call out the OpenSSL binary and VBS scripts

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Renderer Process
    subgraph "Electron Renderer Process (React UI)"
        ER_Index["index.js"]:::frontend
        ER_App["App.jsx & App.less"]:::frontend
        ER_FSM["fsm.js"]:::frontend
        ER_HTML["index.html"]:::frontend
    end

    %% Main Process
    subgraph "Electron Main Process (Node)"
        EM_Entry["index.js"]:::backend
        CertMgr["Certificate Manager\n(cert.js)"]:::backend
        ProxySrv["Proxy Server\n(proxyServer.js, setProxy.js)"]:::backend
        Decrypt["Decrypt Engine\n(decrypt.js, utils.js)"]:::backend
        IPC["IPC Module\n(ipc.js, const.js)"]:::backend
    end

    %% OS Layer
    subgraph "OS Integration Layer"
        Win["Windows VBS Scripts"]:::os
        Mac["Mac Shell Commands"]:::os
    end

    %% External Services and Storage
    CDN["WeChat Video CDN"]:::external
    FS["File System\n(Downloads)"]:::external
    Keys["Keys & Certs Store\n(public/keys)"]:::db
    OpenSSL["OpenSSL Binary & Config\n(public/openssl)"]:::external

    %% Data Flows
    ER_Index -->|"initialize"| IPC
    ER_App -->|"downloadVideo"| IPC
    IPC -->|"installCert"| CertMgr
    IPC -->|"setProxy"| ProxySrv
    IPC -->|"cleanup"| CertMgr
    IPC -->|"cleanup"| ProxySrv

    CertMgr -->|"run scripts"| Win
    CertMgr -->|"run sudo commands"| Mac
    ProxySrv -->|"run setProxy"| Win
    ProxySrv -->|"run setProxy"| Mac

    ProxySrv -->|"interceptRequest"| Decrypt
    Decrypt -->|"decryptStream"| FS
    Decrypt -->|"notifyPreview"| IPC
    IPC -->|"previewData"| ER_App

    IPC -->|"fetchThroughProxy"| ProxySrv
    ProxySrv -->|"streamEncrypted"| Decrypt

    ProxySrv -->|"forwardHTTPS"| CDN
    CDN -->|"videoData"| ProxySrv

    Decrypt -->|"use Keys & OpenSSL"| Keys
    Decrypt -->|"use Keys & OpenSSL"| OpenSSL

    %% Click Events for component mapping
    click ER_Index "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/src/index.js"
    click ER_App "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/src/App.jsx"
    click ER_App "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/src/App.less"
    click ER_FSM "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/src/fsm.js"
    click ER_HTML "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/public/index.html"
    click EM_Entry "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/electron/index.js"
    click CertMgr "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/electron/cert.js"
    click ProxySrv "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/electron/proxyServer.js"
    click ProxySrv "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/electron/setProxy.js"
    click Decrypt "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/electron/decrypt.js"
    click Decrypt "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/electron/utils.js"
    click IPC "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/electron/ipc.js"
    click IPC "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/electron/const.js"
    click Win "https://github.com/fly-sem/wechatvideodownloader-pro/tree/master/public/regedit-vbs/"
    click Keys "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/public/keys/private.key"
    click Keys "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/public/keys/private.pem"
    click Keys "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/public/keys/public.crt"
    click Keys "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/public/keys/public.pem"
    click OpenSSL "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/public/openssl/openssl.exe"
    click OpenSSL "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/public/openssl/openssl.cnf"
    click OpenSSL "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/public/openssl/HashInfo.txt"
    click OpenSSL "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/public/openssl/ReadMe.txt"
    click OpenSSL "https://github.com/fly-sem/wechatvideodownloader-pro/blob/master/public/openssl/OpenSSL License.txt"

    %% Styles
    classDef frontend fill:#BBEFFF,stroke:#333,stroke-width:1px
    classDef backend fill:#AED5B5,stroke:#333,stroke-width:1px
    classDef os fill:#FDE68A,stroke:#333,stroke-width:1px
    classDef external fill:#CCCCCC,stroke:#333,stroke-width:1px
    classDef db fill:#FFF59D,stroke:#333,stroke-width:1px
```
