Skip to the content.

Universal Request Analyzer - Complete Architecture Overview

Table of Contents

  1. System Architecture
  2. Data Architecture
  3. Code Organization
  4. Component Architecture
  5. Analytics & Reporting
  6. Development Workflow

System Architecture

High-Level Overview

graph TB
    subgraph Browser["🌐 Browser Environment"]
        subgraph UI["User Interface Components"]
            Popup["πŸ“Š Popup UI<br/>(Extension Icon)"]
            DevTools["πŸ”§ DevTools Panel<br/>(Browser DevTools)"]
            Options["βš™οΈ Options Page<br/>(Settings)"]
        end

        ContentScript["πŸ“„ Content Scripts<br/>(Injected into pages)"]

        subgraph Background["πŸ”„ Background Service Worker (MV3)"]
            RequestCapture["πŸ“‘ Request Capture<br/>(webRequest API)"]
            RequestRunner["▢️ Request Runner<br/>(Execution Engine)"]
            EventBus["🚌 Event Bus<br/>(Message routing)"]
            MessageHandler["βœ‰οΈ Message Handler<br/>(Action dispatcher)"]

            subgraph Managers["Core Managers"]
                DBManager["πŸ’Ύ Database Manager<br/>(Medallion Architecture)"]
                SettingsManager["βš™οΈ Settings Manager"]
                ExportManager["πŸ“€ Export Manager"]
                CleanupManager["🧹 Cleanup Manager"]
                AnalyticsProcessor["πŸ“Š Analytics Processor<br/>(Analytics & Trends)"]
            end
        end

        subgraph Database["πŸ—„οΈ Database Layer (SQL.js + OPFS)"]
            Config["Config Schema<br/>(Settings, Flags, Runners)"]
            Bronze["Bronze Layer<br/>(Requests, Executions, Events)"]
            Silver["Silver Layer<br/>(Validated + Star Schema)"]
            Gold["Gold Layer<br/>(Daily Analytics & Insights)"]
        end
    end

    subgraph External["🌍 External Systems"]
        WebPages["Web Pages<br/>(HTTP Requests)"]
        Storage["Browser Storage<br/>(chrome.storage)"]
    end

    %% Communication flows
    WebPages -->|"HTTP Requests"| RequestCapture
    RequestCapture -->|"Captured Data"| Bronze

    ContentScript -.->|"chrome.runtime<br/>.sendMessage"| EventBus
    Popup -.->|"chrome.runtime<br/>.sendMessage"| EventBus
    DevTools -.->|"chrome.runtime<br/>.sendMessage"| EventBus
    Options -.->|"chrome.runtime<br/>.sendMessage"| EventBus

    EventBus -->|"Route Messages"| MessageHandler
    MessageHandler -->|"Query/Update"| Managers

    Managers <-->|"Read/Write"| Database
    DBManager <-->|"CRUD Operations"| Config
    DBManager <-->|"CRUD Operations"| Bronze
    DBManager <-->|"CRUD Operations"| Silver
    DBManager <-->|"CRUD Operations"| Gold

    SettingsManager <-->|"Sync Settings"| Config
    SettingsManager <-->|"Sync Settings"| Storage

    RequestRunner <-->|"Read Definitions"| Config
    RequestRunner -->|"Execute Requests"| WebPages
    RequestRunner -->|"Log Results"| Bronze

    Bronze -->|"Process & Validate"| Silver
    Silver -->|"Aggregate & Analyze"| Gold
    AnalyticsProcessor -->|"Compute Analytics"| Silver
    AnalyticsProcessor -->|"Generate Insights"| Gold

    MessageHandler -.->|"Response"| Popup
    MessageHandler -.->|"Response"| DevTools
    MessageHandler -.->|"Response"| Options

    ExportManager -->|"Export Data"| Bronze
    ExportManager -->|"Export Data"| Silver
    ExportManager -->|"Export Data"| Gold

    CleanupManager -->|"Purge Old Data"| Bronze
    CleanupManager -->|"Purge Old Data"| Silver
    CleanupManager -->|"Purge Old Data"| Gold

    style UI fill:#e3f2fd
    style Background fill:#fff3e0
    style Database fill:#f3e5f5
    style External fill:#e8f5e9
    style Managers fill:#fff9c4

