
Figure: Architecture Batch-base Clickstream Analytics Platform.
ClickSteam.NextJShttps://main.d2q6im0b1720uc.amplifyapp.com/clickstream-http-apiSBW_EC2_WebDB (Public Subnet)SBW_EC2_WebDB in public subnet SBW_Project-subnet-public1-ap-southeast-1a5432clickstream_web (schema public)Tables include (simplified):
usersproductsordersorder_itemsinventoryThe Amplify app connects via Prisma using DATABASE_URL to this EC2’s public endpoint.
In a stricter production design, this OLTP DB would typically be on Amazon RDS in private subnets behind an API layer. For this workshop, we accept a public EC2 DB to keep the focus on the analytics side.
clickstream-http-apiPOST /clickstreamclickstream-lambda-ingestclickstream-lambda-ingestclickstream-s3-ingest using a path like:events/YYYY/MM/DD/event-<uuid>.jsonIAM for this function is scoped down to:
s3:PutObject on clickstream-s3-ingestclickstream-s3-ingestap-southeast-1 (Singapore)events/YYYY/MM/DD/event-<uuid>.jsonA separate bucket, clickstream-s3-sbw, hosts website assets (product images, static files) and is not used for raw clickstream events.
SBW_EC2_ShinyDWH (Private Subnet)SBW_Project-subnet-private1-ap-southeast-1aAmazonSSMManagedInstanceCoreOn this instance:
PostgreSQL Data Warehouse
clickstream_dw (schema public)clickstream_events with fields:event_id, event_timestamp, event_nameuser_id, user_login_state, identity_source, client_id, session_id, is_first_visitcontext_product_id, context_product_name, context_product_category, context_product_brand, context_product_price, context_product_discount_price, context_product_url_pathR Shiny Server
3838sbw_dashboardhttp://localhost:3838/sbw_dashboardSBW_Lamda_ETL (VPC-Enabled)SBW_Project-subnet-private1-ap-southeast-1asg_Lambda_ETLDWH_HOST, DWH_PORT=5432, DWH_USER, DWH_PASSWORD, DWH_DATABASE=clickstream_dwRAW_BUCKET=clickstream-s3-ingestAWS_REGION=ap-southeast-1The ETL Lambda:
clickstream-s3-ingest/events/YYYY/MM/DD/clickstream_eventsSBW_ETL_HOURLY_RULErate(1 hour)SBW_Lamda_ETL10.0.0.0/1610.0.0.0/20 – SBW_Project-subnet-public1-ap-southeast-1a (OLTP EC2)10.0.128.0/20 – SBW_Project-subnet-private1-ap-southeast-1a (DW, Shiny, ETL)Public Route Table
10.0.0.0/16 → local0.0.0.0/0 → Internet GatewayPrivate Route Table
10.0.0.0/16 → local0.0.0.0/0 to IGW or NAT GatewayKey decision: No NAT Gateway.
Private components (DW, Shiny, ETL) reach S3 via the Gateway Endpoint, and are managed via SSM Interface Endpoints.
clickstream-s3-ingest from ETL Lambda and DW EC2.com.amazonaws.ap-southeast-1.ssmcom.amazonaws.ap-southeast-1.ssmmessagescom.amazonaws.ap-southeast-1.ec2messagesThese enable SSM Session Manager traffic to stay within AWS private networking.
sg_oltp_webDB5432/tcp from Amplify / admin IPs22/tcp from admin IP (optional; can be replaced by SSM)sg_analytics_ShinyDWH5432/tcp from sg_Lambda_ETL3838/tcp for Shiny (accessed via SSM port forward only)sg_Lambda_ETLsg_analytics_ShinyDWH on 5432sg_ec2_VPC_Interface_endpoint_SSM443/tcp from private subnets for SSM endpoints