LearnWithShobhan

How to build a YouTube-like video streaming backend on AWS (serverless architecture)

Shobhan Biswas··5 min read
>_From the course VidShare: 109 lessons, lifetime access.

"Build a YouTube clone" is a classic project idea, but most tutorials stop at a form that saves a file. A real video platform has to handle multi-gigabyte uploads, transcoding into several resolutions, a status lifecycle, and search, without a single server to babysit.

This is the architecture we build end to end in the VidShare course. Here's how every piece fits, and why each AWS service is there.

What the app does

Users can search videos, watch them in the resolution they choose, upload their own with a title, description and tags, and see a list of everything they've uploaded.

Wireframe: search results page showing video cards for a cat videos search
Search results. Search is powered by OpenSearch.
Wireframe: video player page with a resolution selector showing 720p
Playback with a resolution switch. MediaConvert produced each version.
Wireframe: upload page with a drag and drop area and title, description and tags fields
Upload: a file plus metadata.

The course focuses on the backend. Every feature is exposed as an API you test with Postman, so you can put any frontend on top.

The architecture at a glance

Architecture

all deployed with AWS CDK

  1. 1

    Request an upload

    The client calls API Gateway. A Lambda saves the video record in DynamoDB and returns a presigned S3 URL.

    API GatewayLambdaDynamoDB
  2. 2

    Upload straight to S3

    The browser uploads the file directly to S3. No server in the middle, no size headaches.

    S3Presigned URL
  3. 3

    Read the metadata

    An S3 event triggers a Lambda that reads resolution and duration with MediaInfo.

    S3 EventsLambda
  4. 4

    Transcode

    MediaConvert creates streaming renditions. EventBridge tells a Lambda when the job finishes.

    MediaConvertEventBridge
  5. 5

    Search and serve

    Videos are indexed in OpenSearch for full-text search and listed through the API.

    OpenSearchGSI queries
ServiceJob in VidShare
API GatewayThe single front door. Hides every backend detail from clients
LambdaAll business logic, written in TypeScript and tested with Jest
S3 (two buckets)One for raw uploads, one for the transcoded videos you stream
DynamoDBVideo metadata and status
MediaConvertTranscodes each upload into multiple resolutions
EventBridgeTells us when a MediaConvert job finishes or fails
OpenSearchFull-text search on title, description and tags
AWS CDKDefines all of the above as code, deployed with one command
Free to watch. Get all 109 lessons →

The API

Two resources cover everything:

Endpoints: GET /search to search videos; /video with GET, PUT, POST and DELETE
The whole public API.
EndpointPurpose
GET /search?q=...Search videos by keyword
GET /videoOne video by ID, or all videos for a user
PUT /videoStart a new upload (returns an upload URL)
POST /videoUpdate a video's metadata
DELETE /videoDelete a video

One design question you'll hit: one Lambda per HTTP method, or one Lambda for all of them? The course builds both shapes and explains the trade-offs, then settles on a single CRUD handler that routes by method.

API Gateway /video with PUT, GET, POST, DELETE each mapped to its own Lambda handler
One handler per method is one option. A single routed CRUD handler is the other.

Following one video through the system

1. Upload request → presigned URL

The client calls PUT /video with the title, description and tags. A Lambda saves the record in DynamoDB with status NOT_UPLOADED, then returns an S3 presigned URL.

The browser uploads the file directly to S3 with that URL. Your API never touches the bytes, so there's no 10 MB API Gateway limit and no paying to move video through Lambda. Full walkthrough: S3 presigned URLs in TypeScript.

2. S3 event → metadata

When the object lands, S3 fires an event that triggers a Lambda. It marks the video UPLOADED, creates a short-lived signed download URL, and runs MediaInfo on it to read the real resolution and duration.

3. Transcode with MediaConvert

Based on that resolution, the Lambda starts an AWS Elemental MediaConvert job that writes several renditions (for example 720p, 360p and 240p) into the output bucket. You never upscale: a 480p upload doesn't get a 1080p version.

Diagram: a 1920x1080 upload produces 1280x720 and 640x360 versions, 854x480 produces 640x360, 426x240 stays 426x240
Choose output resolutions from the input, and never upscale.

4. EventBridge → ready

MediaConvert emits job state changes: PROGRESSING, COMPLETE, CANCELED, ERROR. An EventBridge rule forwards them to a Lambda, which sets the status to PROCESSING, then READY (or ERROR), deletes the raw upload, and indexes the finished video for search.

MediaConvert job states flow into an EventBridge rule that triggers a Lambda function
No polling: EventBridge pushes the job result to a Lambda.

5. Index for search

Ready videos are indexed in OpenSearch, so GET /search?q=funny cat matches words in titles, descriptions and tags. DynamoDB is excellent for lookups by key but isn't a search engine; that's the right split. More on the key design in DynamoDB data modeling explained.

Why serverless for this?

  • No servers to scale. Ten uploads or ten thousand, Lambda, S3 and MediaConvert scale by themselves.
  • Pay per use. Idle costs almost nothing, which suits side projects and early products.
  • Event-driven by design. Each step reacts to the previous one (S3 event, EventBridge rule), so the pieces stay small and testable.
  • Everything is code. With CDK, the whole stack is a TypeScript file in git. Recreate it in another region with one command.

Key takeaways

  • ✓API Gateway is the only door; Lambdas hold the logic.
  • ✓Uploads go straight to S3 with presigned URLs, never through your API.
  • ✓S3 events and EventBridge chain the pipeline with no polling.
  • ✓DynamoDB stores metadata by key; OpenSearch handles full-text search.
  • ✓CDK keeps the entire architecture in code.

Build it yourself

This is a portfolio project that interviewers actually ask about. VidShare walks you through all of it in 109 lessons, with tests and infrastructure as code, from an empty folder to a final end-to-end test. Watch the 5-minute course walkthrough or the free architecture lesson first.

Free download

Linux command line cheat sheet

One printable page: navigation, files, permissions, pipes, processes, scripts and SSH.

Occasional emails with new tutorials and courses. Unsubscribe any time.

Keep reading