Communication Flow Details

  1. Request Capture Flow

    • Browser makes HTTP request β†’ webRequest API intercepts β†’ Background captures β†’ Bronze layer stores
  2. UI β†’ Background Flow

    • UI component calls chrome.runtime.sendMessage() β†’ Event Bus receives β†’ Message Handler routes β†’ Manager processes β†’ Database query/update β†’ Response back to UI
  3. Settings Sync Flow

    • Settings Manager maintains settings in both database (config_app_settings) and browser storage (chrome.storage.local) for fast access
  4. Data Processing Flow

    • Bronze (raw) β†’ Silver (validated + enriched) β†’ Gold (aggregated analytics)
  5. Content Script Communication

    • Content scripts read config from chrome.storage.local (set by Settings Manager) and cannot directly import background modules

Data Architecture

Medallion Architecture with Star Schema

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ CONFIG SCHEMA - Application Configuration                    β”‚
β”‚ β€’ App Settings  β€’ Feature Flags  β€’ User Preferences          β”‚
β”‚ β€’ Performance Settings  β€’ Storage Settings  β€’ Export Settingsβ”‚
β”‚ β€’ Runner Definitions  β€’ Runner Requests  β€’ Runner Collectionsβ”‚
β”‚ β€’ Scheduled Runs  β€’ Runner Alerts                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ BRONZE SCHEMA - Raw Event Capture Data                       β”‚
β”‚ β€’ Requests  β€’ Headers  β€’ Timings  β€’ Events  β€’ Sessions       β”‚
β”‚ β€’ Errors  β€’ Performance Entries  β€’ Runner Executions         β”‚
β”‚ β€’ Runner Execution Results                                   β”‚
β”‚ Characteristics: Immutable, Complete, Timestamped, Append-Onlyβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              ↓
                        Data Processing
                  (Validation & Enrichment)
                              ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SILVER SCHEMA - Curated Data + STAR SCHEMA                   β”‚
β”‚ Curated Tables:                                              β”‚
β”‚ β€’ Validated Requests  β€’ Metrics  β€’ Domain Stats              β”‚
β”‚ β€’ Resource Stats  β€’ Tags                                     β”‚
β”‚                                                              β”‚
β”‚ Star Schema Dimensions:                                      β”‚
β”‚ β€’ dim_time (Multi-timeframe)                                β”‚
β”‚ β€’ dim_domain (SCD Type 2)                                   β”‚
β”‚ β€’ dim_resource_type                                         β”‚
β”‚ β€’ dim_status_code                                           β”‚
β”‚                                                              β”‚
β”‚ Star Schema Facts:                                           β”‚
β”‚ β€’ fact_requests (Atomic metrics)                            β”‚
β”‚ β€’ fact_performance_trends (Trend tracking)                   β”‚
β”‚ β€’ fact_quality_metrics (Quality scores)                      β”‚
β”‚                                                              β”‚
β”‚ Characteristics: Validated, Enriched, Indexed, Analytical    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              ↓
                        Aggregation
                  (Daily/Weekly/Monthly)
                              ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ GOLD SCHEMA - Analytics & Insights                           β”‚
β”‚ β€’ Daily Analytics  β€’ Performance Insights                    β”‚
β”‚ β€’ Domain Performance  β€’ Optimization Opportunities           β”‚
β”‚ β€’ Trends  β€’ Anomalies                                        β”‚
β”‚ Characteristics: Aggregated, Historical, Actionable          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow

Browser Event β†’ Bronze (Raw) β†’ Silver (Validated + Star Schema) β†’ Gold (Analytics)
                    ↓               ↓                                  ↓
                Immutable      Fact Tables                      Pre-aggregated
                Complete       Dimensions                       Insights
                Audit Trail    Analytics                        Trends

Code Organization

Directory Structure

