# VisaAgent: AI and RPA visa-form automation platform

> A product I built solo over about 22 months: AI document import, Playwright automation of five visa forms, local-first sync to Supabase, multi-tenant billing, code-signed releases and a WhatsApp bot.

URL: https://thuyavan.netlify.app/projects/visaagent
Updated: 2026-10-12

- Role: Sole designer and developer
- Period: 2024-12 → 2026-10
- Technologies: Playwright, LLM integration, Python, FastAPI / Flask, Electron, React, Supabase / Postgres, SQLite, OCR / computer vision, Docker / CI/CD

## Executive Summary

A multi-generation SaaS-style product the owner built solo over ~22 months.

Gen 1 (Dec 2024): a Python prototype that fills the India e-Visa form (fillVisaForm.py → v1 app with pages + backend, captcha OCR).

Gen 2 (Jan–Feb 2026), the desktop product:

an Electron desktop app (React client UI) with a bundled FastAPI local backend (PyInstaller) and a SQLite local-first store synced to Supabase

AI document import (Gemini via an edge function) and Playwright automation of all 5 India e-Visa forms, with real-time progress over WebSocket + Supabase Realtime

multi-tenant companies / users / roles, credentials and presets, a pricing engine (prepaid / postpaid, volume tiers, reuse detection to avoid double charging), invoices and balances

an admin app, versioned releases (v25+) with code signing, browser install / selection logic, and fixes for antivirus / network issues

Gen 3 (May–Oct 2026), the cloud and agent era:

a web platform (React monorepo with a shared @visaagent/cloud-client package) and a Chrome extension (with MediaPipe vision for photo checks)

an AI agent worker (Playwright + Supabase job queue, captcha client, OpenCV face-based photo cropping, PyMuPDF document prep, a dev control UI)

China visa support (AI extraction, application versions, fill runs with events, persistent browser profile)

an n8n automation “brain”

a WhatsApp bot on Supabase edge functions (wa-webhook, wa-send, wa-prepare, wa-job-event, wa-staff-action) with cases, ledgers, templates, link codes, automation settings and staff actions in the admin app

captcha solving and AI health edge functions, document-review findings, clarification requests, prompt management (system / company / service prompts), data-retention policies, and a credential access log

## Portfolio Blurb + Resume Bullets

Blurb:

Founded and built VisaAgent, an AI + RPA platform that cuts travel agencies’ visa form filling from 30–45 to 5–10 minutes. Gemini extracts passport and document data, and Playwright agents fill India / China government forms with captcha solving and photo processing. It runs as an Electron + FastAPI desktop app (local-first SQLite, Supabase sync), a React web platform with a Chrome extension, and a WhatsApp bot, with multi-tenant billing (credits, prepaid / postpaid, reuse detection), an admin console, code-signed releases and 181 Postgres migrations.

Bullets:

Built AI document extraction with Google Gemini (edge functions gemini-extract, cn-ai-extract, ai-health) behind prompt management (system / company / service prompts, prompt logs, usage logs and costing).

Built Playwright automation for the 5-step India e-Visa and the China online visa forms, with real-time progress, resume after failure (resume code flow), confirmation capture, captcha solving (captcha-solve + captcha_client.py), and OpenCV face-detected photo cropping.

Shipped a desktop product: Electron + React UI + FastAPI backend bundled with PyInstaller, SQLite local-first with Supabase sync, a dynamic-port architecture, browser installation / selection, code signing, and a release pipeline (v25+); fixed an antivirus-blocking connectivity issue (post-mortem doc).

Designed a multi-tenant billing system in Postgres: companies, credit pools and scopes, balances, pricing tiers, reuse pricing (no double charge for re-runs), invoices / line items, limit-change history, payments, through RPC functions and triggers.

Built the cloud generation: a React web platform + shared cloud client package, a Chrome extension (MediaPipe tasks-vision), and an AI agent worker consuming agent_jobs from Supabase.

