# dheyyu/text-to-speech-application architecture

> Architecture diagram of the GitHub repository dheyyu/text-to-speech-application, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dheyyu/text-to-speech-application
- Repository: https://github.com/dheyyu/text-to-speech-application

## Overview

This is a serverless text-to-speech narrator. A user enters text and selects a voice in the frontend; it submits them to the configured API endpoint, and the Lambda handler validates the request, asks Polly to synthesize speech, stores the MP3 in S3, and returns a temporary audio URL for playback or download. Terraform provisions the documented Lambda, S3 bucket, and IAM role. The Lambda and frontend behavior is supported by excerpts; infrastructure details and the API Gateway-to-Lambda wiring are documented or inferred only at a high level.

Main entry points: [`lambda/lambda_function.py`](https://github.com/dheyyu/text-to-speech-application/blob/main/lambda/lambda_function.py) (Request handler), [`infra/main.tf`](https://github.com/dheyyu/text-to-speech-application/blob/main/infra/main.tf) (Resource provisioning), [`frontend/script.js`](https://github.com/dheyyu/text-to-speech-application/blob/main/frontend/script.js) (Narrator UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_frontend["Narrator UI<br/>[script.js]"]
end

subgraph group_runtime["Speech generation"]
  node_handler["Request handler<br/>[lambda_function.py]"]
end

subgraph group_provisioning["Cloud infrastructure"]
  node_terraform["Resource provisioning<br/>[main.tf]"]
  node_frontend_infra["Frontend infrastructure<br/>[frontend.tf]"]
end

node_user(("User"))
node_endpoint{{"API endpoint"}}
node_polly{{"Amazon Polly"}}
node_bucket[("Audio bucket")]

node_user -->|"enters text"| node_frontend
node_frontend -->|"submits request"| node_endpoint
node_endpoint -.->|"invokes"| node_handler
node_handler -->|"synthesizes speech"| node_polly
node_handler -->|"uploads audio"| node_bucket
node_handler -->|"returns audio URL"| node_endpoint
node_terraform -->|"provisions"| node_handler
node_terraform -->|"provisions"| node_bucket

click node_frontend "https://github.com/dheyyu/text-to-speech-application/blob/main/frontend/script.js"
click node_handler "https://github.com/dheyyu/text-to-speech-application/blob/main/lambda/lambda_function.py"
click node_terraform "https://github.com/dheyyu/text-to-speech-application/blob/main/infra/main.tf"
click node_frontend_infra "https://github.com/dheyyu/text-to-speech-application/blob/main/infra/frontend.tf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend,node_user toneBlue
class node_handler,node_bucket toneAmber
class node_terraform,node_frontend_infra,node_endpoint toneMint
class node_polly toneIndigo
```

## Components

### User interface

- [Narrator UI](https://github.com/dheyyu/text-to-speech-application/blob/main/frontend/script.js): `frontend/script.js`

### Speech generation

- [Request handler](https://github.com/dheyyu/text-to-speech-application/blob/main/lambda/lambda_function.py): `lambda/lambda_function.py`

### Cloud infrastructure

- [Resource provisioning](https://github.com/dheyyu/text-to-speech-application/blob/main/infra/main.tf): `infra/main.tf`
- [Frontend infrastructure](https://github.com/dheyyu/text-to-speech-application/blob/main/infra/frontend.tf): `infra/frontend.tf`

### Other components

- **User**
- **API endpoint**
- **Amazon Polly**
- **Audio bucket**

## Connections

- User → Narrator UI: enters text (evidence: `frontend/script.js`)
- Narrator UI → API endpoint: submits request (evidence: `frontend/script.js`)
- API endpoint → Request handler: invokes
- Request handler → Amazon Polly: synthesizes speech (evidence: `lambda/lambda_function.py`)
- Request handler → Audio bucket: uploads audio (evidence: `lambda/lambda_function.py`)
- Request handler → API endpoint: returns audio URL (evidence: `lambda/lambda_function.py`)
- Resource provisioning → Request handler: provisions (evidence: `README.md`)
- Resource provisioning → Audio bucket: provisions (evidence: `README.md`)
