A serverless web application to convert written posts into audio files.
The application is composed of a React frontend and a serverless backend. The infrastructure is deployed on AWS utilizing a wide array of AWS services, and is provisioned through Terraform.
-
S3 Static Website: Hosts the frontend, a static website built with React.
-
API Gateway: Acts as a bridge between the frontend and backend, exposing HTTP endpoints for interacting with the application.
It handles two main endpoints:
POST /v1/posts
: Submits a new post to be converted to audio.GET /v1/posts
: Retrieves the list of posts, their statuses and the URL to the audiofile
-
AWS Lambda:
- The
POST
Lambda function handles incoming posts from the API Gateway. It processes each post, assigns a uniquerecord_id
, and stores it in DynamoDB. Additionally, it sends a message to SNS to trigger further processing. - The
convert_to_audio
Lambda function listens for SNS messages and initiates the audio conversion process using Amazon Polly. After the post is converted to audio, the resulting file is stored in an S3 bucket, and the corresponding entry in DynamoDB is updated to reflect the audio file’s availability. - The
GET
Lambda function retrieves post entries from DynamoDB and sends them back to the frontend.
- The
-
SNS (Simple Notification Service): Acts as an intermediary that broadcasts events, like when a new post is submitted, allowing other components (like Amazon Polly Lambda) to be notified.
-
Amazon Polly: Converts the text of the posts into audio files. The converted audio is stored or made accessible for the user to listen to.
-
DynamoDB: A NoSQL database that stores the posts and their metadata, including status, timestamps, and links to the generated audio files.
The infrastructure can be provisioned using Terraform. Ensure your AWS credentials are set up, then run the following commands:
- Initialize Terraform:
terraform init
- Plan and apply the infrastructure:
terraform apply
- Build and Push the frontend
make frontend-build make frontend-push
-
Async Processing:
Use websockets or an asynchronous processing system to notify the frontend when audio generation is complete, improving user experience.
-
CDN Integration:
Use a Content Delivery Network (CDN) such as Amazon CloudFront to serve the frontend for reduced latency and improved load times.
-
User Management:
Integrate Amazon Cognito with API Gateway to manage user authentication and authorization, adding security to user actions.
-
Enhanced CORS Configuration:
Improve CORS security to restrict access to only the frontend domain, enhancing security against cross-origin requests.
This project ist licensed under the Apache License, Version 2.0