Skip to main content

Architecture Overview

Store Shield is a Shopify app that protects online stores from various threats including content theft, bots, spy tools, and fraud. This document provides a high-level view of how the system is designed.

Tech Stack

LayerTechnology
FrontendReact Router 7 (Remix) + Shopify Polaris
BackendRemix server on Fly.io
Edge ProcessingCloudflare Workers
Real-time DatabaseCloudflare D1 (SQLite at edge)
Primary DatabaseSQLite via Prisma (Fly.io)
Theme IntegrationShopify Theme App Extension
External APIsSerpAPI (Google, Amazon, eBay, etc.)

System Diagram

┌─────────────────────────────────────────────────────────────────┐
│ MERCHANT'S STOREFRONT │
│ (Theme Extension: Heartbeat + Pixel Tracking) │
└─────────────────────────────┬───────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│ CLOUDFLARE WORKERS (Edge) │
│ • POST /api/pixels - Receive all tracking data │
│ • POST /api/heartbeat - Sync protection config │
│ • GET /api/check-ip-access - IP/Country blocking │
│ • Real-time aggregation in D1 │
└─────────────────────────────┬───────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│ CLOUDFLARE D1 DATABASE │
│ • Visitor sessions and identities │
│ • Bot/Spy/IP blocking signals │
│ • Daily metrics and aggregations │
│ • Protection configuration cache │
└─────────────────────────────┬───────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│ REMIX APP (Fly.io) │
│ • Shopify embedded admin dashboard │
│ • Fetches analytics from Workers │
│ • Manages scans, billing, alerts │
│ • Background workers for threat scanning │
└─────────────────────────────┬───────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│ PRISMA DATABASE (Fly.io) │
│ • Merchant settings and billing │
│ • Fraud orders │
│ • Phishing/Marketplace scans │
│ • Product scan jobs and results │
│ • Takedown requests │
└─────────────────────────────────────────────────────────────────┘

Key Design Decisions

1. Edge-First Architecture

All real-time protection happens at the edge via Cloudflare Workers. This provides:

  • Low latency: Protection checks happen in under 50ms globally
  • High availability: Cloudflare's edge network ensures uptime
  • Cost efficiency: No server compute for pixel processing
  • Scalability: Handles traffic spikes automatically

2. Dual Database Strategy

We use two databases for different purposes:

DatabasePurposeWhy
D1Real-time events, sessions, analyticsEdge location, fast writes, automatic aggregation
PrismaScans, billing, settingsComplex queries, relationships, transaction support

See Dual Database Strategy for details.

3. Theme Extension for Data Collection

The Shopify Theme App Extension injects JavaScript into merchant storefronts to:

  • Track visitor sessions (fingerprinting)
  • Detect bots and spy tools
  • Enforce content protection (right-click, copy, etc.)
  • Report events to edge workers

4. Background Processing

Long-running tasks like threat scanning happen in background workers:

  • Phishing detection: Scans domain variations for fake sites
  • Marketplace monitoring: Searches for counterfeit listings
  • Image similarity: Compares product images across platforms

Component Responsibilities

ComponentResponsibilities
Theme ExtensionClient-side protection, pixel emission, heartbeat
Cloudflare WorkersPixel ingestion, IP blocking, config serving, analytics API
Remix AppDashboard UI, settings management, worker coordination
Background WorkersPhishing scans, marketplace monitoring, image analysis
Shopify APIsBilling, product data, order webhooks