# nladuo/captcha-break architecture

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

- Interactive diagram: https://gitdiagram.com/nladuo/captcha-break
- Repository: https://github.com/nladuo/captcha-break

## Overview

##### Project type and purpose
- This is an open-source CAPTCHA-breaking toolkit (“captcha-break”) that provides end-to-end pipelines—implemented in both C++ and Python—for downloading, preprocessing (splitting), recognizing, and (in some cases) training models on CAPTCHAs from multiple sources (basic, CSDN, SubMail, Weibo.cn, JiKeXueYuan, Weibo.com).
- It uses OpenCV for image processing, Tesseract (or a custom tiny-cnn library) for OCR, and includes data-generation/training modules for model refinement.

##### File structure
- Top level: LICENSE, README.md, and six source modules: basic, csdn, submail, weibo.cn, jikexueyuan, weibo.com
- Each module (e.g. csdn) is subdivided by language:
- cpp/… with CMakeLists.txt, downloader, spliter, recognizer subfolders
- python/… with downloader, spliter, recognizer scripts + requirements.txt
- The “weibo.cn” and “weibo.com” modules also include a trainer subfolder, complete with tiny-cnn code (in cpp) or Python training scripts.
- Config/build artifacts: CMakeLists.txt, requirements.txt, .gitignore files, data archives (dataset.zip, tests.zip) and weight files.

##### README for additional insights
- Lists each supported CAPTCHA source, with screenshots.
- Emphasizes a uniform three-stage pipeline (download → split → recognize) plus optional training.