Built a WhatsApp bot (Supabase edge functions + Postgres: conversations, messages, contacts, cases, case ledger, templates, link codes, automation settings, audit events) for document collection, family / group cases, payment prompts and staff actions, with admin views.

Added governance: data-retention policies, credential access logs, encryption guide, doc-review findings, clarification requests.

Built a Sri Lanka ETA Chrome extension (Manifest V3, eta.gov.lk) with a country mapper, date pickers and chat.

## Business Domain

Concept
Meaning

Company (agency)
Tenant; users, roles, services, credits / balance, prompt overrides

User
Agency staff (permissions per service), presets, credentials (government portal logins, access-logged), settings, WhatsApp numbers, client pool

Service
Visa service (India e-Visa types, China visa…) with categories, prompts, pricing

Visa application / group
Applicant data (from AI extraction + review), group / family members, files, versions (China)

Automation attempt / fill run
One browser run with events (progress, errors, screenshots), resumable

AI extraction
Gemini output + debug / usage logs; doc-review findings; clarification requests to the customer

Billing
Credits / pools / scopes, pricing tiers, reuse pricing, balance transactions, invoices + line items, payments

WhatsApp case
Customer conversation → case (documents, family members, questions) → ledger / pricing → job to the agent worker → result / payment

## Technology Stack

6.1 Desktop local backend (requirements.txt)

FastAPI 0.104.1, uvicorn 0.24, httpx 0.27, SQLAlchemy 2.0.23, pydantic 2.10.4, Playwright 1.40, Selenium 4.15 + webdriver-manager (fallback), Pillow 10.1, pandas 2.1.3, openpyxl 3.1.2, psycopg2-binary, supabase 2.10, PyInstaller 6.3, BeautifulSoup 4.12, google-genai ≥ 1.0 (Gemini), PyMuPDF, opencv-python-headless, python-docx, pdf-orientation-corrector, pytesseract, pypdf, pip-system-certs, python-dotenv.

6.2 Agent worker

Playwright ≥ 1.48, supabase ≥ 2.10, httpx, pydantic, SQLAlchemy, Pillow, OpenCV < 5 (CascadeClassifier face detection for photo cropping), PyMuPDF, pypdf, tenacity (retries), structlog (structured logs).

6.3 Frontends

Desktop client-ui and web app: React (TS), Radix UI set, @tanstack/react-table 8, tsparticles, date-fns, CVA / clsx, supabase-js 2.89, @visaagent/cloud-client (web).

Admin app: React + shadcn / Radix, react-hook-form + @hookform/resolvers + zod, @monaco-editor/react (prompt editing), Turnstile.

Extension: React 19 / Preact 10, @mediapipe/tasks-vision 0.10.17, supabase-js, cloud client.

6.4 Cloud

Supabase Postgres (RPC functions, triggers, RLS), Auth (JWT), Realtime, Storage, Edge Functions (Deno/TS); Gemini model family (2.5-flash / -lite / -pro and newer flash variants referenced); WhatsApp Cloud API (wa-* functions); Firebase (version sync); n8n (Docker) workflows.

6.5 Runtime

Windows + PowerShell, Python 3.11.3, Node 22.18, npm 10.8 (run guide).

## Architecture

7.1 Generations

7.2 Desktop product (Gen 2)

7.3 Cloud / agent / WhatsApp (Gen 3)

7.4 Automation run (India)

## Database (cloud, 60+ tables)

