Skip to content

task: Production Test Launch: Phase 1 Validation & Smoke Testing #66

Description

@clduab11

Production Test Launch: Phase 1 Validation & Smoke Testing

Epic Context

This issue implements the critical path toward PriceHawk's first production test launch, focusing on validating core detection accuracy, worker reliability, and notification delivery across the multi-channel architecture. [github](https://github.com/clduab11/pricehawk)

Objectives

  • Validate end-to-end anomaly detection pipeline with real retailer data
  • Confirm BullMQ worker stability under production-like load
  • Verify notification delivery across all 8 channels (Discord, Email, SMS, Telegram, WhatsApp, Twitter/X, Facebook, Webhooks)
  • Establish baseline KPIs for detection latency, false positive rate, and affiliate conversion tracking
  • Deploy containerized stack to Railway staging environment

Technical Scope

1. Pre-Flight Infrastructure Validation

Acceptance Criteria:

  • PostgreSQL connection pooling configured for concurrent workers (min 10, max 30 connections)
  • Redis persistence enabled with AOF for BullMQ job recovery
  • Docker Compose health checks passing for all 6 workers (anomaly-validator, notification-sender, deal-verifier, social-poster, newsletter-digest, telegram-bot)
  • Railway deployment smoke test: verify app + worker containers start successfully
  • Environment variable validation: all required API keys present in .env (OpenRouter, Clerk, Stripe, Twilio, Resend, Telegram)

2. Detection Algorithm Calibration

Acceptance Criteria:

  • Test all 5 anomaly detection methods (Decimal Error, Z-Score, Double MAD, Adjusted IQR, Category Thresholds) against historical pricing dataset
  • Validate category-specific sensitivity tuning:
    • Grocery: 30% threshold
    • Electronics/Computers: 40%
    • Fashion: 60%
    • Home/Toys: 50-55%
  • Measure false positive rate < 15% on test corpus of 100 "normal sale" prices
  • Confirm DeepSeek V3 AI validation reduces false positives by ≥50% in secondary filtering
  • Document detection latency: target <30 seconds from price scrape to anomaly flag

3. Scraping Reliability & Rate Limiting

Acceptance Criteria:

  • Playwright scraper handles JavaScript-heavy sites (Amazon, Best Buy, Walmart) without timeouts
  • Jina Reader API fallback triggers correctly when Playwright fails (timeout >15s or 403 response)
  • Implement exponential backoff for rate-limited endpoints (max 3 retries, base delay 2s)
  • Verify scraper respects robots.txt and avoids triggering bot detection (User-Agent rotation enabled)
  • Test concurrent scraping: 20 products across 5 retailers simultaneously without failures

4. Worker Queue Stability

Acceptance Criteria:

  • BullMQ workers process jobs in FIFO order with <5% queue backlog during peak load
  • Dead letter queue (DLQ) configured for failed jobs after 3 retry attempts
  • Monitor job completion times:
    • Anomaly Validator: <10s median
    • Deal Verifier: <15s median
    • Notification Sender: <5s median
  • Confirm workers auto-scale: test with 50 simultaneous anomalies, verify no job starvation
  • Implement graceful shutdown: workers finish in-flight jobs before terminating (max 30s timeout)

5. Notification Channel Integration Tests

Acceptance Criteria:

  • Discord webhook delivers rich embeds with price charts, affiliate links, and expiration countdown
  • Email via Resend renders HTML template correctly (test in Gmail, Outlook, Apple Mail)
  • SMS via Twilio includes shortened link and retailer name (test with ≤160 characters)
  • Telegram bot /deals command returns last 5 active anomalies with inline buttons
  • WhatsApp template message approved and delivered without delays
  • Twitter/X OAuth posts deals with #PricingError hashtag and affiliate link
  • Facebook Graph API posts to designated page with image attachment
  • Webhook endpoint accepts JSON payload and returns 200 status within 3s

6. Affiliate Monetization Validation