##### Detail
- Six source modules as separate “pipelines” or group them under a “multi‐source” umbrella, each following the same internal flow
- Where datasets (e.g., dataset.zip, tests.zip, captchas_backup.zip) and model-weights reside
- Build/deploy elements: CMake for C++, requirements.txt for Python

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Common Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px;
    classDef cpp fill:#bbf,stroke:#333,stroke-width:1px;
    classDef python fill:#bfb,stroke:#333,stroke-width:1px;
    classDef data fill:#ffebcc,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;

    %% Basic Module
    subgraph "Basic Module"
        direction TB
        B_Ext["External CAPTCHA Source"]:::external
        B_DL_cpp["Downloader (C++)"]:::cpp
        B_Split_cpp["Spliter (C++)"]:::cpp
        B_Rec_cpp["Recognizer (C++)"]:::cpp
        B_DL_py["Downloader (Python)"]:::python
        B_Rec_py["Recognizer (Python)"]:::python

        B_Ext --> B_DL_cpp --> B_Split_cpp --> B_Rec_cpp
        B_Ext --> B_DL_py --> B_Rec_py

        click B_DL_cpp "https://github.com/nladuo/captcha-break/blob/master/basic/cpp/main.cpp"
        click B_Rec_cpp "https://github.com/nladuo/captcha-break/blob/master/basic/cpp/ocr_decoder.cpp"
        click B_Rec_cpp "https://github.com/nladuo/captcha-break/blob/master/basic/cpp/ocr_decoder.h"
        click B_Rec_py "https://github.com/nladuo/captcha-break/blob/master/basic/python/recognize.py"
    end

    %% CSDN Module
    subgraph "CSDN Module"
        direction TB
        C_Ext["External CAPTCHA Source"]:::external
        C_DL_cpp["Downloader (C++)"]:::cpp
        C_Split_cpp["Spliter (C++)"]:::cpp
        C_Rec_cpp["Recognizer (C++)"]:::cpp
        C_DL_py["Downloader (Python)"]:::python
        C_Split_py["Spliter (Python)"]:::python
        C_Rec_py["Recognizer (Python)"]:::python

        C_Ext --> C_DL_cpp --> C_Split_cpp --> C_Rec_cpp
        C_Ext --> C_DL_py --> C_Split_py --> C_Rec_py

        click C_DL_cpp "https://github.com/nladuo/captcha-break/blob/master/csdn/cpp/downloader/downloader.py"
        click C_Split_cpp "https://github.com/nladuo/captcha-break/blob/master/csdn/cpp/spliter/main.cpp"
        click C_Rec_cpp "https://github.com/nladuo/captcha-break/blob/master/csdn/cpp/recognizer/main.cpp"
        click C_DL_py "https://github.com/nladuo/captcha-break/blob/master/csdn/python/downloader/downloader.py"
        click C_Split_py "https://github.com/nladuo/captcha-break/blob/master/csdn/python/spliter/spliter.py"
        click C_Rec_py "https://github.com/nladuo/captcha-break/blob/master/csdn/python/recognizer/recognizer.py"
    end

    %% SubMail Module
    subgraph "SubMail Module"
        direction TB
        S_Ext["External CAPTCHA Source"]:::external
        S_DL_cpp["Downloader (C++)"]:::cpp
        S_Split_cpp["Spliter (C++)"]:::cpp
        S_Rec_cpp["Recognizer (C++)"]:::cpp

        S_Ext --> S_DL_cpp --> S_Split_cpp --> S_Rec_cpp

        click S_DL_cpp "https://github.com/nladuo/captcha-break/blob/master/submail/cpp/downloader/downloader.py"
        click S_Split_cpp "https://github.com/nladuo/captcha-break/blob/master/submail/cpp/spliter/main.cpp"
        click S_Rec_cpp "https://github.com/nladuo/captcha-break/blob/master/submail/cpp/recognizer/main.cpp"
    end

    %% JiKeXueYuan Module
    subgraph "JiKeXueYuan Module"
        direction TB
        J_Ext["External CAPTCHA Source"]:::external
        J_DL_py["Downloader (Python)"]:::python
        J_Split_py["Spliter (Python)"]:::python
        J_Rec_py["Recognizer (Python)"]:::python
        J_Trainer["Trainer (Python)"]:::python
        J_DataGen["DataGen"]:::python
        J_Model["Model Definition"]:::python
        J_Test["Trainer Test"]:::python

        J_Ext --> J_DL_py --> J_Split_py --> J_Rec_py
        J_Split_py --> J_Trainer
        J_Trainer --> J_Model
        J_Trainer --> J_DataGen
        J_Trainer --> J_Test

        click J_DL_py "https://github.com/nladuo/captcha-break/blob/master/jikexueyuan/python/downloader/downloader.py"
        click J_Trainer "https://github.com/nladuo/captcha-break/blob/master/jikexueyuan/python/trainer/train.py"
        click J_DataGen "https://github.com/nladuo/captcha-break/blob/master/jikexueyuan/python/trainer/gen/gen_captcha.py"
        click J_DataGen "https://github.com/nladuo/captcha-break/blob/master/jikexueyuan/python/trainer/gen/img_process.py"
        click J_DataGen "https://github.com/nladuo/captcha-break/blob/master/jikexueyuan/python/trainer/gen/utils.py"
        click J_Model "https://github.com/nladuo/captcha-break/blob/master/jikexueyuan/python/trainer/model/nn.py"
        click J_Model "https://github.com/nladuo/captcha-break/blob/master/jikexueyuan/python/trainer/model/common.py"
        click J_Test "https://github.com/nladuo/captcha-break/blob/master/jikexueyuan/python/trainer/test_model.py"
    end

    %% Weibo.cn Module
    subgraph "Weibo.cn Module"
        direction TB
        Wc_Ext["External CAPTCHA Source"]:::external
        Wc_DL_cpp["Downloader (C++)"]:::cpp
        Wc_Split_cpp["Spliter (C++)"]:::cpp
        Wc_Rec_cpp["Recognizer (C++)"]:::cpp
        Wc_Trainer_cpp["Trainer (C++)"]:::cpp
        Wc_DL_py["Downloader (Python)"]:::python
        Wc_Split_py["Spliter (Python)"]:::python
        Wc_Rec_py["Recognizer (Python)"]:::python
        Wc_Trainer_py["Trainer (Python)"]:::python

        Wc_Ext --> Wc_DL_cpp --> Wc_Split_cpp --> Wc_Rec_cpp
        Wc_Ext --> Wc_DL_py --> Wc_Split_py --> Wc_Rec_py
        Wc_Rec_cpp --> Wc_Trainer_cpp
        Wc_Rec_py --> Wc_Trainer_py

        click Wc_DL_cpp "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/cpp/downloader/downloader.py"
        click Wc_DL_cpp "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/cpp/downloader/clean.py"
        click Wc_Split_cpp "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/cpp/spliter/main.cpp"
        click Wc_Rec_cpp "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/cpp/recognizer/main.cpp"
        click Wc_Trainer_cpp "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/cpp/trainer/main.cpp"
        click Wc_DL_py "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/python/downloader/downloader.py"
        click Wc_DL_py "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/python/downloader/clean.py"
        click Wc_Split_py "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/python/spliter/spliter.py"
        click Wc_Split_py "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/python/spliter/captcha_utils.py"
        click Wc_Rec_py "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/python/recognizer/recognize.py"
        click Wc_Rec_py "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/python/recognizer/_recognize_p.py"
        click Wc_Trainer_py "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/python/trainer/train.py"
        click Wc_Trainer_py "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/python/trainer/check_dataset.py"
        click Wc_Trainer_py "https://github.com/nladuo/captcha-break/blob/master/weibo.cn/python/trainer/format_dataset.py"
    end

    %% Weibo.com Module
    subgraph "Weibo.com Module"
        direction TB
        Wm_Ext["External CAPTCHA Source"]:::external
        Wm_DataArchive["Dataset Archive"]:::data
        Wm_Dataset["Dataset Directory"]:::data
        Wm_Notebook["Processing Notebook"]:::data
        Wm_Helper["Yundama Helper"]:::python

        Wm_Ext --> Wm_DataArchive --> Wm_Dataset
        Wm_Dataset --> Wm_Notebook
        Wm_Dataset --> Wm_Helper

        click Wm_DataArchive "https://github.com/nladuo/captcha-break/blob/master/weibo.com/dataset.zip"
        click Wm_Dataset "https://github.com/nladuo/captcha-break/tree/master/weibo.com/dataset/"
        click Wm_Notebook "https://github.com/nladuo/captcha-break/blob/master/weibo.com/weibo.com-process.ipynb"
        click Wm_Helper "https://github.com/nladuo/captcha-break/blob/master/weibo.com/yundama/create_dataset.py"
    end

    %% Common Layer
    subgraph "Common Utilities & Config"
        direction TB
        Common_Opencv["OpenCV"]:::external
        Common_Tesseract["Tesseract/tiny-cnn"]:::external
        Common_CMake["CMakeLists.txt"]:::external
        Common_Req["requirements.txt"]:::external
        Common_Ignore[".gitignore"]:::external
        Common_Backup["captchas_backup.zip"]:::data
        Common_Tests["tests.zip"]:::data
        Common_Weights["weibo.cn-nn-weights"]:::data

        Common_Opencv & Common_Tesseract --> Common_CMake
        Common_Req --> Common_Ignore
        Common_Backup & Common_Tests & Common_Weights --> Common_Opencv
    end
```
