Project: Audio Notes

A Text-to-Speech Web Application.


About the Project

Context

This project was inspired by an idea found on the ACloudGuru website while studying Terraform and AWS. The initial concept was to create a webpage that allows users to input text, select from available voices, and receive an audio output of the text read in the chosen voice.

Initial Project Overview

The first iteration of the project involved a static website hosted on AWS S3 and delivered through CloudFront.

Workflow

Image 1 - Diagram of the initial version of the project.
Image 1 - Diagram of the initial version of the project.

Creating a Note:

  1. Users input text and select a voice on the website.
  2. The request is sent to API Gateway.
  3. A Lambda function is triggered by the API Gateway
  4. This function writes the text and voice selection to DynamoDB.
  5. The Lambda function also publishes the DynamoDB item ID to an SNS topic.
  6. A second Lambda function, subscribed to the SNS topic, is triggered.
  7. This function requests Amazon Polly to synthesize the audio from the text.
  8. The audio file is stored in an S3 bucket.
  9. The DynamoDB item is updated with the URL of the audio file.

Listing Notes:

  1. Users request the list of notes on the website.
  2. The request is sent to API Gateway.
  3. A Lambda function is triggered by the API Gateway
  4. The Lambda function retrieves items from DynamoDB.

The AWS resources for the ACloudGuru project were created manually in the AWS console. However, to leverage the benefits of Infrastructure as Code (IaC), Terraform was used to automate the creation of these resources.

Benefits of IaC and Terraform

Infrastructure as Code (IaC) allows for the automation of infrastructure deployment, ensuring consistency, accuracy, and speed. Terraform, in particular, provides a declarative approach to defining infrastructure, making it easier to manage and version control. It supports multiple cloud providers and enables the creation of modular, reusable components, leading to efficient and scalable infrastructure management.

Updates and Improvements

The Lambda functions were transitioned from Python to Go. Despite requiring more code, Go offers significantly faster execution, reducing costs and improving response times due to AWS Lambda's billing based on execution time.

First Version Demo

First Version GitHub

Enhanced Project with User Authentication

In addition to the adoption of Terraform and the conversion of Lambda functions from Python to Go, I introduced another significant enhancement to the original project. The subsequent phase of the project incorporated user authentication, which allows the creation of both public and private notes. This was accomplished by utilizing Next.js in conjunction with AWS Amplify and Cognito for authentication, authorization, and user management.

Workflow

Image 2 - Diagram of the final version of the project.
Image 2 - Diagram of the final version of the project.

Creating a Note:

  1. Users access the website hosted on AWS Amplify.
  2. Users can and sign in using Cognito
  3. When a new note is created, it is stored in DynamoDB.
  4. A DynamoDB Stream triggers a Lambda function.
  5. The function publishes a message about the new note to an SNS topic.
  6. A new Lambda function is triggered by the SNS message.
  7. This function requests Amazon Polly to synthesize the audio from the text.
  8. The audio file is stored in an S3 bucket.
  9. The DynamoDB item is updated with the URL of the audio file.

Listing Notes:

  1. Users request the list of notes on the website.
  2. Users can and sign in using Cognito
  3. The Amplify retrieves items from DynamoDB.

Second Version Demo

Second Version GitHub

C4 Model Diagrams

Context Diagram

Image 3 - C4 Model of the final version of the project: Context Diagram.
Image 3 - C4 Model of the final version of the project: Context Diagram.

Container Diagram

Image 4 - C4 Model of the final version of the project: Container Diagram.
Image 4 - C4 Model of the final version of the project: Container Diagram.