brightdata-reference-architecture
Implement Bright Data reference architecture with best-practice project layout. Use when designing new Bright Data integrations, reviewing project structure, or establishing architecture standards for Bright Data applications. Trigger with phrases like "brightdata architecture", "brightdata best practices", "brightdata project structure", "how to organize brightdata", "brightdata layout".
What this skill does
# Bright Data Reference Architecture
## Overview
Production-ready architecture for Bright Data scraping systems. Covers project layout, data pipeline design, and integration patterns for Web Unlocker, Scraping Browser, SERP API, and Datasets API.
## Prerequisites
- Understanding of layered architecture
- Node.js/TypeScript project setup
- Database for storing scraped data
## Project Structure
```
my-scraper/
├── src/
│ ├── brightdata/
│ │ ├── proxy.ts # Proxy config helper (zone, country, session)
│ │ ├── client.ts # Axios client with proxy + retry
│ │ ├── browser.ts # Scraping Browser connection manager
│ │ ├── api.ts # REST API client (trigger, snapshot)
│ │ ├── cache.ts # Response cache (LRU + optional Redis)
│ │ └── types.ts # Shared TypeScript interfaces
│ ├── scrapers/
│ │ ├── product-scraper.ts # Domain-specific scraper
│ │ ├── serp-scraper.ts # Search result collector
│ │ └── parser.ts # HTML → structured data (cheerio)
│ ├── pipeline/
│ │ ├── scheduler.ts # Cron-based scraping scheduler
│ │ ├── processor.ts # Raw HTML → clean data
│ │ └── storage.ts # Database/file output
│ ├── webhooks/
│ │ └── brightdata.ts # Webhook delivery handler
│ └── api/
│ ├── health.ts # Health check endpoint
│ └── scrape.ts # On-demand scrape endpoint
├── tests/
│ ├── unit/ # Mocked tests (no proxy needed)
│ ├── integration/ # Live proxy tests
│ └── fixtures/ # Cached HTML for testing
├── config/
│ ├── zones.json # Zone configuration per environment
│ └── targets.json # Target URLs and scraping schedules
└── .env.example
```
## Architecture Diagram
```
┌──────────────────────────────────────────────────────┐
│ API / Scheduler │
│ (On-demand scrape, cron jobs, webhooks) │
├──────────────────────────────────────────────────────┤
│ Scraper Layer │
│ (Product scraper, SERP scraper, custom parsers) │
├────────────┬─────────────────┬───────────────────────┤
│ Web │ Scraping │ SERP / Datasets │
│ Unlocker │ Browser │ API │
│ (Proxy) │ (WebSocket) │ (REST) │
├────────────┴─────────────────┴───────────────────────┤
│ Bright Data Infrastructure Layer │
│ (Proxy config, retry, cache, session management) │
├──────────────────────────────────────────────────────┤
│ Storage / Pipeline │
│ (Database, file output, webhook delivery) │
└──────────────────────────────────────────────────────┘
```
## Key Components
### Step 1: Multi-Product Client
```typescript
// src/brightdata/client.ts
import axios, { AxiosInstance } from 'axios';
import https from 'https';
import { chromium } from 'playwright';
export class BrightDataClient {
private proxyClient: AxiosInstance;
private apiToken: string;
constructor(private config: {
customerId: string;
zone: string;
zonePassword: string;
apiToken: string;
}) {
this.apiToken = config.apiToken;
this.proxyClient = axios.create({
proxy: {
host: 'brd.superproxy.io',
port: 33335,
auth: {
username: `brd-customer-${config.customerId}-zone-${config.zone}`,
password: config.zonePassword,
},
},
httpsAgent: new https.Agent({ keepAlive: true, rejectUnauthorized: false }),
timeout: 60000,
});
}
// Web Unlocker — simple HTTP through proxy
async scrape(url: string, country?: string): Promise<string> {
const response = await this.proxyClient.get(url);
return response.data;
}
// Scraping Browser — Playwright over CDP
async scrapeWithBrowser(url: string, extract: (page: any) => Promise<any>) {
const auth = `brd-customer-${this.config.customerId}-zone-scraping_browser1:${this.config.zonePassword}`;
const browser = await chromium.connectOverCDP(`wss://${auth}@brd.superproxy.io:9222`);
try {
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 });
return await extract(page);
} finally {
await browser.close();
}
}
// Web Scraper API — async bulk collection
async triggerCollection(datasetId: string, inputs: any[]) {
const response = await fetch(
`https://api.brightdata.com/datasets/v3/trigger?dataset_id=${datasetId}&format=json`,
{
method: 'POST',
headers: { 'Authorization': `Bearer ${this.apiToken}`, 'Content-Type': 'application/json' },
body: JSON.stringify(inputs),
}
);
return response.json();
}
}
```
### Step 2: Scraping Pipeline
```typescript
// src/pipeline/scheduler.ts
import cron from 'node-cron';
interface ScrapeJob {
name: string;
urls: string[];
product: 'web_unlocker' | 'scraping_browser' | 'datasets_api';
schedule: string; // cron expression
parser: (html: string) => any;
}
export function startScheduler(jobs: ScrapeJob[], client: BrightDataClient) {
for (const job of jobs) {
cron.schedule(job.schedule, async () => {
console.log(`Running job: ${job.name}`);
if (job.product === 'datasets_api') {
await client.triggerCollection('dataset_id', job.urls.map(url => ({ url })));
} else {
for (const url of job.urls) {
const html = await client.scrape(url);
const data = job.parser(html);
await saveToDatabase(job.name, data);
}
}
});
}
}
```
### Step 3: Environment Configuration
```json
// config/zones.json
{
"development": {
"web_unlocker": "web_unlocker_dev",
"scraping_browser": "scraping_browser_dev",
"api_datasets": true
},
"production": {
"web_unlocker": "web_unlocker_prod",
"scraping_browser": "scraping_browser_prod",
"api_datasets": true
}
}
```
## Decision Matrix
| Scenario | Product | Why |
|----------|---------|-----|
| Simple HTML pages | Web Unlocker | Cheapest, fastest |
| JavaScript SPA | Scraping Browser | Needs browser rendering |
| Search results | SERP API | Pre-parsed JSON output |
| 1000+ URLs one-time | Web Scraper API | Async, handles parallelism |
| Amazon/LinkedIn/etc. | Pre-built Datasets | No code needed |
| Login-required pages | Scraping Browser + sticky session | Session persistence |
## Output
- Multi-product Bright Data client
- Domain-specific scrapers with parsers
- Cron-based scraping pipeline
- Environment-isolated zone configuration
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| Mixed product confusion | Wrong zone for task | Use decision matrix above |
| Circular dependencies | Tight coupling | Keep scraper layer separate from proxy layer |
| Test pollution | Shared mocks | Use dependency injection |
| Config mismatch | Wrong environment | Load zone config from `zones.json` |
## Resources
- [Bright Data Products Overview](https://brightdata.com/products)
- Scraping Browser
- [Web Scraper API](https://docs.brightdata.com/scraping-automation/web-data-apis/web-scraper-api/overview)
- SERP API
## Next Steps
For multi-environment setup, see `brightdata-deploy-integration`.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.