This repository contains AWS infrastructure and Lambda functions for a comprehensive audio processing pipeline with AI-powered features, user management, and payment processing capabilities.
The system consists of Lambda functions, containerized applications, Step Functions, API Gateway endpoints, and supporting infrastructure deployed via Terraform.
- start-summary-chain: Initiates the audio processing pipeline
- segment-audio-container: Container-based Lambda for segmenting uploaded audio files
- faster-whisper-container: Container-based Lambda using faster-whisper for audio transcription
- combine-text-segments: Combines transcription segments into cohesive text
- final-summary: Generates AI-powered summaries from transcriptions
- revise-summary: Revises summaries based on user feedback
- session-chat: AI-powered chat interface for user interactions
- campaign-chat: Campaign-specific chat functionality
- init-credits: Initializes user credit accounts
- spend-credits: Handles credit spending transactions
- refund-credits: Processes credit refunds
- create-campaign-index: Creates and manages campaign indices
- html-to-url: Converts HTML content to accessible URLs
- stripeWebhook: Handles Stripe payment webhook events
- migrate-historical-segments.py: Migration script for historical data segments
- Layer Building Scripts: Automated scripts for building Lambda layers
build_layer.sh: Base Python dependencies layer (pydantic, openai, requests, thefuzz)build_faiss_layer.sh: FAISS & NumPy layer used by campaign chat / index functionsbuild_html_layer.sh: HTML processing layer builderbuild_stripe_layer.sh: Stripe integration layer builderbuild_brevo_layer.sh: Brevo (email) API dependencies layer
- Terraform v1.0+
- AWS CLI configured with appropriate credentials
- Docker for building container images
- Python 3.9+ for Lambda functions
- Node.js (if applicable for certain layers)
audio-processing-lambdas/
├── terraform/
│ ├── application/ # Main application infrastructure
│ └── shared/ # Shared resources (ECR, etc.)
├── [function-name]/ # Individual Lambda function directories
│ └── app.py # Lambda handler code
├── [container-name]/ # Container-based Lambda directories
│ ├── container/
│ │ ├── app.py
│ │ └── Dockerfile
│ ├── build.sh
│ └── build_push.sh
└── build_*.sh # Layer building scripts
Run these from the repo root (audio-processing-lambdas/).
# Base Python dependencies (pydantic, openai, requests, thefuzz)
./build_layer.sh
# FAISS + NumPy layer for campaign index/chat
./build_faiss_layer.sh
# HTML processing layer
./build_html_layer.sh
# Stripe integration layer
./build_stripe_layer.sh
# Brevo (email) API dependencies layer
./build_brevo_layer.shNote: Layer zips are written to the repo root and then referenced from
terraform/application/lambda.tf(e.g.,python_dependencies_layer.zip,faiss_dependencies_layer.zip, etc.). Ensure the zips are present before running Terraform.
cd terraform/application
./build_lambdas.sh# For development environment
cd segment-audio-container
./build_push.sh dev
cd ../faster-whisper-container
./build_push.sh dev
cd ..
# For production environment
cd segment-audio-container
./build_push.sh prod
cd ../faster-whisper-container
./build_push.sh prod
cd ..cd terraform/application
terraform init# Plan the infrastructure changes for development
terraform plan -var-file="dev.tfvars"
# Apply the infrastructure for development
terraform apply -var-file="dev.tfvars"# Plan the infrastructure changes for production
terraform plan -var-file="prod.tfvars"
# Apply the infrastructure for production
terraform apply -var-file="prod.tfvars"# Create and switch to a production workspace
terraform workspace new prod
# Use production configuration
terraform plan -var-file="prod.tfvars"
terraform apply -var-file="prod.tfvars"
# Switch back to default (dev) workspace
terraform workspace select defaultThe infrastructure supports multiple environments through .tfvars files:
dev.tfvars: Development environment configurationprod.tfvars: Production environment configuration
- Development: Resources include a
-devsuffix (e.g.,audio-processor-dev) - Production: Resources use the base name without suffix (e.g.,
audio-processor)
- Prerequisites: S3 buckets and DynamoDB tables should be created before deploying this infrastructure
- Security: For production deployments, use AWS Secrets Manager or Parameter Store for sensitive values
- Permissions: Ensure your AWS credentials have necessary permissions for all required resources
- Container Registry: ECR repositories are managed in the
terraform/shared/directory - API Integration: Stripe webhook integration requires proper endpoint configuration
- CloudWatch Logs: Check Lambda execution logs for debugging
- Step Functions: Monitor workflow execution in AWS Step Functions console
- API Gateway: Review API logs and metrics for endpoint performance
- Lambda Metrics: View function metrics in the AWS Lambda console
- Container Logs: Monitor containerized Lambda logs for processing issues
To remove all created resources:
cd terraform/application
# For development environment
terraform destroy -var-file="dev.tfvars"
# For production environment
terraform destroy -var-file="prod.tfvars"
# If using workspaces
terraform workspace select [workspace-name]
terraform destroy -var-file="[environment].tfvars"- Follow the established Lambda function structure
- Update Terraform configurations for new resources
- Test deployments in development environment first
- Update this README when adding new components
See LICENSE file for details.