# 2captcha/puppeteer-recaptcha-solver-using-clicks architecture

> Architecture diagram of the GitHub repository 2captcha/puppeteer-recaptcha-solver-using-clicks, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/2captcha/puppeteer-recaptcha-solver-using-clicks
- Repository: https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks

## Overview

#### Purpose and Entry Point
A Node.js demonstration automates reCAPTCHA v2 image-grid challenges through Puppeteer and the 2Captcha Grid API. `index.js` is the execution entry point; `captchaSolver.js` coordinates browser interaction, extraction, external solving, and click replay.

#### Browser Automation Boundary
Puppeteer drives a live target page and interacts with reCAPTCHA’s nested widget/challenge frames. Frame discovery and challenge-state checks isolate the fragile browser/third-party DOM boundary:
- `utils/isFoundReCaptchaBadge.js`
- `utils/isFoundRecaptchaChallengeFrame.js`
- `utils/isRecaptchaPassed.js`

#### Challenge Extraction Stage
Once a challenge frame is available, an in-page extractor obtains grid dimensions, task instruction, and image payload suitable for 2Captcha’s GridTask request. Extraction is initialized/injected separately from parameter collection:
- `utils/initCaptchaParamsExtractor.js`
- `utils/getCaptchaParams.js`
- `captchaSolver.js`

#### External Solver Integration
The extracted challenge is submitted to 2Captcha using the API key supplied via `APIKEY` (or code fallback). The solver result encodes selected grid cells, e.g. `click:3/6/8`; this is the principal external-service boundary and can return unsolvable/error outcomes.
- `captchaSolver.js`
- `package.json`

#### Solution Translation and Click Replay
Solver cell numbers are translated into grid coordinates based on extracted row/column dimensions. Puppeteer then performs coordinate-based clicks in the challenge frame, with randomized offsets/timing intended to resemble user interaction:
- `utils/clickAtCoordinates.js`
- `utils/getRandomNumber.js`
- `utils/showClickInfo.js`

#### Verification and Iteration
After replaying selected cells, automation activates the reCAPTCHA Verify control and checks whether the widget has passed. The architecture expects multiple sequential image tasks before completion; challenge refresh handling and stronger error recovery are not yet implemented.
- `utils/clickRecaptchaVerifyButton.js`
- `utils/isRecaptchaPassed.js`
- `captchaSolver.js`

#### Runtime and Dependencies
The project runs under Node.js via the npm start command defined in `package.json`. It depends on Puppeteer for Chromium/browser control and reaches 2Captcha over its remote API. Demonstration assets are non-runtime documentation:
- `package.json`
- `index.js`
- `media/bypass_recaptcha_v2.gif`

