High-Level Architecture Overview
Bragabot's architecture is strategically designed to be modular, scalable, and secure, leveraging modern technologies and AWS infrastructure. The system is composed of several key layers, each serving a critical role within the platform's overall operation. This layered approach ensures that Bragabot can scale, deploy, and evolve without disrupting other parts of the system.
The primary layers include:
1. Infrastructure Layer
Virtual Private Cloud (VPC): The VPC serves as the foundational network layer, providing isolated networking for all Bragabot services. It includes both Public and Private Subnets, ensuring secure communication between components.
Internet Gateway and Public Subnet: The Internet Gateway allows communication between instances in the Public Subnet and the internet. The Public Subnet hosts the Elastic Load Balancer (ELB), which distributes incoming traffic to the backend services.
Elastic Load Balancer (ELB): The ELB distributes traffic across multiple EC2 instances in the Private Subnet, ensuring high availability and fault tolerance.
EC2 Instances: These instances host the Docker containers running Bragabot’s microservices. They are deployed within the Private Subnet to protect them from direct internet exposure, enhancing security.
2. Container Orchestration Layer
Deployment and Scaling Management: Docker containers encapsulate Bragabot’s microservices, which are orchestrated by Kubernetes. These containers are deployed across EC2 instances within the Private Subnet of the VPC. Jenkins is integrated into the CI/CD pipeline, automating the build, testing, and deployment processes of these containers. Kubernetes then automates the deployment, scaling, and management of these containers, utilizing the Horizontal Pod Autoscaler (HPA) to adjust the number of pods based on demand.
NGINX Ingress Controller: Manages incoming HTTP/HTTPS traffic, providing SSL termination, load balancing, and routing to the appropriate services within the Kubernetes cluster.
3. Data Layer
Persistent Data Management: MongoDB is used for managing and storing unstructured data, such as user profiles and activity logs. Firebase is utilized for handling media files and other assets. The data layer is hosted within a Private Subnet in the AWS Virtual Private Cloud (VPC) to ensure security and isolation from the public internet.
4. Messaging Layer
Asynchronous Communication: The messaging layer facilitates asynchronous, event-driven communication between microservices. Job queues provided by Telegram are used for scheduling tasks such as notifications, raid management etc.. This layer ensures that the system remains responsive and can handle background tasks without impacting user experience.
5. Microservices Layer
Business Logic Management: The backend, powered by Django, is organized into microservices, each responsible for specific business logic such as user management, tweet forwarding, raid orchestration etc.. These microservices run within containers managed by Docker and are deployed across EC2 instances in a Kubernetes cluster, allowing for independent scaling and deployment.
6. API Gateway
Unified Entry Point: The API Gateway serves as the centralized entry point for all external requests, managing routing, security, and load balancing. It integrates with the Django backend to serve various functionalities, ensuring that only authenticated and authorized requests reach the backend services. The API Gateway also handles rate limiting and request aggregation to maintain system performance.
7. Frontend Layer
User and Administrator Interfaces: The frontend layer is developed using HTML, CSS, and JavaScript, providing responsive and interactive interfaces for both users and administrators. This layer includes the web interface and Telegram bot interactions, facilitating seamless user engagement with Bragabot's core functionalities.
8. Monitoring and Logging Layer
System Visibility and Analysis: The monitoring and logging layer uses tools like Prometheus for collecting metrics, Grafana for visualizing system performance, and the ELK stack (Elasticsearch, Logstash, Kibana) for centralized logging and analysis. This layer ensures that Bragabot's health, performance, and security are constantly monitored, and any anomalies are promptly addressed.
Last updated