Tenancy: companies, user_profiles, user_settings, user_service_permissions, user_presets, user_credentials (+ credential_access_logs), user_clients, user_contact_pool, user_whatsapp_numbers, institutions.
Services / AI: services, service_categories, company_services, system_prompts, service_prompts, company_prompt_overrides, prompt_options, prompt_settings, prompt_logs, aiextractions, ai_debug_logs, ai_usage_logs (+ base), mock_responses, doc_review_findings, clarification_requests, cloud_api_keys.
Applications / automation: visa_applications, visa_groups, visa_group_members, group_files, case_documents, automationattempts, automation_configs, custom_fills, custom_fill_groups, agent_jobs, cn_applications, cn_application_versions, cn_application_files, cn_fill_runs, cn_fill_run_events.
Billing: pricingtiers, reusepricing, company_credits, company_credit_pools, credit_pool_scope, companybalance, balancetransactions, invoices, invoicelineitems, payments, limitchangehistory.
WhatsApp: wa_contacts, wa_conversations, wa_messages, wa_cases, wa_case_ledger, wa_pricing, wa_templates, wa_link_codes, wa_automation_keys, wa_automation_settings, wa_automation_setting_log, wa_audit_events.
Ops / governance: app_versions, data_retention_policies, data_retention_log.
Plus local SQLite (12+ tables) for offline apps and cache [V doc].

## Features (complete)

AI passport / document extraction · review / edit UI · India e-Visa 5-form automation · China form automation with persistent profile · resume after failure · captcha solving · photo crop (face detection) / rotation / orientation fixes · PDF and document prep · progress streaming (WebSocket + Realtime) · multi-tenant companies / users / roles / service permissions · credentials (encrypted, access-logged) and presets · pricing engine (prepaid / postpaid, tiers, reuse) · credits / balances / invoices · admin console (services, prompts with Monaco editor, users, companies, pricing, WhatsApp chats, family card, payments due) · desktop build / release / code signing / auto version sync · browser install and selection · web platform (AI Import, Apply, History) · Chrome extension fill · agent worker + dev control UI · n8n workflows · WhatsApp bot (menu, documents, family, questions, payments, staff actions, templates, link codes) · data retention · audit logs · Sri Lanka ETA extension.

## Security & Compliance

Supabase JWT auth + RLS; encrypted stored credentials with access logs (encryption_guide.md); API-key management for cloud AI keys (round-robin calls, import format); data-retention policies with logs; code-signed desktop binaries (CODE_SIGNING_GUIDE, certs/); Turnstile in admin; secrets in .env / Supabase secrets «redacted». The service-account JSON in the parent folder is a risk to rotate / remove.

## Build, Release, Ops

PyInstaller backend + Electron packaging (DESKTOP_PACKAGING_GUIDE, BUILD_AND_RELEASE_GUIDE), releases (v25 Jan 2026), version sync to Firebase, client installation guide, debugging guides for release backend, browser installation and startup; dynamic port architecture; database migration compatibility guide; n8n via Docker.

## Algorithms / Logic

Reuse detection (same applicant / service within a window → no charge), volume-tier pricing, credit-pool scoping, resumable step machine over 5 forms, captcha pipeline (OCR model → AI solve fallback), face-detected crop to the portal’s photo specs, API-key round-robin for AI quota spread, retries with tenacity.

## Metrics

Component
LOC

Desktop backend (Python)
48,896

Desktop UI
42,192

Admin app
48,121

Web platform
37,884

Cloud (TS / SQL)
14,308 / 19,063 (181 migrations)

Agent worker
6,118

n8n automation
7,099

SL extension
2,849

Commits / docs
233 / 77

## Skills Learned

Browser automation at production scale (Playwright / Selenium), LLM document extraction and prompt ops, desktop packaging and code signing, local-first sync, multi-tenant billing design, WhatsApp bot architecture, job-queue workers, n8n, Chrome extensions (MV3, MediaPipe), computer vision for photos, Supabase at scale.

## Challenges & Solutions

Challenge
Solution

Antivirus blocking backend connectivity
Post-mortem + env / packaging fixes

Browser path issues on client PCs
Browser selection / launch logic, Chromium / Edge path fixes

Field focus / cursor issues on the portal
Field-level focus handling

Long runs failing mid-way
Resume code flow

Double billing on retries
Reuse pricing

AI quota limits
API-key round-robin management

Image rotation / orientation
Orientation correction pipeline