Acceptance Criteria:

  • Amazon affiliate tags correctly injected into product URLs (format: tag=pricehawk-20)
  • Verify click tracking via Stripe Payment Links for subscription tiers (Free, Pro, Elite)
  • Test affiliate link expiration: confirm 24-hour validity window enforced
  • Implement revenue attribution: associate affiliate clicks with user IDs for commission tracking
  • Document conversion funnel: anomaly detected → notification sent → link clicked → purchase attributed

7. Deal Lifecycle & Expiration Logic

Acceptance Criteria:

  • Deal Verifier worker re-scrapes active deals every 30 minutes
  • Auto-expire deals when price returns to within 10% of historical average
  • Send "Deal Expired" notifications to users who subscribed to specific anomaly alerts
  • Test temporal context: anomalies detected during 2-5 AM maintenance window flagged as "low confidence"
  • Verify chart generation: price history visualization includes anomaly marker and confidence score

8. Monitoring & Observability

Acceptance Criteria:

  • Integrate Sentry for error tracking (production environment configured)
  • Set up Grafana dashboard for real-time metrics:
    • Anomalies detected per hour
    • Worker job completion rates
    • Notification delivery success rate per channel
    • API response times (OpenRouter, Jina Reader, Twilio)
  • Configure alerts for critical failures:
    • Worker offline >5 minutes
    • Database connection pool exhausted
    • Redis out of memory
    • False positive rate >25%
  • Implement audit logging: all anomaly detections, notifications, and affiliate clicks persisted to Prisma DB

Testing Strategy

  1. Unit Tests: Validate anomaly detection algorithms in isolation (Vitest framework)
  2. Integration Tests: Test worker queue processing with mocked scraper responses
  3. End-to-End Tests: Simulate live retailer scrape → anomaly detection → notification delivery
  4. Load Tests: Generate 100 concurrent anomalies to stress-test worker scaling
  5. User Acceptance Testing (UAT): Deploy to 5 beta testers, collect feedback on notification UX

Rollout Plan

  1. Day 1-3: Infrastructure setup + worker configuration
  2. Day 4-7: Algorithm calibration + scraping reliability tests
  3. Day 8-10: Notification channel integration + affiliate link validation
  4. Day 11-12: Monitoring dashboards + error alerting
  5. Day 13-14: UAT with beta cohort
  6. Day 15: Production deployment to Railway with 10-retailer watchlist

Success Metrics (KPIs)

  • Detection Accuracy: ≥85% precision (true positives / total flagged anomalies)
  • Notification Latency: <60 seconds from anomaly detection to user notification
  • Worker Uptime: ≥99.5% availability during 7-day test period
  • Affiliate Conversion: ≥3% click-through rate on shared links
  • False Positive Rate: <15% (validated by AI + manual review)

Dependencies

  • OpenRouter API quota sufficient for DeepSeek V3 inference (estimate: 500 requests/day)
  • Railway deployment credits allocated for staging + production environments
  • Twilio SMS credits loaded (minimum $20 for test phase)
  • Stripe test mode configured for subscription tier validation

Documentation Requirements

  • Update docs/core-flow-prod.md with production deployment checklist
  • Document anomaly detection tuning parameters in docs/architecture/detection-algorithms.md
  • Create runbook for worker failures: docs/guides/troubleshooting-workers.md
  • Add monitoring dashboard screenshots to docs/guides/observability.md

Exit Criteria

  • All acceptance criteria met with documented evidence (logs, screenshots, test reports)
  • Zero critical bugs in 48-hour soak test with live retailer data
  • Beta tester feedback average rating ≥4/5 for notification relevance and timeliness
  • Production deployment approved by stakeholders with go/no-go checklist completed

Estimated Effort: 60-80 hours over 15 days
Priority: P0 - Blocks production launch
Labels: production-readiness, testing, infrastructure, monitoring
Assignee: @clduab11
Milestone: Test Launch - Phase 1

This issue provides clear acceptance criteria, measurable KPIs, technical validation steps, and a phased rollout plan to systematically prepare PriceHawk for production deployment while maintaining engineering rigor.

Metadata

Metadata

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions