audio-ui-cf-s3-lambda-cognito

A deprecated serverless personal cloud platform featuring secure audio recording and file management via AWS Cognito, Lambda, S3, and CloudFront.

https://github.com/davidbmar/audio-ui-cf-s3-lambda-cognito  ·  public  ·  shipped

What it is

This project is a serverless web application that provides two main interfaces: a file manager for CRUD operations on S3 storage and an audio recorder for capturing, chunking, and uploading voice memos. It uses AWS Cognito for user authentication and isolation, ensuring each user's data is stored under their unique ID in S3. The architecture relies on Lambda functions for generating pre-signed URLs and managing metadata, with CloudFront serving the static frontend assets.

Features

Quickstart

git clone https://github.com/davidbmar/audio-ui-cf-s3-lambda-cognito.git
cd audio-ui-cf-s3-lambda-cognito
chmod +x step-*.sh
./step-10-setup.sh
./step-20-deploy-lambda.sh
./step-25-update-web-files.sh
./step-45-validation.sh
./step-47-test-apis.sh

Architecture

flowchart TD
    User[User Browser] -->|HTTPS| CF[CloudFront Distribution]
    CF -->|Serves Static Assets| S3Web[S3 Web Bucket]
    User -->|API Requests| AG[API Gateway]
    AG -->|Authorizes| Cognito[AWS Cognito]
    AG -->|Invokes| Lambda[Lambda Functions]
    Lambda -->|Reads/Writes| S3Data[S3 Data Bucket]
    Lambda -->|Generates Pre-signed URLs| S3Data
    User -->|Direct Upload| S3Data

How it's built

The backend consists of Node.js Lambda functions (api/audio.js, api/s3.js, api/memory.js) deployed via shell scripts. The frontend is a React-based SPA using in-browser Babel compilation, served as static HTML/JS files from S3/CloudFront. Infrastructure is managed through a series of numbered shell scripts (step-10 to step-47) that handle AWS CLI commands for setting up Cognito User Pools, Identity Pools, API Gateway, and S3 buckets. Templates are used for web files to inject environment-specific configuration during deployment.

How it runs

sequenceDiagram
    participant U as User
    participant F as Frontend (HTML/JS)
    participant G as API Gateway
    participant L as Lambda (audio.js)
    participant S as S3 Bucket
    
    U->>F: Start Recording
    F->>F: Capture Audio Chunk
    F->>G: Request Pre-signed URL (sessionId, chunkNumber)
    G->>L: Invoke uploadChunk Handler
    L->>L: Validate Cognito Claims & Input
    L->>S: Generate Pre-signed PUT URL
    L-->>G: Return Pre-signed URL
    G-->>F: Return Pre-signed URL
    F->>S: PUT Audio Chunk Directly
    S-->>F: Confirm Upload
    F->>F: Update UI Progress

How to apply & reuse

Clone the repository, configure AWS CLI credentials, and execute the numbered deployment scripts in sequence (step-10 through step-47). After infrastructure deployment, manually create a Cognito user via AWS CLI. Access the application via the provided CloudFront distribution URL for file management or the /audio.html path for recording.

At a glance

CapabilitiesAudio RecordingFile ManagementUser AuthenticationSecure StorageMobile Optimization
ComponentsLambda FunctionsAPI GatewayS3 BucketsCloudFront DistributionCognito User PoolCognito Identity PoolReact Frontend
TechNode.jsAWS LambdaAmazon S3Amazon CloudFrontAmazon CognitoAPI GatewayHTML5 MediaRecorder APIReact
Depends onAWS CLINode.js v14+npmGit
Integrates withAWS CognitoAWS S3AWS LambdaAWS CloudFront
PatternsServerlessPre-signed URLsChunked UploadStatic Site HostingJWT Authentication
Reuse tagsaws-serverlessaudio-recordingcognito-auths3-storagecloudfront-cdndeprecated

Repo hygiene

✓ all on main — nothing unmerged.