Screen-to-SOP & Automation Generator
Multimodal AI pipeline that turns screen recordings into structured SOP documents, native flowcharts, and verified Playwright Python or n8n JSON automation scripts with zero hardcoded secrets.
Built for operations and engineering teams who spend hours manually writing step-by-step SOP manuals and brittle browser automation scripts from repetitive screen workflows. Raw screen recordings often contain exposed passwords, API tokens, or customer emails that cannot safely be hardcoded into generated scripts. This system extracts key visual frames in the browser, streams live AI progress over SSE, automatically moves sensitive values into environment variables, and verifies every generated script before delivery.
Problem Solved
Operations teams repeat browser and back-office workflows daily, yet documenting Standard Operating Procedures (SOPs) and translating them into reliable automation scripts takes hours. Naive multimodal video-to-code prototypes upload huge raw video files, stall without progress feedback, leak credentials/PII into generated scripts, and output syntactically broken Playwright or n8n code.
Architecture & Engineering Decisions
1. Client-Side <canvas> Keyframe Extraction
- Decodes uploaded or recorded browser video directly on the client using an HTML5
<canvas>pixel-difference detector, extracting6–14compressed JPEG keyframes (<= 300 KBeach) instead of uploading multi-megabyte raw videos. - Keeps free-tier bandwidth and Gemini Vision token spend minimal while preserving every meaningful UI state transition.
2. Real-Time SSE Streaming Pipeline (/api/proxy/sop/api/v1/analyze/stream)
- Streams live Server-Sent Events (
extracting->sanitizing->composing_sop->synthesizing_script->complete) through a dedicated Next.js App Router streaming Route Handler (X-Accel-Buffering: no,Cache-Control: no-cache, no-transform) so users see real-time stage progress with zero cross-origin calls.
3. Secret & PDPA-to-.env Sanitizer (0.00% Secret Leak Rate)
- Scans extracted workflow steps for emails, Thai phone numbers, Thai National IDs, API tokens, and password fields before SOP composition or script synthesis.
- Replaces every detected sensitive value with typed environment variable placeholders (e.g.,
os.environ["PORTAL_PASSWORD"]) and generates a ready-to-use.env.examplealongside the redaction audit table.
4. AST / Schema Verification Harness & Self-Repair Loop
- Validates every generated Playwright Python script via Python's
ast.parse, forbidden-operation checks (eval,exec,os.system,subprocess), and hardcoded-secret scanners; validatesn8nworkflows against strict node/connection JSON schemas. - If verification flags a syntax, schema, or security issue, an automated self-repair loop feeds the exact diagnostics back to the synthesizer before returning the final artifact.
5. Shared Supabase screen_to_sop.* Schema Isolation
- Persists run metadata in an isolated PostgreSQL 16 schema (
screen_to_sop.*) with PgBouncer-safepsycopg_poolconnections (prepare_threshold=None),AUTH_MODE=demo_sandbox|token, and SHA-256 IP-hashed rate limiting.
Verified Benchmarks
- Golden Eval Gate (
12 / 12Passed —100%): End-to-end multimodal workflow extraction, SOP Markdown + Flowchart generation, and Playwright Python /n8nJSON synthesis. - Valid Script Rate (
100% Verified): Zero syntax or schema failures after AST/schema verification + self-repair. - Hardcoded Secret Leak Rate (
0.00%): All synthetic credentials, API tokens, and PDPA fields extracted cleanly into.env.example. - Automated Tests:
40 / 40 pytestpassed + green CI.