How handel-hub/bettingautomation works
Purpose and Runtime
Node.js 18+ Playwright automation engine for coordinated betting actions across one visible Master browser and multiple background Slave browsers. It loads encrypted account credentials, optional proxies, and INI settings; actions are recorded or replayed as macros, with an independent cashout path. Process entry point: index.mjs; shared configuration and browser utilities: src/config.mjs, src/utils/playwright.mjs.
Bootstrap, Credentials, and Network Identity
Startup reads settings, decrypts accounts.enc using MASTER_KEY, and assigns accounts/proxies to browser instances. Plaintext account import is encrypted for persistence; proxy and stealth facilities isolate or reduce detection exposure. Key boundaries: local secrets/config versus external betting sites.
Paths: src/utils/crypto.mjs, src/detection/proxyManager.mjs, src/detection/stealth.mjs.
Browser Fleet Control
AutomationController is the top-level browser orchestration façade. It routes incoming operator commands, maintains browser registration and lifecycle, resolves targets, tracks health, manages sessions, and locks accounts during exclusive operations such as cashout.
Paths: src/browser/AutomationController.mjs, src/browser/CommandRouter.mjs, src/browser/coordination/BrowserLifecycleManager.mjs.
Command Execution and Workflows
Commands enter a scheduler/receiver pipeline, gain an execution context, resolve locators, and are dispatched as real actions or simulated validation actions. MacroEngine replays sequence JSON across eligible slaves; WorkflowEngine hosts higher-level workflows, including cashout rather than relying on master mirroring.
Paths: src/browser/execution/ExecutionScheduler.mjs, src/browser/execution/MacroEngine.mjs, src/browser/workflows/CashoutWorkflow.mjs.
Master Capture and Slave Playback
Master-browser activity is captured by injected page-side JavaScript and stored as reusable sequences. On hotkey playback, the system broadcasts macro steps to ready slaves; validation mode substitutes action simulation/DOM checks for clicks. Sequence files are the durable boundary between capture and replay.
Paths: injected.js, src/browser/execution/ActionDispatcher.mjs, sequences/login.json.
Locator Intelligence Pipeline
Locator resolution is a dedicated pipeline: extract target features, generate ARIA/data/role/text/structural candidates, deduplicate, validate against the live DOM, rank candidates, serialize the selected locator, and emit telemetry. This isolates volatile betting-site DOMs from macro/workflow logic.
Paths: src/browser/execution/locatorIntelligence/engine/LocatorIntelligenceEngine.mjs, src/browser/execution/locatorIntelligence/generation/CandidateGenerator.mjs, src/browser/execution/locatorIntelligence/ranking/RankingEngine.mjs.
Synchronization, Recovery, and Observability
A capability-based synchronization subsystem observes connection, DOM, navigation, frames, viewport, and scrolling. It compares actual browser state with required consistency profiles, coordinates barriers, and executes recovery plans. This is separate from action execution so fleet readiness and recovery can gate work.
Paths: src/browser/synchronization/SynchronizationManager.mjs, src/browser/synchronization/coordination/SynchronizationCoordinator.mjs, src/browser/synchronization/providers/frame/FrameCapabilityProvider.mjs.
Main entry points: AutomationController.mjs Automation Controller · ExecutionScheduler.mjs Execution Scheduler · ActionDispatcher.mjs Action Dispatcher · LocatorIntelligenceEngine.mjs Locator Engine
Components 22
Bootstrap & Identity
Local settings, encrypted accounts, and browser identity controls.
- Process Entry
index.mjs - Settings Loader · Loads INI settings and shared browser configuration.
src/config.mjs - Encrypted Accounts · Encrypted account credentials persisted locally.
accounts.enc - Credential Crypto · Decrypts accounts with MASTER_KEY and encrypts imports.
src/utils/crypto.mjs - Proxy & Stealth · Assigns proxies and reduces browser detection exposure.
src/detection/proxyManager.mjs
Browser Fleet
Operator command routing and browser lifecycle control.
- Automation Controller · Registers browsers, resolves targets, tracks health, sessions, and account locks.
src/browser/AutomationController.mjs - Command Router
src/browser/CommandRouter.mjs - Browser Lifecycle · Launches and manages visible master and background slave browsers.
src/browser/coordination/BrowserLifecycleManager.mjs
Execution & Macros
Action scheduling, playback, and cashout workflows.
- Execution Scheduler · Builds execution context and schedules browser work.
src/browser/execution/ExecutionScheduler.mjs - Macro Engine · Replays recorded sequences across eligible ready slaves.
src/browser/execution/MacroEngine.mjs - Cashout Workflow · Runs independent cashout actions with account locking.
src/browser/workflows/CashoutWorkflow.mjs - Action Dispatcher · Executes real actions or validation-mode DOM simulations.
src/browser/execution/ActionDispatcher.mjs - Master Activity Capture · Captures visible master-browser activity as reusable steps.
injected.js - Sequence Files · Durable capture-to-replay boundary.
sequences/login.json
Locator Intelligence
Live-DOM locator generation and ranking pipeline.
- Locator Engine · Extracts target features, validates live DOM candidates, and serializes the selected locator.
src/browser/execution/locatorIntelligence/engine/LocatorIntelligenceEngine.mjs - Candidate Generator · Produces ARIA, data, role, text, and structural candidates.
src/browser/execution/locatorIntelligence/generation/CandidateGenerator.mjs - Ranking Engine
src/browser/execution/locatorIntelligence/ranking/RankingEngine.mjs
Synchronization
Readiness barriers and browser-state recovery.
- Synchronization Manager · Gates work on required browser consistency profiles.
src/browser/synchronization/SynchronizationManager.mjs - Synchronization Coordinator · Coordinates fleet barriers and recovery plans.
src/browser/synchronization/coordination/SynchronizationCoordinator.mjs - Frame Capability Provider · Supplies frame capability state for synchronization.
src/browser/synchronization/providers/frame/FrameCapabilityProvider.mjs
Other components
- Operator
- Betting Sites · Volatile external site DOM and betting endpoints.
Connections 26
- Process Entry → Settings Loader: loads
- Process Entry → Credential Crypto: initializes
- Credential Crypto → Encrypted Accounts: decrypts and persists
- Settings Loader → Automation Controller: configures
- Encrypted Accounts → Automation Controller: supplies accounts
- Proxy & Stealth → Browser Lifecycle: applies identity controls
- Operator → Automation Controller: commands
- Automation Controller → Command Router: routes commands
- Automation Controller → Browser Lifecycle: manages
- Command Router → Execution Scheduler: submits work
- Execution Scheduler → Macro Engine: dispatches macro replay
- Execution Scheduler → Cashout Workflow: dispatches cashout
- Macro Engine → Sequence Files: loads steps
- Master Activity Capture → Sequence Files: records
- Macro Engine → Action Dispatcher: broadcasts steps
- Cashout Workflow → Action Dispatcher: executes actions
- Action Dispatcher → Locator Engine: resolves targets
- Locator Engine → Candidate Generator: generates candidates
- Candidate Generator → Ranking Engine: submits candidates
- Ranking Engine → Locator Engine: selects locator
- Execution Scheduler → Synchronization Manager: checks readiness
- Synchronization Manager → Synchronization Coordinator: coordinates barriers
- Synchronization Coordinator → Frame Capability Provider: queries capability
- Browser Lifecycle → Betting Sites: opens browsers to
- Action Dispatcher → Betting Sites: acts on
- Locator Engine → Betting Sites: validates against DOM