Back to projectsAWS SERVERLESS

Nordika Wear E-commerce & AWS Serverless Architecture

High-performance headless platform with visual customizer and corporate backend on AWS Serverless (Lambda + LWA + CloudFront CDN + ECR + Neon PostgreSQL). Asynchronous event-driven SkydropX PRO logistics with atomic DB locking, dual payment rails, and $0.00 USD/mo operational cost.

AWS Lambda Container (Python 3.12)AWS us-east-1
Serverless Technology Stack
19 Technologies

Decoupled cloud infrastructure running Django 6 on lightweight Docker containers with AWS Lambda Web Adapter, Function URLs (TLS 1.3), Neon PostgreSQL PgBouncer pooling, and zero-downtime CI/CD.

AWS LambdaAmazon CloudFrontLambda Async InvocationAWS Lambda Web AdapterAmazon ECRNeon PostgreSQL (PgBouncer)CloudWatch LogsAWS KMS & IAMDockerDjango 6DRFAstro v5React 18SkydropX PRO APIStripe APIMercado PagoResend SMTPWhiteNoiseGitHub Actions
Lambda Web Adapter · Function URLs · NeonFinOps $0.00 / mo
01 — Problem & Constraints
Architecture Audit

Monolithic VPS Limits & Idle Compute Waste

Nordika Wear, an apparel brand specializing in custom products (t-shirts, caps, mugs), needed a storefront where shoppers could upload artwork, position it visually on products before checkout, and get real-time multi-carrier shipping quotes & labels in Mexico (SkydropX PRO) across dual payment rails (Stripe and Mercado Pago). Traditional architectures posed four critical bottlenecks: 1. Idle compute billing: A VPS or PaaS (Render) charges 24/7 regardless of traffic, while closed SaaS platforms like Shopify restrict custom visualizers and local carrier logic. 2. Cold Starts & CDN cookie conflicts: Moving Django to AWS Lambda introduces ~1.5s cold starts on catalog browsing, yet caching the entire API in CloudFront breaks HttpOnly JWT sessions, CSRF protection, and webhooks. 3. Lambda CPU Freeze: AWS Lambda freezes the vCPU immediately upon returning an HTTP response, killing any background threading.Thread—causing payment webhooks to time out if SkydropX label creation runs synchronously. 4. Zombie DB sockets & Read-Only filesystem: Frozen ephemeral containers exhaust PostgreSQL connection pools, the root filesystem is read-only (breaking Django Admin without build-time collectstatic), and heavy SDKs like boto3 (+95 MB) bloat the ECR image.

Serverless Execution Constraints

Function URLs (TLS 1.3) → LWA :8000

ALLOWED

Direct HTTPS endpoint bypassing API Gateway markup ($1.00 USD/million requests saved).

Lambda → Neon PostgreSQL (-pooler)

POOLED

PgBouncer pooler + conn_max_age=0 closes client sockets instantly, preventing zombie connections.

Native Async Invocation (Event) & DB Lock

ACTIVE

Lambda auto-invokes asynchronously (Event) with atomic PostgreSQL lock, decoupling SkydropX from webhooks at $0.00.

CloudFront (2 Behaviors) + X-Origin-Secret

SHIELDED

