Skip to content

Architecture

John Williams edited this page Mar 18, 2026 · 1 revision

Architecture

Tech Stack

Layer Technology
Frontend Vanilla JavaScript (ES modules), single HTML file
Styling Custom CSS with CSS variables (dark theme design system)
Auth Google Identity Services (GSI) OAuth
Backend (optional) PHP 7+ REST API
Cloud Backend Supabase (PostgreSQL, Edge Functions, Auth, Realtime)
Media Processing Cloudinary (upload, transform, CDN, AI)
AI Providers Google Gemini, OpenAI GPT, Anthropic Claude
Image Gen Google Imagen (Nano Banana), DALL-E 3
Video Gen Google Veo 3.1
Local Storage IndexedDB, localStorage

Application Structure

index.html                    # Single-page application shell
β”œβ”€β”€ security-production.js    # Auth gate, HTTPS enforcement
β”œβ”€β”€ validator-app.js          # Core app logic, navigation, asset management
β”œβ”€β”€ validator.css             # Complete design system
β”‚
β”œβ”€β”€ ai-adapter.js             # AI outpainting, image-to-video
β”œβ”€β”€ ai-enhanced-analysis.js   # Multi-model creative analysis
β”œβ”€β”€ ai-intelligence-engine.js # Chained AI pipeline
β”œβ”€β”€ ai-library-integration.js # Asset cards, channel specs, AI generation
β”œβ”€β”€ ai-library-manager.js     # Session-based AI asset library
β”œβ”€β”€ ai-model-selector.js      # User model selection UI
β”œβ”€β”€ ai-models-config.js       # Provider/model configuration
β”œβ”€β”€ ai-orchestrator.js        # Task routing across AI providers
β”œβ”€β”€ ai-studio.js              # Text-to-image, outpainting UI
β”‚
β”œβ”€β”€ cloudinary-client.js      # Cloudinary upload, transform, resize
β”œβ”€β”€ auto-fix.js               # Batch fix workflow
β”‚
β”œβ”€β”€ crm.js                    # Client/project management
β”œβ”€β”€ integrations.js           # Google Drive, Sheets, Gmail, Dropbox, Slack
β”œβ”€β”€ google-ads-builder.js     # Google Ads campaign builder
β”œβ”€β”€ social-media-builder.js   # Meta/LinkedIn/X/TikTok ad builder
β”œβ”€β”€ keyword-analyzer.js       # Keyword research + landing page analysis
β”œβ”€β”€ strategy-module.js        # Campaign strategy planning
β”œβ”€β”€ learn-module.js           # URL analyzer, swipe file, benchmarks
β”œβ”€β”€ analyze-module.js         # Creative analysis (hook, CTA, brand)
β”œβ”€β”€ settings-module.js        # API keys, preferences, brand profiles
β”œβ”€β”€ logo-generator.js         # Brand kit generator
β”‚
β”œβ”€β”€ video-analyzer.js         # Video analysis orchestrator
β”œβ”€β”€ video-analyzer-v2.js      # Advanced paid-media video analysis
β”œβ”€β”€ video-analyzer-ui.js      # Video analysis UI
β”œβ”€β”€ video-intelligence-engine.js  # Full video pipeline
β”œβ”€β”€ video-intelligence-client.js  # Server-side video integration
β”œβ”€β”€ video-frame-extractor.js  # Frame extraction (Cloudinary + canvas)
β”œβ”€β”€ video-extraction-layer.js # URL normalization, metadata, thumbnails
β”‚
β”œβ”€β”€ security-core.js          # AES-256-GCM encryption, sessions
β”œβ”€β”€ auth-config.production.js # OAuth client ID, admin list
β”‚
β”œβ”€β”€ supabase-backend.js       # Main Supabase client
β”œβ”€β”€ supabase-full-integration.js  # CRM/asset Supabase wiring
β”œβ”€β”€ supabase-video-client.js  # Video analysis Supabase client
β”œβ”€β”€ supabase-video-processor.js   # Server-side video processing
β”‚
β”œβ”€β”€ data-models.js            # Data model definitions
β”œβ”€β”€ unified-storage.js        # Storage abstraction (IDB + Supabase)
β”œβ”€β”€ sync-engine.js            # Bidirectional sync
β”œβ”€β”€ realtime-sync.js          # Real-time Supabase subscriptions
β”œβ”€β”€ persistence-ui.js         # Save/load UI state
β”œβ”€β”€ advanced-features.js      # Additional features
β”œβ”€β”€ advanced-toolbar.js       # Toolbar components
└── sw.js                     # Service worker (offline support)

Data Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Browser    │────▢│  Cloudinary  │────▢│     CDN      β”‚
β”‚  (IndexedDB) β”‚     β”‚  (Process)   β”‚     β”‚  (Deliver)   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”‚ Sync
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Supabase   │────▢│  Edge Func   β”‚
β”‚  (Postgres)  β”‚     β”‚  (Process)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Storage Architecture

Local (IndexedDB)

  • Asset metadata and thumbnails
  • CRM data (companies, projects, contacts)
  • User preferences and API keys (encrypted)
  • Analysis history
  • Offline queue for pending changes

Cloud (Supabase)

  • User profiles and auth
  • Shared API keys
  • CRM entities
  • Video analyses
  • Activity logs
  • Real-time subscriptions

Media (Cloudinary)

  • Original uploaded assets
  • Transformed/resized derivatives
  • CDN URLs for delivery
  • Video frame extraction

Authentication Flow

Google Sign-In β†’ Token Validation β†’ Session Creation β†’ Domain Check
                                          β”‚
                                    β”Œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”
                                    β”‚           β”‚
                              Personal     Corporate
                              (any Gmail)  (domain-restricted)

API Architecture (PHP)

Optional PHP backend for self-hosted deployments:

api/
β”œβ”€β”€ index.php              # Router (REST endpoints)
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ Auth.php           # Google token validation, sessions
β”‚   β”œβ”€β”€ Database.php       # MySQL connection
β”‚   └── Response.php       # JSON response helpers
β”œβ”€β”€ services/
β”‚   └── CloudinaryService.php  # Signed transforms, quota
└── config/
    └── config.example.php # Database + Cloudinary credentials

Deployment Options

Platform Config File Notes
Netlify netlify.toml Static hosting + security headers
Vercel vercel.json Static hosting + security headers
Cloudflare Pages _headers Static hosting
Self-hosted .htaccess Apache + PHP for API

Clone this wiki locally