Hercules Merchandise

Hybrid Architecture Technical Proposal

Current Challenge

The existing WooCommerce/WordPress implementation faces significant performance challenges:

  • Lighthouse Performance: 40-60 (Target: 90+)
  • Heavy plugin overhead reducing Core Web Vitals
  • Slow page loads impacting user experience and SEO

Proposed Architecture

A hybrid approach combining static site generation with dynamic backend capabilities:

graph TB
    subgraph "Frontend Layer"
        A[Astro Static Site]
        B[React Islands]
        C[Cloudflare Pages]
    end

    subgraph "Backend Layer"
        D[WordPress/WooCommerce]
        E[REST API]
        F[Admin Dashboard]
    end

    subgraph "Data Layer"
        G[Cloudflare R2]
        H[Image Optimization]
    end

    A -->|Dynamic Components| B
    B -->|API Calls| E
    E -->|Product Data| D
    D -->|Manage Content| F
    D -->|Images| G
    G -->|Optimized Delivery| H
    H -->|CDN| C
    C -->|Deploy| A

    style A fill:#50B2C0,stroke:#333,stroke-width:2px
    style D fill:#f9f,stroke:#333,stroke-width:2px
    style G fill:#f96,stroke:#333,stroke-width:2px
          

Technical Solution Breakdown

1. Static Frontend

Technology: Astro

  • Zero JavaScript by default
  • Pre-rendered HTML for instant loads
  • SEO-optimized out of the box
  • 90+ Lighthouse scores

2. Dynamic Islands

Technology: React

  • Cart functionality
  • Product search
  • Interactive filters
  • Lazy-loaded only when needed

3. Backend API

Technology: WordPress REST API

  • Product management
  • Order processing
  • Inventory control
  • Familiar admin interface

4. Image Optimization

Technology: Cloudflare R2

  • Auto-resizing
  • WebP conversion
  • CDN delivery
  • Lazy loading

Traffic Routing Architecture

Cloudflare Worker intelligently routes requests between static Astro pages and dynamic WordPress pages:

flowchart TB
    subgraph "User Request"
        A[Browser]
    end

    subgraph "Cloudflare Edge"
        B[Cloudflare Worker]
    end

    subgraph "Static Origin - Astro"
        C[Homepage]
        D[Collection Pages]
        E[Product Pages]
        F[About/Contact]
    end

    subgraph "Dynamic Origin - WordPress"
        G[Checkout]
        H[Cart]
        I[My Account]
        J[Order Tracking]
    end

    A -->|All Requests| B
    B -->|/products/*
/collections/*
/ | C B -->|/collections/*| D B -->|/products/*| E B -->|/about, /contact| F B -->|/checkout/*| G B -->|/cart/*| H B -->|/my-account/*| I B -->|/order/*| J style B fill:#f96,stroke:#333,stroke-width:3px style C fill:#50B2C0,stroke:#333,stroke-width:2px style D fill:#50B2C0,stroke:#333,stroke-width:2px style E fill:#50B2C0,stroke:#333,stroke-width:2px style F fill:#50B2C0,stroke:#333,stroke-width:2px style G fill:#f9f,stroke:#333,stroke-width:2px style H fill:#f9f,stroke:#333,stroke-width:2px style I fill:#f9f,stroke:#333,stroke-width:2px style J fill:#f9f,stroke:#333,stroke-width:2px

Static Pages (Astro)

90+ Lighthouse Score

  • Homepage - Pre-rendered, instant load
  • Collection Pages - Product listings with filters
  • Product Pages - Full product details & gallery
  • About/Contact - Informational pages
  • Blog - Content marketing pages

Built at deploy time, served from CDN edge

Dynamic Pages (WordPress)

Server-Side Rendered

  • Checkout - Payment processing
  • Cart - Session-based cart management
  • My Account - Customer dashboard
  • Order Tracking - Real-time order status
  • Wishlist - Saved items

Requires user session & database access

Why Cloudflare Worker?

Edge Routing

Decisions made at CDN edge, minimal latency

🔀
Seamless Transition

Users don't notice origin switches

🛡️
Origin Protection

WordPress hidden behind Cloudflare

📊
Analytics

Track traffic patterns per origin

Data Flow Architecture

sequenceDiagram
    participant User
    participant Astro
    participant React
    participant WP_API
    participant WooCommerce

    User->>Astro: Request Page
    Astro->>User: Serve Static HTML (instant)

    User->>React: Interact (Add to Cart)
    React->>WP_API: POST /cart/add
    WP_API->>WooCommerce: Process Request
    WooCommerce->>WP_API: Return Cart Data
    WP_API->>React: JSON Response
    React->>User: Update UI

    Note over Astro,WooCommerce: Static pages load instantly
Dynamic features load on-demand

Performance Comparison

Metric Current (WP) Proposed (Astro) Improvement
Lighthouse Performance 40-60 90+ +50-83%
First Contentful Paint 2.5-3.5s 0.8-1.2s -68-70%
Time to Interactive 4-6s 1.5-2s -62-67%
Total Blocking Time 800-1200ms 100-200ms -83-87%
Largest Contentful Paint 3-4.5s 1.2-1.8s -60-67%
JavaScript Bundle Size 800-1200 KB 50-100 KB -91-94%

Current Performance

45

Lighthouse Score

Proposed Performance

92

Lighthouse Score

Build & Deploy Process

graph LR
    A[WP Product Update] -->|Webhook| B[Trigger Build]
    B --> C[Astro Build Process]
    C --> D[Fetch WP API Data]
    D --> E[Generate Static Pages]
    E --> F[Optimize Assets]
    F --> G[Deploy to Cloudflare]
    G --> H[Live Site Updated]

    style A fill:#f9f,stroke:#333,stroke-width:2px
    style H fill:#50B2C0,stroke:#333,stroke-width:2px
          

Automated rebuilds triggered when products are updated in WordPress

Implementation Timeline

Total Duration: 4 weeks

gantt
    title Implementation Phases
    dateFormat YYYY-MM-DD
    section Phase 1
    Astro Setup & WP API Integration :2025-01-06, 5d
    section Phase 2
    Product Pages & Cart Development :2025-01-13, 5d
    section Phase 3
    Checkout & Image Optimization    :2025-01-20, 5d
    section Phase 4
    Testing, QA & Launch             :2025-01-27, 5d
          

Phase 1: Foundation (Week 1)

  • Astro project setup and configuration
  • WordPress REST API integration
  • Development environment setup

Phase 2: Core Features (Week 2)

  • Product listing and detail pages
  • Shopping cart (React Island)
  • Product search and filtering

Phase 3: Integration (Week 3)

  • WooCommerce checkout integration
  • Cloudflare R2 image optimization
  • Webhook-triggered builds

Phase 4: Launch (Week 4)

  • Comprehensive testing and QA
  • Performance optimization and tuning
  • Production deployment

Technical Benefits

🚀 Performance

  • 90+ Lighthouse scores
  • Sub-second page loads
  • Minimal JavaScript overhead

🔍 SEO

  • Pre-rendered HTML
  • Fast Core Web Vitals
  • Better search rankings

💰 Cost Efficiency

  • Lower hosting costs
  • Reduced server load
  • Cloudflare free tier

🔧 Maintainability

  • Familiar WordPress admin
  • Clean separation of concerns
  • Easy content updates

📈 Scalability

  • CDN distribution
  • Static file serving
  • No database bottlenecks

🔒 Security

  • WordPress backend isolated
  • Reduced attack surface
  • Static frontend = no PHP exploits

Technology Stack

Frontend

  • Astro - Static site generator
  • React - Dynamic islands
  • TypeScript - Type safety
  • Tailwind CSS - Styling

Backend

  • WordPress - Content management
  • WooCommerce - E-commerce engine
  • REST API - Data interface
  • MySQL - Database

Infrastructure

  • Cloudflare Pages - Hosting & CDN
  • Cloudflare R2 - Image storage
  • GitHub - Version control
  • Webhooks - Auto-deployment