Main entry points: [`captchaSolver.js`](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/captchaSolver.js) (Captcha solver coordinator), [`utils/clickAtCoordinates.js`](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/clickAtCoordinates.js) (Coordinate click replay), [`index.js`](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/index.js) (Execution entry), [`utils/isFoundRecaptchaChallengeFrame.js`](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/isFoundRecaptchaChallengeFrame.js) (Widget frame discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Node.js Runtime"]
  node_package["npm start &amp; dependencies<br/>package manifest<br/>[package.json]"]
  node_entry["Execution entry<br/>Node.js entry point<br/>[index.js]"]
end

subgraph group_browser["Browser / reCAPTCHA"]
  node_puppeteer["Puppeteer / Chromium<br/>browser automation"]
  node_target["Target page<br/>live web page"]
  node_frame_discovery["Widget frame discovery<br/>reCAPTCHA DOM boundary"]
  node_challenge_state["Challenge pass check<br/>reCAPTCHA state check"]
  node_verify["Verify control<br/>reCAPTCHA interaction"]
end

subgraph group_pipeline["Solve Pipeline"]
  node_solver{{"Captcha solver coordinator<br/>orchestrator<br/>[captchaSolver.js]"}}
  node_extractor_init["Extractor injection<br/>in-page setup"]
  node_params["Grid challenge parameters<br/>challenge extractor"]
  node_cell_clicks["Coordinate click replay<br/>grid interaction"]
  node_randomization["Human-like timing<br/>interaction randomizer<br/>[getRandomNumber.js]"]
  node_click_info["Click diagnostics<br/>interaction logging<br/>[showClickInfo.js]"]
end

subgraph group_external["External Service"]
  node_twocaptcha{{"2Captcha Grid API<br/>remote solver API"}}
end

node_package -->|"npm start"| node_entry
node_entry -->|"starts"| node_solver
node_solver -->|"controls"| node_puppeteer
node_puppeteer -->|"loads"| node_target
node_solver -->|"locates challenge"| node_frame_discovery
node_frame_discovery -->|"inspects nested frames"| node_target
node_solver -->|"injects"| node_extractor_init
node_extractor_init -->|"enables collection"| node_params
node_params -->|"GridTask request"| node_twocaptcha
node_twocaptcha -->|"selected cells"| node_cell_clicks
node_cell_clicks -->|"uses offsets and delays"| node_randomization
node_cell_clicks -->|"reports clicks"| node_click_info
node_cell_clicks -->|"replays in frame"| node_puppeteer
node_solver -->|"after replay"| node_verify
node_verify -->|"clicks control"| node_puppeteer
node_solver -->|"checks completion"| node_challenge_state
node_challenge_state -.->|"repeat if pending"| node_solver

click node_package "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/package.json"
click node_entry "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/index.js"
click node_solver "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/captchaSolver.js"
click node_frame_discovery "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/isFoundRecaptchaChallengeFrame.js"
click node_challenge_state "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/isRecaptchaPassed.js"
click node_extractor_init "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/initCaptchaParamsExtractor.js"
click node_params "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/getCaptchaParams.js"
click node_cell_clicks "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/clickAtCoordinates.js"
click node_randomization "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/getRandomNumber.js"
click node_click_info "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/showClickInfo.js"
click node_verify "https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/clickRecaptchaVerifyButton.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_package,node_entry toneBlue
class node_puppeteer,node_target,node_frame_discovery,node_challenge_state,node_verify toneAmber
class node_solver,node_extractor_init,node_params,node_cell_clicks,node_randomization,node_click_info toneMint
class node_twocaptcha toneRose
```

## Components

### Node.js Runtime

- [npm start & dependencies](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/package.json): package manifest · Defines Node.js startup and Puppeteer dependency. · `package.json`
- [Execution entry](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/index.js): Node.js entry point · `index.js`

### Browser / reCAPTCHA

- **Puppeteer / Chromium**: browser automation
- **Target page**: live web page
- [Widget frame discovery](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/isFoundRecaptchaChallengeFrame.js): reCAPTCHA DOM boundary · Finds badge and nested challenge frames. · `utils/isFoundRecaptchaChallengeFrame.js`
- [Challenge pass check](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/isRecaptchaPassed.js): reCAPTCHA state check · `utils/isRecaptchaPassed.js`
- [Verify control](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/clickRecaptchaVerifyButton.js): reCAPTCHA interaction · `utils/clickRecaptchaVerifyButton.js`

### Solve Pipeline

- [Captcha solver coordinator](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/captchaSolver.js): orchestrator · Coordinates extraction, submission, replay, and iterative verification. · `captchaSolver.js`
- [Extractor injection](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/initCaptchaParamsExtractor.js): in-page setup · `utils/initCaptchaParamsExtractor.js`
- [Grid challenge parameters](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/getCaptchaParams.js): challenge extractor · Collects grid dimensions, instruction, and image payload. · `utils/getCaptchaParams.js`
- [Coordinate click replay](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/clickAtCoordinates.js): grid interaction · Maps solver cell numbers to grid coordinates and clicks them. · `utils/clickAtCoordinates.js`
- [Human-like timing](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/getRandomNumber.js): interaction randomizer · `utils/getRandomNumber.js`
- [Click diagnostics](https://github.com/2captcha/puppeteer-recaptcha-solver-using-clicks/blob/main/utils/showClickInfo.js): interaction logging · `utils/showClickInfo.js`

### External Service

- **2Captcha Grid API**: remote solver API · Returns selected grid cells or an error/unsolvable result.

## Connections

- npm start & dependencies → Execution entry: npm start
- Execution entry → Captcha solver coordinator: starts
- Captcha solver coordinator → Puppeteer / Chromium: controls
- Puppeteer / Chromium → Target page: loads
- Captcha solver coordinator → Widget frame discovery: locates challenge
- Widget frame discovery → Target page: inspects nested frames
- Captcha solver coordinator → Extractor injection: injects
- Extractor injection → Grid challenge parameters: enables collection
- Grid challenge parameters → 2Captcha Grid API: GridTask request
- 2Captcha Grid API → Coordinate click replay: selected cells
- Coordinate click replay → Human-like timing: uses offsets and delays
- Coordinate click replay → Click diagnostics: reports clicks
- Coordinate click replay → Puppeteer / Chromium: replays in frame
- Captcha solver coordinator → Verify control: after replay
- Verify control → Puppeteer / Chromium: clicks control
- Captcha solver coordinator → Challenge pass check: checks completion
- Challenge pass check → Captcha solver coordinator: repeat if pending · Sequential image tasks may require another solve cycle.
