How studyprojectsthb/guessingaverage works
Main Components
• Application Layer:
• Web Frontend: Represent the HTML templates and static resources (CSS, images) that render the game’s interface.
• Controller: Highlight the NumberController that handles GET (displaying the game page) and POST (processing user guesses). Also note that this controller uses GuessingAverageProperties (configuration) and interacts with the core logic.
• Application Runner: Show MyApplicationRunner, which pre-populates data when the application starts.
• Cloud and Deployment Infrastructure:
• Cloud Infrastructure Components (defined in the terraform directory):
▪ Application Load Balancer (ALB/ELB): Receives HTTP requests from end users.
▪ EC2 Instances: Represent the servers running the Dockerized Spring Boot app.
▪ Auto Scaling Group (ASG) & Launch Templates: Manage scaling/updating of instances.
▪ Database (secured by Security Groups): Although not detailed in the file tree, the README mentions a DB secured with specific rules.
▪ Security Groups and Routing: Illustrate the SG for ELB, EC2, and DB as described.
• Continuous Deployment Pipeline:
▪ GitHub Actions: Illustrate the workflow starting with unit/integration tests (using Maven) and building the Docker image.
▪ Webhook and AWS API Gateway: Show that GitHub pushes trigger a webhook.
▪ Lambda Functions & SQS: Detail the sequence where Lambda functions update the EC2 instance, create an AMI, refresh the ASG, and handle retries via SQS in case of concurrent deployments.
Relationships and Data Flow
• User HTTP requests (labeled in green) originating from a standard user’s browser to the ALB and then being routed to EC2 instances.
• Admin SSH access (labeled in red) directly to EC2 instances from the THB network.
• Outgoing internet access from EC2 instances (labeled in orange) when they connect externally.
• In the application layer, connect the components as follows:
• The Controller interacts with the Service Layer.
• The Service Layer communicates with the Data Access Layer to fetch/store NumberEntries.
• The Application Runner initializes data using the same service.
• Configuration properties from application.properties and the GuessingAverageProperties are used across multiple components.
Architectural Patterns and Technologies
• MVC Pattern: Clearly separate the responsibilities of rendering the interface (views/templates), handling user requests (controllers), and processing business logic (services).
• CI/CD Pipeline: Illustrate the role of GitHub Actions, Docker image creation, webhook to AWS API Gateway, subsequent Lambda functions, and the AMI/ASG update process.