AWS E-Commerce Data Pipeline
Scope note: learning project, not a production system. Built to practice serverless AWS infrastructure and infrastructure-as-code with Terraform.
Goal
Process 540k+ e-commerce transactions through a serverless AWS pipeline — from raw CSV to live JSON endpoints — with all infrastructure defined as Terraform code.
Approach
- Upload the UCI Online Retail dataset (541k transactions, Dec 2010–Dec 2011) to a versioned S3 bucket.
- Run a PySpark job on AWS Glue to clean the data (remove cancellations, invalid rows) and compute 9 aggregation tables written as Parquet.
- Serve results through a Lambda function + API Gateway — public HTTP endpoints returning JSON.
- Define all 15 infrastructure resources in Terraform: one command to deploy, one to tear down.
Guiding questions
- Can a full analytics pipeline run on AWS free tier at ~$0/month?
- Is Terraform practical for managing a small but complete serverless stack?
- How well does PySpark on Glue handle aggregations like RFM segmentation and cohort retention?
Data
- UCI Online Retail Dataset: 541,909 transactions from a UK-based online retailer, 37 countries.
- Pipeline code and Terraform config live in the project repository.
- Live API: 87rc15jlf7.execute-api.eu-west-1.amazonaws.com
Headline numbers
Architecture
▲ all resources managed by Terraform
S3 (raw bucket)Raw CSV (541k transactions) uploaded to a versioned S3 bucket.
AWS Glue (PySpark)PySpark job cleans, casts types, removes cancellations, and computes 9 aggregation tables.
S3 (processed)Results written as Parquet — columnar, compressed, fast to query.
Lambda + API GatewayServerless Python function reads Parquet from S3 and returns JSON via a public HTTP endpoint.
TerraformAll infrastructure defined as code — reproducible, version-controlled, one-command deploy/teardown.
Analytics computed
The PySpark job computes 9 aggregation tables from the cleaned data, grouped into three categories.
Core Metrics
Total revenue, orders, unique customers per market
Revenue and order volume — captures seasonality
Top 20 SKUs by revenue with quantity sold
Customer Analytics
Recency × Frequency × Monetary scoring → Champion, Loyal, At Risk, Lost
What % of each monthly cohort returns in following months
Do 20% of customers drive 80% of revenue?
Behavioral
When do people buy? Revenue by day-of-week and hour
AOV trend — is the business growing value or volume?
Items per order and average revenue per bucket
Live API
The endpoints below hit a real AWS Lambda function that reads Parquet files from S3. Click any endpoint to see live data from the pipeline.
Conclusion
- The PySpark job processes 540k rows and computes 9 analytical views (RFM segmentation, cohort retention, Pareto analysis) served through a serverless API at near-zero cost.
- The entire stack (15 resources) is defined in Terraform — one
terraform applyto deploy, oneterraform destroyto tear down.