- Published on
YANA - Clubhouse-like Voice Chatroom
- Authors
- Name
- Bowen Y
Project Overview
YANA ("You Are Not Alone") is a cloud-based SaaS platform designed to facilitate real-time voice and text chat. Built during the COVID-19 pandemic, YANA enables users to create and join topic-based rooms, fostering meaningful interactions in a virtual space.
Architecture and Tech Stack
The architecture of YANA leverages various AWS services to ensure scalability, security, and efficiency. Here’s a breakdown of the key components:
Front-End:
- Hosted using AWS Amplify for streamlined build and deployment directly from a GitHub repository. Amplify automatically configures CloudFront for global content delivery, providing high availability and performance for the React front-end.
- React.js is used for building the user interface, delivering a responsive and interactive experience.
Back-End (Web):
- Flask serves as the main back-end framework, deployed on EC2 instances within a private subnet for secure communication.
- An Elastic Load Balancer (ELB) distributes incoming traffic among the EC2 instances, ensuring scalability and fault tolerance.
- Amazon DocumentDB is used for persistent data storage, managing user information, chatroom configurations, and other metadata.
- Amazon ElastiCache (likely Redis) provides caching, improving response times for frequently accessed data.
- Socket.IO enables real-time text chat, managing event-driven messages so users can communicate instantly within chatrooms.
- Worker Processes with Celery: Python-based workers using Celery handle background tasks for text chat processing and message queuing. These tasks are managed in a distributed fashion to ensure efficient event handling.
Back-End (Voice):
- Python is utilized for handling real-time voice interactions, integrated with Twilio to manage voice functionality.
- The Elastic Load Balancer (ELB) for the voice service distributes traffic across multiple EC2 instances, ensuring high availability.
- Worker Processes with Celery: Workers are also deployed within the voice back-end, handling Twilio-related tasks such as call setup, monitoring, and processing call events. These workers use Celery to ensure tasks are processed asynchronously, improving responsiveness.
- AWS SQS: Amazon Simple Queue Service (SQS) is used as a message broker for Celery, facilitating reliable task queuing and communication between the application and worker processes.
Supporting AWS Services
To support YANA's functionality and ensure observability, security, and scalability, the following AWS services are employed:
- VPC (Virtual Private Cloud): The infrastructure is hosted within a VPC, with private subnets for back-end services, enhancing security and access control.
- IAM (Identity and Access Management) and Network Firewall: IAM provides access control for AWS resources, while Network Firewall secures the infrastructure.
- Amazon S3: Used for storing static assets, such as profile images or any media uploaded by users.
- CloudWatch and Compute Optimizer: These services are used to monitor application performance, provide insights, and help optimize resource usage and costs.
Implementation Details
1. Modular Microservices Setup with Worker Processes
YANA’s back end is divided into two core services, each with its own worker processes:
- Web Service (Flask): Manages user sessions, room management, and real-time text chat. Celery workers are deployed for handling background tasks like message processing and event handling for chatrooms, ensuring responsiveness and scalability.
- Voice Service (Python with Twilio): Manages voice interactions, allowing users to connect in real-time voice chat rooms. Separate Celery workers handle Twilio tasks, such as setting up calls, monitoring call status, and handling call-related events. This separation improves reliability and offloads processing from the main application.
Each service is deployed on separate EC2 instances within private subnets, with ELBs handling traffic distribution for high availability.
2. Real-Time Communication with Twilio, Socket.IO, and Celery Workers
- Voice Chat: Twilio’s Programmable Voice API is integrated into the Node.js back-end for voice functionality. Celery workers handle call-related events and setup tasks asynchronously through SQS, enabling efficient, non-blocking processing of voice interactions.
- Text Chat: Real-time text chat is implemented using Socket.IO on the Flask back-end, enabling users to exchange messages instantly. Celery workers manage background tasks such as message queuing and event handling, ensuring the system remains responsive under load.
3. AWS SQS as the Task Queue
Amazon SQS acts as the message broker for Celery, queuing tasks and managing communication between the application and worker processes. This setup ensures that tasks for both text and voice chat are processed reliably and in an organized manner, without overloading the main application servers.
4. Enhanced Security with Separate Security Groups
Each service component is assigned specific security groups to control access:
- DocumentDB Security Group: Restricts access to only the web back-end instances that require database access.
- ElastiCache Security Group: Limits access to the web back-end for caching purposes.
- SQS Security Group: Controls access to the SQS queues, allowing only authorized worker instances to connect and process tasks.
This separation improves security by isolating services and allowing fine-grained access control.
Conclusion
By leveraging AWS services like Amplify, EC2, DocumentDB, ElastiCache, and SQS, along with Socket.IO and Twilio, YANA provides a robust, scalable platform for both voice and text-based social interactions. The integration of Celery with Python-based workers ensures efficient background task processing, while SQS as the message broker guarantees reliable task queuing. This setup demonstrates a professional approach to building real-time communication systems that are secure, scalable, and maintainable.