src/
β”œβ”€β”€ lib/                          # Shared Library (NEW)
β”‚   β”œβ”€β”€ core/                     # Core Classes
β”‚   β”‚   └── DataManager.js        # Base data management
β”‚   β”œβ”€β”€ ui/                       # UI Components
β”‚   β”‚   β”œβ”€β”€ BaseComponent.js      # Base component class
β”‚   β”‚   β”œβ”€β”€ ChartManager.js       # Chart management
β”‚   β”‚   └── NotificationManager.js # Notifications
β”‚   β”œβ”€β”€ managers/                 # Feature Managers
β”‚   β”‚   └── ExportManager.js      # Export/Import
β”‚   β”œβ”€β”€ utils/                    # Utilities
β”‚   β”‚   └── helpers.js            # Helper functions
β”‚   └── index.js                  # Main entry point
β”‚
β”œβ”€β”€ background/                   # Background Service Worker
β”‚   β”œβ”€β”€ database/                 # Database Layer
β”‚   β”‚   β”œβ”€β”€ medallion-schema.js   # Medallion architecture (Config + Bronze + Silver + Gold)
β”‚   β”‚   β”œβ”€β”€ star-schema.js        # Star schema with SCD Type 2
β”‚   β”‚   β”œβ”€β”€ medallion-manager.js  # Data flow orchestration
β”‚   β”‚   β”œβ”€β”€ config-schema-manager.js # Config management
β”‚   β”‚   β”œβ”€β”€ analytics-processor.js # Analytics & aggregations
β”‚   β”‚   β”œβ”€β”€ medallion-migration.js # Data migration
β”‚   β”‚   β”œβ”€β”€ db-manager-medallion.js # Main DB manager with runner CRUD
β”‚   β”‚   β”œβ”€β”€ sql-js-loader.js      # SQL.js initialization
β”‚   β”‚   └── purge-manager.js      # Data cleanup
β”‚   β”œβ”€β”€ capture/                  # Request Capture & Runner Execution
β”‚   β”‚   β”œβ”€β”€ request-capture.js    # webRequest API integration
β”‚   β”‚   β”œβ”€β”€ request-runner.js     # Runner execution engine
β”‚   β”‚   β”œβ”€β”€ runner-collections.js # Runner collections manager
β”‚   β”‚   └── request-capture-integration.js # Medallion integration
β”‚   β”œβ”€β”€ messaging/                # Event Bus & Message Handlers
β”‚   β”‚   β”œβ”€β”€ event-bus.js          # Pub/sub event system
β”‚   β”‚   β”œβ”€β”€ message-handler.js    # Central message router
β”‚   β”‚   β”œβ”€β”€ handlers/             # Modular message handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ vitals-handlers.js    # Web vitals & recent requests
β”‚   β”‚   β”‚   β”œβ”€β”€ stats-handlers.js     # Statistics & filtered data
β”‚   β”‚   β”‚   β”œβ”€β”€ collection-handlers.js # Runner collections
β”‚   β”‚   β”‚   β”œβ”€β”€ analytics-handlers.js  # Analytics & compression
β”‚   β”‚   β”‚   β”œβ”€β”€ settings-handlers.js   # Settings CRUD
β”‚   β”‚   β”‚   └── export-handlers.js     # Data export
β”‚   β”‚   └── popup-message-handler.js # Legacy popup handlers
β”‚   β”œβ”€β”€ api/                      # API Services
β”‚   β”œβ”€β”€ auth/                     # Authentication
β”‚   β”œβ”€β”€ security/                 # Security & Encryption
β”‚   β”œβ”€β”€ cleanup/                  # Cleanup Manager
β”‚   β”œβ”€β”€ export/                   # Export Manager
β”‚   β”œβ”€β”€ compat/                   # Browser Compatibility
β”‚   β”‚   └── browser-compat.js     # Cross-browser API wrapper
β”‚   β”œβ”€β”€ background-medallion.js   # Main entry point (Medallion)
β”‚   └── background.js             # Legacy entry point
β”‚
β”œβ”€β”€ popup/                        # Popup UI
β”‚   β”œβ”€β”€ components/               # UI Components
β”‚   └── popup.html                # Popup page
β”‚
β”œβ”€β”€ options/                      # Options Page (Settings + Dashboard + Runners)
β”‚   β”œβ”€β”€ components/               # UI Components
β”‚   β”‚   β”œβ”€β”€ dashboard.js          # Dashboard with analytics
β”‚   β”‚   β”œβ”€β”€ runners.js            # Runner management UI
β”‚   β”‚   β”œβ”€β”€ analytics.js          # Analytics visualizations
β”‚   β”‚   β”œβ”€β”€ alerts.js             # Alert configuration
β”‚   β”‚   └── export-db.js          # Database export
β”‚   β”œβ”€β”€ js/                       # JavaScript modules
β”‚   β”‚   └── options.js            # Main options entry point
β”‚   β”œβ”€β”€ css/                      # Stylesheets
β”‚   β”‚   └── options.css           # Options page styles
β”‚   └── options.html              # Options page
β”‚
β”œβ”€β”€ devtools/                     # DevTools Panel
β”‚   └── devtools.html             # DevTools page
β”‚
└── content/                      # Content Scripts
    └── content.js                # Content script