Caches /api/products/* (<20ms) while forwarding HttpOnly cookies & webhooks on Default (*), blocking direct origin bypass.

Production Serverless EnvironmentAWS us-east-1
02 — Benchmarking & FinOps Metrics
Cold Start ~1.5s

Cold Start Benchmarks & Cost Guardrails

Rigorous verification of latency, concurrency limits, and operational cost elimination under AWS Free Tier and automated container policies.

Monthly Compute Billing$0.00 USD
1,000,000 requests and 400,000 GB-seconds included free each month (Always Free).
Edge Catalog Latency< 20ms
CloudFront CDN micro-caching eliminates cold starts; 1024 MB RAM caps initial cold start to ~1.5s.
Continuous Deployment< 15s
Zero-downtime cutover via GitHub Actions, Amazon ECR and Lambda update-function-code.
Concurrency Kill-Switch & DRF Rate Limiting

DRF AnonRateThrottle: 10 req/min · Emergency Concurrency Kill-Switch: 3s

PgBouncer -pooler · conn_max_age=0SkydropX PRO · Neon PostgreSQL
03 — Serverless Cloud Architecture

Decoupled Infrastructure & Container Execution

Architecture deployed on AWS us-east-1 following the Twelve-Factor App methodology and AWS Well-Architected Framework serverless lens:

AWS Lambda Web Adapter (LWA) & Gunicorn

01
Python 3.12 · Docker · Gunicorn (1w / 1t) · 1024 MB RAM

The official open-source AWS Lambda Web Adapter binary (/opt/extensions/lambda-adapter) translates native Lambda events to standard HTTP directed to Gunicorn (1 worker / 1 thread) on 127.0.0.1:8000, eliminating vendor lock-in and allowing native Django 6 execution.

Amazon CloudFront Edge CDN & Function URLs

02
Edge Micro-caching (<20ms) · Dual Behaviors · Zero Cold Starts

CloudFront CDN distribution with 2 behaviors: /api/products/* cached at the Edge (s-maxage=300) eliminating cold starts on catalog browsing, and Default (*) transparently forwarding HttpOnly cookies, CSRF tokens, and webhooks to Lambda Function URLs with TLS 1.3.

Amazon ECR Automated Lifecycle Rule

03
Up to 2 Active Images (countNumber > 2) · ~115 MB/img

Slim Docker image without C compilers (~115 MB) paired with an automated lifecycle rule expiring older images. Stays well within the 500 MB Free Tier, enables safe rollbacks, and caps post-year cost at ~$0.02 USD/month.

Neon PostgreSQL Serverless + PgBouncer Pooler

04
-pooler Endpoint · conn_max_age=0 · Zero Zombie Sockets

Mitigates Lambda CPU freeze by routing queries through Neon PgBouncer pooled endpoint. Configuring conn_max_age=0 immediately recycles client sockets upon HTTP 200, preventing connection exhaustion.

Asynchronous Event-Driven SkydropX PRO Logistics

05
Lambda Async Event (SigV4 + HMAC) · Atomic DB Lock · Resend

Upon payment confirmation, the webhook invokes the AWS Lambda Control Plane API (X-Amz-Invocation-Type: Event) with a stdlib SigV4-signed HTTP v2 envelope for LWA, returning in < 150 ms. In the background, the worker validates an HMAC-SHA256 signature, acquires an atomic lock in Neon PostgreSQL, and issues the label at $0.00 USD cost.

Headless Frontend on Astro v5 & React Islands

06
Vercel Edge CDN · Interactive Visual Customizer · Nano Stores

Static Catalog pages with near-instant edge loading. Dynamic React islands empower shoppers to upload designs, drag, scale, and preview artwork directly over real apparel mockups with synchronized coordinates.

AWS Lambda · Function URLs · Neon PostgreSQLZero Vendor Lock-in
04 — Architectural Diagrams (6 Views)
6 Diagrams
Tier 1 — Global Topology, Sequence & Edge Routing (2.1 – 2.3)

2.1 — Global Cloud Infrastructure Diagram

End-to-end serverless topology on AWS us-east-1: Frontend on Vercel (Astro/React), Amazon CloudFront Edge CDN (2 behaviors + X-Origin-Secret header), Lambda Function URL (TLS 1.3), AWS Lambda Web Container (1024 MB RAM, LWA :8000, Gunicorn 1w/1t + Django 6.0), Control Plane async self-invocation to the Worker container, Neon PostgreSQL (-pooler), and external services (Stripe, Mercado Pago, SkydropX, Cloudinary, Resend).

Expand Image
2.1 — Global Cloud Infrastructure Diagram
Tier 2 — Container Internals, Dual Security & CI/CD (2.4 – 2.6)

2.4 — Internal Lambda Container & Connection Pooler

Internal anatomy of the AWS Lambda Firecracker microVM (1024 MB RAM / Linux AMD64): JSON v2 event translation via the AWS Lambda Web Adapter extension (/opt/extensions/lambda-adapter) to HTTP 127.0.0.1:8000 targeting Gunicorn (1w/1t) and Django 6.0, paired with conn_max_age=0 and Neon PgBouncer (-pooler, up to 10,000 concurrent connections) to prevent zombie sockets upon CPU freeze.

Expand Image
2.4 — Internal Lambda Container & Connection Pooler
Click or pinch to inspect in full HDFunction URLs TLS 1.3
05 — Production Impact & Findings
9 Results

Empirical Findings & Production Readiness

Verified production metrics achieved after migrating from monolithic infrastructure to AWS Serverless:

  • >AWS cloud compute cost held at $0.00 USD during Free Tier and ~$0.02 USD/month afterwards.
  • >Cold starts completely eliminated on the product catalog via Amazon CloudFront Edge CDN with sub-20ms latency.
  • >Asynchronous SkydropX PRO label generation protected by atomic PostgreSQL lock against duplicate purchases.
  • >Atomic Zero-Downtime deployments executed in under 15 seconds via GitHub Actions and Amazon ECR.
  • >Full end-to-end logistics automation: real-time multi-carrier rates (FedEx, Estafeta, Redpack) and SkydropX label creation.
  • >Robust relational persistence on Neon PostgreSQL with zero zombie sockets via PgBouncer and conn_max_age=0.
  • >Django Admin panel fully operational through CloudFront and Function URLs served with WhiteNoise.
  • >Abuse protection via DRF rate limiting (10 req/min for auth/payments) and a 3-second AWS concurrency emergency kill-switch.
  • >Top Lighthouse performance score and near-instant catalog navigation with Astro SSG Headless architecture.
AWS Free Tier Validated$0.00 USD / mo
06 — Architectural Decisions

Rigorous Engineering Trade-offs

Each technical decision documents conscious trade-offs, cold start mitigations, and database connection pooling guarantees.

1 / 9

AWS Lambda Web Adapter (LWA) vs. Invasive Serverless Frameworks

Instead of coupling code to proprietary libraries like Mangum or Zappa, the official AWS Lambda Web Adapter binary (/opt/extensions/lambda-adapter) was packaged in the Dockerfile. It intercepts Lambda JSON events and proxies them as standard HTTP to Gunicorn (1 worker / 1 thread, optimal for 1 active request per microVM) on 127.0.0.1:8000, allowing Django 6 and DRF to run unmodified with zero vendor lock-in.

Lambda Function URLs with TLS 1.3 vs. Amazon API Gateway

Bypassed Amazon API Gateway to simplify network topology and eliminate the $1.00 USD/million request surcharge. Function URLs deliver native TLS 1.3 endpoints, support up to 6 MB payloads, and are hardened with restricted dual IAM permissions (lambda:InvokeFunctionUrl and lambda:InvokeFunction conditioned with --invoked-via-function-url).

Neon PostgreSQL Serverless & Zombie Connection Elimination

Because AWS Lambda freezes container CPU after returning a response, open TCP connections to PostgreSQL would remain in a zombie state, exhausting database connection limits. This was solved by routing Django through Neon PgBouncer (-pooler) endpoint and enforcing conn_max_age=0 with sslmode=require, closing client sockets immediately.

CPU Freeze, Dual Defense (SigV4 + HMAC) & Atomic DB Lock

AWS Lambda freezes CPU instantly upon response delivery, preventing background threads (threading.Thread). To prevent Stripe/Mercado Pago webhook timeouts, the dispatcher invokes the AWS Lambda Control Plane API (X-Amz-Invocation-Type: Event) with a stdlib SigV4-signed HTTP v2 envelope for LWA, returning in < 150 ms. In the background, the worker validates an HMAC-SHA256 signature with timestamp and acquires an atomic lock in Neon PostgreSQL (shipment_id = "PROCESSING:...") prior to SkydropX label creation.

Amazon CloudFront Edge CDN with Dual Behaviors without Cookie Breakage

To suppress Cold Starts (~1.5s) on catalog browsing, an Amazon CloudFront CDN was placed in front of the Function URL with 2 behaviors: "/api/products/*" with CachingOptimized (s-maxage=300, delivering sub-20ms edge responses) and "Default (*)" with CachingDisabled and AllViewerExceptHostHeader, preserving HttpOnly cookies, CSRF tokens, and webhook HMAC signatures without altering the origin Host header.

FinOps: Amazon ECR Automated Lifecycle Rule for Zero Cost

To prevent unbounded Docker image storage fees in Amazon ECR after the 500 MB Free Tier period, the image was slimmed down without C compilers (~115 MB) and paired with an automated lifecycle policy expiring older images (imageCountMoreThan: 2 -> Expire). ECR retains the latest 2 images for safe scaling and instant rollbacks, capping post-Free Tier storage at ~$0.02 USD/month.

Zero-Downtime CI/CD Pipeline & Decoupled Migraciones

GitHub Actions workflow automates docker buildx (linux/amd64, --provenance=false), pushes to ECR, and triggers aws lambda update-function-code. Existing containers serve inflight traffic while the new container initializes, achieving atomic zero-downtime cutover in < 15 seconds. Django migrations are run decoupled prior to image update against the Neon pooler.

Django Admin Panel & WhiteNoise in a Read-Only Container

Because the root filesystem in AWS Lambda is read-only, build-time dummy environment variables were injected in the Dockerfile to run python manage.py collectstatic safely. In production, WhiteNoise compresses and serves /admin/ static files without S3 bucket dependencies.

Visual Drag & Drop Customizer in an Islands Architecture

Astro v5 frontend embeds dynamic React islands using react-draggable. Shoppers upload artwork, resize, and adjust it over the product canvas, computing normalized coordinates sent to the backend, while Nano Stores keeps the cart synchronized across fast static transitions.

Well-Architected FrameworkTwelve-Factor / Serverless
07 — Production Screenshots

Catalog, Customizer & Checkout

Production interface running on Astro v5 edge network with real-time visual drag-and-drop customization.

Astro v5 · React IslandsVisual Customizer
08 — FinOps & Future Evolution
$0.00 USD / mo

FinOps Economics & Strategic Roadmap

Real production cost breakdown under AWS Free Tier and automated container lifecycle guardrails:

AWS ServiceReal BillCost Guardrail
Amazon CloudFront CDN$0.00 USD1 TB OUT + 10M HTTPS reqs free
AWS Lambda (x86_64)$0.00 USD1024 MB RAM, 29s timeout
Function URLs TLS 1.3$0.00 USDBypasses API Gateway ($1/M)
Amazon ECR Registry$0.00 / ~$0.02countNumber > 2 purge (~115 MB)
Neon PostgreSQL$0.00 USDPgBouncer -pooler
CloudWatch Logs$0.00 USD7-day retention limit
AWS KMS$0.00 USDManaged aws/lambda key
Data Transfer OUT$0.00 USD100 GB Free Tier (Cloudinary media)
  • CloudFront CDN & Edge Micro-caching

    ACTIVE

    Dual-behavior CloudFront distribution live in production: delivers sub-20ms catalog navigation with zero cold starts while preserving HttpOnly cookies and webhooks.

  • Hybrid Async Event Dispatcher & SQS Ready

    ACTIVE

    Native asynchronous event dispatching (Lambda Async Event) with atomic PostgreSQL lock at $0.00; pre-wired to toggle Amazon SQS via a single environment variable.

SQS · CloudFront · Multi-RegionWell-Architected
David_Nicanor.dev

$ status --current Available for hire

Insolus Marca
© 2026 David Nicanor. All rights reserved.
Built with Astro · React · TypeScriptHosted on S3 · CloudFront