How pblanco/safesend works
Main Components
• Client (Frontend): Represented by the React application in the “client” directory. Note that it’s built with Vite and deployed using AWS Amplify.
• AWS Infrastructure (Backend): This includes several AWS services:
◦ AWS S3 Bucket – Stores the files and manages retention policies.
◦ AWS Lambda Functions – Two primary handlers for generating pre-signed URLs:
▪ “get-upload-url” – for uploads.
▪ “get-download-url” – for downloads.
◦ API Gateway – Serves as the RESTful interface to invoke Lambda functions.
◦ IAM Roles/Policies – Manage permissions between services.
• CDK Infrastructure Code: Found in “lib” (safesend-stack.ts) and “bin” which provisions and manages the cloud resources.
Relationships and Data Flow
• Client Interaction:
◦ The client (React) initiates file uploads/downloads by making HTTP requests.
◦ These HTTP calls reach the API Gateway endpoints.
• Backend Processing:
◦ API Gateway routes requests to AWS Lambda functions (get-upload-url or get-download-url).
◦ The Lambda functions use shared common code (from lambda/common) and interact with S3 to generate pre-signed URLs.
◦ The pre-signed URL is returned through API Gateway back to the client.
• CDK Deployment:
◦ The AWS CDK application (including files in “lib” and “bin”) configures and provisions all of the above AWS resources.
◦ This infrastructure code is pivotal in interconnecting components.
Architectural Patterns and Design Principles
• Separation of Concerns:
◦ Clear separation between the frontend (client) and backend (AWS services).
◦ Infrastructure is defined via AWS CDK resulting in reproducible, version-controlled cloud resource management.
• Serverless Design:
◦ Use of AWS Lambda and API Gateway indicates a serverless architecture.
• Security & Scalability:
◦ Use of pre-signed URLs and IAM for secure interactions.
◦ S3 policies (managed via CDK) help ensure file storage security and automated cleanup (expiration policy).