Shared Library Benefits

  1. No Code Duplication: Single source of truth
  2. Reusable Classes: BaseComponent, ChartManager, etc.
  3. Consistent Behavior: Same utilities everywhere
  4. Easy Maintenance: Update once, apply everywhere
  5. Better Testing: Test shared code once

Component Architecture

Base Component Pattern

All UI components extend BaseComponent:

import { BaseComponent } from "@/lib/ui/BaseComponent.js";

class RequestList extends BaseComponent {
  async onInit() {
    // Initialization
  }

  setupEventListeners() {
    // Event handlers
  }

  render() {
    // Rendering logic
  }

  onDestroy() {
    // Cleanup
  }
}

Manager Classes

Encapsulate complex functionality:

Runner Architecture

Overview

The Runner system enables automated HTTP request execution with validation, scheduling, and collections support.

Runner Data Model

erDiagram
    config_runner_definitions ||--o{ config_runner_requests : contains
    config_runner_definitions ||--o{ bronze_runner_executions : executes
    config_runner_collections ||--o{ config_runner_definitions : groups
    bronze_runner_executions ||--o{ bronze_runner_execution_results : produces

    config_runner_definitions {
        text id PK
        text name
        text description
        text collection_id FK
        text execution_mode
        integer delay_ms
        boolean follow_redirects
        boolean validate_status
        boolean use_variables
        text header_overrides
        boolean is_active
        integer run_count
        integer last_run_at
        integer created_at
        integer updated_at
    }

    config_runner_requests {
        text id PK
        text runner_id FK
        integer sequence_order
        text url
        text method
        text headers
        text body
        text domain
        text page_url
        text captured_request_id
        text assertions
        text description
        boolean is_enabled
        integer created_at
    }

    config_runner_collections {
        text id PK
        text name
        text description
        text schedule_cron
        boolean is_active
        integer created_at
        integer updated_at
    }

    bronze_runner_executions {
        text id PK
        text runner_id FK
        text execution_mode
        integer start_time
        integer end_time
        integer total_requests
        integer successful_requests
        integer failed_requests
        text status
        text error
    }

    bronze_runner_execution_results {
        text id PK
        text execution_id FK
        text request_id
        text url
        text method
        integer status
        integer duration
        boolean success
        text error
        text response_body
        integer timestamp
    }

Runner Execution Flow

sequenceDiagram
    participant UI as Options Page
    participant BG as Background
    participant Runner as Request Runner
    participant DB as Database
    participant Web as Web Server

    UI->>BG: Create Runner Definition
    BG->>DB: Store Runner + Requests

    UI->>BG: Execute Runner
    BG->>DB: Load Runner Definition
    DB-->>BG: Runner + Requests

    BG->>Runner: Start Execution
    Runner->>DB: Create Execution Record

    loop For Each Request
        Runner->>Web: Execute HTTP Request
        Web-->>Runner: HTTP Response
        Runner->>DB: Store Execution Result
        Runner->>BG: Progress Update
        BG-->>UI: Update UI

        alt Sequential Mode
            Runner->>Runner: Wait delay_ms
        end
    end

    Runner->>DB: Update Execution Record
    Runner-->>BG: Execution Complete
    BG-->>UI: Show Results

Runner Features

  1. Execution Modes

    • Sequential: Execute requests one after another with configurable delays
    • Parallel: Execute all requests simultaneously
  2. Request Configuration

    • Custom headers and body
    • Follow redirects option
    • Status code validation
    • Variable interpolation
    • Per-request assertions
  3. Collections

    • Group related runners
    • Scheduled execution via cron expressions
    • Batch operations (run all in collection)
  4. Execution Tracking

    • Real-time progress updates
    • Success/failure metrics
    • Response time tracking
    • Error logging
    • Historical execution data
  5. UI Integration

    • Wizard-based runner creation
    • Dashboard β€œRun Selected” feature
    • Execution history viewer
    • Edit, duplicate, export, delete actions
    • Context menu for quick actions

Analytics & Reporting

Supported Timeframes

const timeframes = [
  "1min", // 1 minute
  "5min", // 5 minutes
  "15min", // 15 minutes
  "1h", // 1 hour
  "4h", // 4 hours
  "1d", // 1 day
  "1w", // 1 week
  "1m", // 1 month
];

Quality Metrics

Comprehensive site quality assessment:

SCD Type 2 Tracking

Domain attributes tracked over time:

// Version 1
{ domain: 'api.example.com', risk: 'low', valid: [t1, t2], current: false }

// Version 2 (after risk increased)
{ domain: 'api.example.com', risk: 'high', valid: [t2, null], current: true }

Development Workflow

1. Request Capture

// Browser makes request
β†’ Request Intercepted
β†’ Insert to Bronze Schema (raw data)
β†’ Queue for processing

2. Data Processing

// Background processor
β†’ Read from Bronze
β†’ Validate & Enrich
β†’ Insert to Silver (curated + facts)
β†’ Update dimensions (SCD Type 2)
β†’ Queue for aggregation

3. Analytics Generation

// Periodic processor
β†’ Read from Silver/Facts
β†’ Generate quality metrics
β†’ Calculate trends
β†’ Insert to Gold (analytics)

4. UI Display

// User opens dashboard
β†’ Query Gold/Silver schemas
β†’ Load analytics data for selected timeframe
β†’ Render charts using ChartManager
β†’ Display quality metrics

Key Features

1. Multi-Timeframe Analysis

View performance at any granularity:

2. Historical Tracking

Complete audit trail:

3. Performance Insights

4. Quality Monitoring

5. Flexible Querying

Star schema enables:

Star Schema Details

Dimension Tables

1. Time Dimension (dim_time)

Multi-granularity time tracking with support for 8 timeframes.

Supported Timeframes:

Key Columns:

2. Domain Dimension with SCD Type 2 (dim_domain)

Tracks domain attributes with full historical versioning using Slowly Changing Dimensions Type 2.

SCD Type 2 Implementation:

Key Columns:

Example History:

domain_key | domain      | risk_level | valid_from | valid_to   | is_current | version
-----------|-------------|------------|------------|------------|------------|--------
1          | api.com     | low        | 1638316800 | 1640908800 | 0          | 1
2          | api.com     | medium     | 1640908800 | NULL       | 1          | 2

3. Resource Type Dimension (dim_resource_type)

Pre-populated resource type categorization:

4. Status Code Dimension (dim_status_code)

HTTP status code metadata with success/error/redirect classifications.

Fact Tables

1. Request Fact Table (fact_requests)

Atomic request metrics linked to all dimensions.

Key Measures:

Tracks metric changes with moving averages and volatility measures.

3. Quality Metrics Fact (fact_quality_metrics)

Comprehensive quality assessment including:

Configuration

Application Settings

// Via ConfigSchemaManager
await configManager.setAppSetting("theme", "dark", {
  category: "ui",
  description: "UI theme preference",
});

const theme = await configManager.getAppSetting("theme");

Feature Flags

// Gradual rollout
await configManager.setFeatureFlag("newFeature", true, {
  rolloutPercentage: 25, // 25% of users
});

const isEnabled = await configManager.getFeatureFlag("newFeature");

Performance Settings

await configManager.updatePerformanceSettings({
  enabled: true,
  samplingRate: 100,
  captureNavigationTiming: true,
});

Best Practices

1. Data Layer

βœ… Do:

❌ Don’t:

2. Components

βœ… Do:

❌ Don’t:

3. Analytics

βœ… Do:

❌ Don’t:

Performance Optimization

1. Database

2. Caching

3. Query Optimization

Future Enhancements

  1. Machine Learning Layer

    • Anomaly detection
    • Performance predictions
    • Optimization recommendations
  2. Real-time Streaming

    • Live performance updates
    • WebSocket support
    • Real-time dashboards
  3. Advanced Analytics

    • Correlation analysis
    • Regression analysis
    • Forecasting
  4. Data Export

    • External BI tools integration
    • API for analytics
    • Scheduled exports
  5. Partitioning

    • Time-based partitions
    • Archive old data
    • Improve query performance