Reverse-engineered and refactored a legacy Python-based high-frequency automation framework for a Middle East client. Reduced authentication latency by ~60%, implemented shared-memory IPC for Master→Receiver synchronization, added captcha session reuse, and built a curl_cffi-based stealth transport layer.
The client inherited a complex Python automation framework originally built by a third-party developer. The system had significant performance bottlenecks across the authentication, monitoring, and execution paths, with no clear architecture documentation. The goal was to reverse-engineer the existing codebase, identify the critical paths, and rebuild them for high-frequency operation under real-world server response conditions.
The work was structured in three phases: a baseline audit (Phase 0), incremental optimization rounds (Phase 1), and a full architectural refactor introducing a Master→Receiver pattern with shared-memory IPC for sub-millisecond handoff (Phase 2).
Reverse engineering: The original codebase had no architectural documentation. Mapped the request flow end-to-end by instrumenting every entry point, tracing call graphs, and documenting the critical path before changing a single line of code.
Phase 1 — Targeted optimization: Removed defensive sleeps and timeouts that were padding the critical path, tightened WebSocket polling intervals, and introduced lazy initialization for heavy renderers. Each change was measured with before/after benchmarks.
Phase 2 — Architectural refactor: Split the monolithic process into a Master (monitoring/decision) and Receiver (execution) using a shared memory bus and atomic flags for handoff. This avoided the overhead of any external IPC mechanism (no Redis, no sockets, no queues) and produced a measured handoff time of ~2ms. The execution path was rebuilt on top of curl_cffi to spoof TLS fingerprints and bypass JA3-based detection.