Skip to content
fernando.catalan
All projects

WorkWeb · Backend · Cloud

Serverless migration of a graphics editor

I was handed a web app hosted on another platform and had it running in production on AWS within three days: CloudFront, S3, a TypeScript Lambda and DynamoDB, without changing what its users see.

Role
Project and AWS owner. Architecture, backend and infrastructure
Period
Oct 2026 — Nov 2026
Status
In production
Team
Two people. A teammate ported the frontend to React following the migration plan I wrote

Professional project: the name and client details are anonymized. The technical description is real.

Context

It is an app where teachers from a school network build social media graphics from brand templates and submit them for review. The communications team edits them, sends them back with a note or approves them for download.

The original interface and its canvas drawing engine already existed. My job was to move the app to our own infrastructure, rewrite the backend and leave it in a maintainable state.

The problem

The app arrived running on another platform, with managed Redis and file storage. The frontend was a single HTML file of about 1,800 lines, there were no tests or typed validation, and data cleanup depended on a daily cron job.

It had to be hosted on AWS at a limited cost, without exposing photos that may show students, and without changing what teachers see.

What I built

  • A serverless architecture on AWS: CloudFront with a custom domain serves the static site from a private S3 bucket and routes /api/* to a Lambda, uncached.

  • The backend rewritten as a single TypeScript Lambda with a 7-route router and input validation through zod schemas shared by the API and the frontend.

  • Google sign-in and a custom session in a cookie signed with HMAC-SHA256, using the __Host- prefix and constant-time comparison. Permissions are recomputed on every request.

  • The data model in DynamoDB: single table, optimistic concurrency with conditional expressions, TTL for automatic deletion and atomic daily quotas per user.

  • Photos uploaded straight from the browser to S3 with a presigned POST (4 MB max, JPEG only) and read through signed URLs that last 5 minutes.

  • A local server that mounts the same handler with in-memory stores, so development never touches AWS or real data.

  • The 9-stage plan to migrate the frontend to React, plus the contribution guide. The teammate who carried it out merged each stage into develop through their own pull requests, and I merged develop into main.

Architecture

architecture.svgSwipe →

Everything is pay-per-use. The infrastructure is documented resource by resource and the Lambda's role only reaches its table, the photo prefix and its parameter.

  • Client
  • External system
  • Edge and network
  • Data
  • Compute
  • Managed service
  • Client:
    • Browser: teachers · reviewers
    • Google Identity: sign-in
  • Edge:
    • CloudFront: custom domain · ACM
  • Origins:
    • S3 · static site: private bucket
    • Lambda: TypeScript · arm64
  • Data and operations:
    • DynamoDB: single table · TTL
    • S3 · photos: lifecycle rules
    • Parameter Store: SecureString
    • CloudWatch + SNS: log-based alarm

Connections:

  • Browser → Google Identity
  • Browser → CloudFront
  • CloudFront → S3 · static site (OAC)
  • CloudFront → Lambda (/api/* · IAM)
  • Lambda → DynamoDB
  • Lambda → S3 · photos
  • Lambda → Parameter Store
  • Lambda → CloudWatch + SNS

Technical decisions

  1. The Lambda is not public

    The Function URL requires IAM signing and only CloudFront can invoke it, through Origin Access Control. Writes also require the app's own origin, and reserved concurrency caps spending in case of abuse or a bug.

  2. Deletion by configuration, not by cron

    DynamoDB TTL deletes requests after a year, and S3 lifecycle rules delete photos based on their tag: one day if left pending, 120 if used. They replace the previous version's cleanup cron: less code to maintain.

  3. Testing the artifact that ships

    Bundling for Lambda as an ES module with CommonJS dependencies fails in ways unit tests cannot see. CI loads the bundle the same way Lambda does, and checks that the test-only sign-in never makes it into the zip.

  4. Migrating without changing what users see, and proving it

    The plan required the new React page to be identical to the old one. CI compares 30 graphics and 29 screens pixel by pixel against references generated from the original page, with zero tolerance.

  5. Counting errors in the logs

    Lambda's error metric does not see errors the API catches and returns as 500s. The alarm is built on a metric filter over the logs and notifies through SNS.

Stack

Backend
  • TypeScript
  • Node.js 22
  • AWS Lambda
  • zod
  • esbuild
  • AWS SDK v3
Data
  • Amazon DynamoDB
  • Amazon S3
Edge and network
  • Amazon CloudFront
  • Origin Access Control
  • ACM
  • Route 53
Security and operations
  • IAM
  • Parameter Store
  • CloudWatch
  • SNS
  • Google Identity
Frontend
  • React 19
  • Vite
  • Canvas API
Quality
  • Vitest
  • Playwright
  • ESLint
  • GitHub Actions

Outcome

  • In production on AWS within three days. The React frontend went live a week later.

  • 65 API test cases, plus the real-bundle test, running in CI alongside typecheck, lint and build.

  • Inherited bugs fixed along the way: requests with a past date that expired too early and a submit error screen with no retry.

What I learned

  • A Function URL behind CloudFront with OAC requires every POST to carry the SHA-256 of its body in a header. Without it, CloudFront cannot sign the request.

  • A TTL computed from a past publication date would delete the request within hours. Expiry is counted from the later of the publication and creation dates.

  • Development shortcuts must live outside the deployed artifact, and that has to be checked automatically.

  • Some browsers block the third-party cookies the Google Drive picker needs. It is better to say so in the interface than to fail silently.