Live website hosted in AWS:  https://cmcc-fantasy-cricket.click/ 

Github repository for UI written in Angular/TS: https://github.com/reazwrahman/fantasy_ui_angular

Github repository for UI facing micro-service: https://github.com/reazwrahman/fantasy_contest_api_new

Github repository for a backend micro-service (ETL): https://github.com/reazwrahman/Fantasy_Cricket_Backend_Lambda

Building My Fantasy Cricket Website: A Journey from Monolithic to Serverless Architecture

As a cricket enthusiast, I’ve always enjoyed playing fantasy cricket with my friends from high school. However, many of the fantasy cricket websites we used initially offered free services but eventually started charging for their features. Not wanting to pay just to enjoy a game we loved, I decided to take matters into my own hands and build a fantasy cricket website myself.

The Initial Build: A Monolithic Application

When I began this project, I didn’t know much about web development, but I was eager to learn. My first version of the site was a monolithic application, and I deployed it on the Heroku platform. Heroku was a great starting point because it allowed me to get my project online quickly. However, after a while, Heroku started charging me $5 a month. This led me to look for a more cost-effective solution, so I decided to migrate my website to AWS, where it now runs with minimal costs—only $0.50 a month for top-level CNAME redirection.

Phase One: Running on AWS with Elastic Beanstalk

The initial AWS deployment involved running my monolithic application on a single EC2 instance. I used AWS Elastic Beanstalk to manage the application, and an RDS MySQL database for storing all the data. While this setup worked, I noticed that the site had slow response times, which affected the user experience. Additionally, the cost of running EC2 and RDS instances 24/7 was higher than I wanted to pay, which prompted me to rethink my architecture.

Phase Two: Transition to a Serverless Architecture

To reduce costs and improve efficiency, I moved away from the EC2 instance and Elastic Beanstalk. Instead, I opted for a serverless architecture using AWS Lambda functions paired with a MySQL database. This setup allowed me to eliminate the need for always-on instances, theoretically reducing costs and improving scalability. However, I soon discovered that the Lambda-based architecture had performance issues, with response times significantly slower than those of the EC2-based setup. This led me to the next phase of re-architecting.

Phase Three: Enhancing Performance with Micro-services

Determined to improve the performance of my site, I further broke down the architecture into smaller components. I replaced the MySQL database with AWS DynamoDB, a NoSQL database known for its speed and scalability. This change, along with optimizing my use of Lambda functions, resulted in a significant improvement in response times. The current version of the website is now lightning fast, providing a much better user experience than before. Also, in this phase I decided to re-architect my source code: I broke down the monolithic application into two separate micro-services. This eliminated the need for real time computation with each user request and allowed me to run the heavy computation on a regular schedule with a different micro-service. This new architecture increased the performance of the website dramatically.

Phase Four: Upgrading the Front-End

While the back-end of the site is now optimized, the next focus was on improving the front-end. The legacy front-end was built using Python Flask, which had served me well for a prototype. However, to enhance the user experience and modernize the interface, redesigned the front-end using HTML, CSS, TypeScript, and Angular. The goal was to keep Flask as the back-end REST API while using Angular for a more responsive and interactive user interface.

Conclusion

This journey of building my fantasy cricket website has been a tremendous learning experience. From starting with a monolithic application to migrating to a serverless architecture and optimizing with DynamoDB, I’ve learned a lot about web development, cloud architecture, and performance optimization. I’m excited to continue enhancing the site, making it a top-notch platform for fantasy cricket enthusiasts like me and my friends.