Project Description / Goal
The primary objective of this project is to create a serverless application that converts text-based blog posts into audio files (MP3 format) using AWS services. The application supports creating and retrieving posts through a RESTful API while ensuring scalability, minimal operational overhead, and cost-efficiency.
The application workflow includes:
- Accepting new blog posts via a web interface.
- Converting the post text into audio using Amazon Polly.
- Storing the audio in an Amazon S3 bucket.
- Retrieving post information, including links to the audio files, via the API.
Technology Stack
- AWS Lambda: Serverless compute for handling backend logic.
- Amazon DynamoDB: NoSQL database to store post metadata and URLs.
- Amazon API Gateway: RESTful API to expose the application's functionality.
- Amazon Simple Notification Service (SNS): Decouples the process of posting and audio conversion for asynchronous processing.
- Amazon Polly: Text-to-speech service to generate audio files in various languages and voices.
- Amazon S3: Static website hosting and audio file storage.
- Amazon CloudWatch: Monitoring and logging Lambda function performance.
Project Planning / Architecting
The architecture was designed around AWS's serverless offerings to minimize the need for infrastructure management.
Frontend: A static website hosted on Amazon S3 serves as the user interface.
Backend:
- API Gateway routes requests to Lambda functions.
- DynamoDB stores post metadata, including links to generated audio files.
- SNS enables decoupled and asynchronous workflows.
- Polly generates audio, which is stored in an S3 bucket.
Workflow for posting:
- A new post is submitted via the static webpage.
- API Gateway triggers the New Post Lambda function.
- Post data is saved to DynamoDB.
- SNS notifies the Convert to Audio Lambda function, which processes the text into an audio file.
- The audio file is uploaded to an S3 bucket, and DynamoDB is updated with the file's URL.
Workflow for retrieval:
- The user retrieves post details via the API.
- API Gateway triggers the Get Post Lambda function.
- Data is fetched from DynamoDB and returned to the user.
Project Journal / History
- Initial Setup: Defined the problem scope, selected AWS services, and created the static S3 website.
- API and DynamoDB Integration: Developed RESTful API endpoints and linked them with DynamoDB for storing post metadata.
- SNS and Lambda Coordination: Integrated SNS to decouple the posting and audio conversion processes.
- Text-to-Audio Conversion: Implemented Polly for generating audio files from text.
- Testing and Deployment: Conducted functional testing of workflows and deployed the application.
Obstacles
- SNS Message Deduplication: Resolved issues with FIFO SNS topics by enabling content-based deduplication.
- Cross-Origin Resource Sharing (CORS): Ensured proper configurations for seamless interaction between S3-hosted frontend and backend API.
- File Storage and Retrieval: Managed S3 bucket policies for public access and secure audio file hosting.
- Error Handling in Lambda Functions: Added robust logging and exception handling to troubleshoot failures during DynamoDB and Polly interactions.
- Integration Testing: Verified asynchronous processes (SNS to Lambda) and ensured data consistency between DynamoDB and S3.