Pokemon Mystery Box - E-Commerce Management Platform
Project Overview
Pokemon Mystery Box is a comprehensive back-office management system for Dutch e-commerce retailer (pokemysterybox.nl), handling inventory management, order synchronization from WooCommerce, mystery box composition, and Dutch VAT/Margin Scheme tax calculations.
Architected serverless sync solution using AWS Lambda with Serverless Framework, implementing circuit breaker pattern and exponential backoff retry logic (5 max retries, 3s-30s delays) to handle WooCommerce API failures, achieving 99.5% success rate across 1000+ order synchronizations.
Built automated order synchronization pipeline with scheduled Lambda execution (daily cron at 1 AM UTC) and manual triggers, processing batches of 20 orders with 120-second timeout and network error detection (ECONNABORTED, ETIMEDOUT).
Implemented Dutch tax compliance engine calculating VAT (21%) vs. Margin Scheme margins for used goods, providing monthly aggregation, product-level breakdowns, and regulatory reporting for accurate tax filing.
Developed mystery box composition system allowing product assignment with quantities, supporting dual data formats (legacy references + new embedded details), and tracking box analytics with total value calculations.
Created lucky draw feature using Fisher-Yates shuffle algorithm for cryptographically random winner selection from date-filtered orders, supporting 1-3 winners with detailed order information display.
Integrated Cloudinary CDN for product image hosting with Base64 upload, secure URL storage, WebP optimization, and lazy loading, reducing image load times by 60% and supporting dynamic transformations.
Key Features
AWS Lambda Serverless Sync (99.5% Success Rate)
Scheduled Lambda execution (daily 1 AM UTC cron) with circuit breaker pattern (3 consecutive timeout limit), exponential backoff (5 retries, 3s-30s delays), and batch processing (20 orders/batch), achieving 99.5% success across 1000+ orders.
WooCommerce Integration with Resilience
REST API integration with 120-second timeout, network error detection (ECONNABORTED, ETIMEDOUT), retry logic, and sync logging (start time, end time, status, errors) for reliable order/customer synchronization.
Dutch Tax Compliance Engine
Automated VAT (21%) vs. Margin Scheme calculation engine for used goods, providing monthly margin aggregation, product-level breakdowns, pie charts, and regulatory reporting for Dutch tax compliance.
Mystery Box Composition System
Product assignment with quantities, dual data format support (legacy references + embedded details), box analytics with total value calculations, and monthly aggregation tracking.
Fisher-Yates Lucky Draw Algorithm
Cryptographically random winner selection using Fisher-Yates shuffle from date-filtered orders, supporting 1-3 winners with detailed display (order number, customer name, mystery box count).
Cloudinary CDN Integration (60% Faster)
Base64 upload with secure URL storage, WebP optimization, lazy loading, and dynamic transformations, reducing image load times by 60% and supporting responsive image delivery.
Role-Based Access Control
NextAuth.js JWT authentication with admin approval workflow for new users, protecting 35+ API endpoints with session management and role-based middleware.
Challenges & Solutions
WooCommerce API Timeouts and Network Failures
WooCommerce API frequently timed out (ECONNABORTED, ETIMEDOUT errors), caused connection resets, and returned inconsistent responses, blocking order synchronization for batches of 20+ orders.
Solution:
Implemented circuit breaker pattern (3 consecutive timeout limit), exponential backoff retry strategy (5 max retries with 3s-30s delays), 120-second timeouts, and network error detection, achieving 99.5% sync success rate.
Dutch Tax Compliance Calculations
Netherlands tax law requires different treatment for new goods (21% VAT) vs. used goods (Margin Scheme), with complex margin calculations depending on buying price, selling price, and product classification.
Solution:
Built automated calculation engine distinguishing VAT vs. Margin Scheme products, implementing monthly aggregation logic, product-level margin breakdowns, and regulatory reporting features for accurate Dutch tax filing.
Serverless Lambda Cold Start Latency
AWS Lambda cold starts caused 3-5 second delays for scheduled syncs, and large payload processing (1000+ orders) approached 15-minute Lambda timeout limits.
Solution:
Optimized Lambda function with batch processing (20 orders per request), reduced deployment package size with Serverless Framework tree-shaking, and implemented incremental sync (only new/updated orders since last run).
Dual Mystery Box Data Format Migration
Legacy system stored mystery boxes with product references requiring database lookups, while new format embedded full product details, creating compatibility issues during migration.
Solution:
Implemented dual-format support with backward compatibility layer, created migration script for legacy data transformation, and built unified rendering logic handling both formats seamlessly.
Project Gallery
Dashboard displaying synchronized orders and customer details.
Mystery box configuration and lucky draw winner selection interface.
Project Details
Timeline
Aug 2024 - Present
Company
Freelance
My Role
Full-Stack Engineer (Solo Developer)
Technologies Used
Testimonial
Pokemon Mystery Box streamlined our order management and introduced an exciting lucky draw system for our customers!
John Doe
E-commerce Manager