Skip to content

NinePiece2/ESPN-Betting-Website-Prototype-Full-Stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESPN Betting Website Prototype (Full Stack)

Table of Contents

Introduction

The purpose of this project is to create a website from scratch that uses microservice architecture to host the website across multiple applications. This is done using HTML, JSP, Java, CSS, SQL, Docker and Kubernetes to manage different steps in the process. Communication between the applications occurs through REST APIs and XML.

Website Design

The first step in the process was to come up with a topic for the website and ESPN with a betting portion was chosen due to the rising popularity of such services. The next step was to design the website using the website design tools mentioned above to create a website base that is functional on a local machine using Apache Tomcat. This single website was then split into three different applications so that other applications can be made that use the different components and it also makes the overall website easier to modify iteratively as only one microservice would need to be modified at a time instead of one large application. These files can be found in the ProjectFiles folder.


Below is a Use Case Diagram that was created for the website described above:


Below is a Entity Relationship Diagram that was created for the database needed to run the website described above:

Microservice Design

As mentioned previously there were three microservices chosen to create the website:

  • FrontEnd: This microservice handles the GUI portion for the project allowing the user to interact with the other components of the project. This microservice has an Account_ESPN database with an Account table.

  • Information: This microservice handles the information that a user can view on the website. Information included is statistics based on teams, leagues, players, etc. This microservice has an Information_ESPN database and contains Leagues, Teams, and Players tables.

  • Betting: This microservice handles information about bets with regards to ongoing bets, bet amounts, the odds of a bet, what the bet is contingent on and the user that the bet is associated with. This microservice has a Betting_ESPN database with a single table named Betting.

REST API Implementation

REST API is used to allow the FrontEnd microservice to communicate with the information microservice and request information such as information about a league, or the teams in a league. This information is transmitted using XML and the InformationResource.java class which can be seen below:

^This shows the XML output that results from searching for information on the NFL.

^This shows the input that is used to generate the XML output for NFL Teams which can be seen in the NFLTeams.xml file.

The FrontEnd then takes this XML and converts it into an ArrayList of Team object in the Business.java and TeamsXML.java which is then used by the NFLTeams.jsp to show the relevant data to the user.

When it comes to communicating with the Betting microservice a form from the BettingPage.jsp is forwarded to the betting microservice which outputs whether or not the bet was successfully placed and then redirects to the home page of the FrontEnd microservice.

Docker

To deploy the web application that has been created so far Docker was used to create 6 images. The first 3 images were used to host Apache Tomcat instances of the 3 microservices that use a compressed version of the Project Files for each microservice called .war files. The other 3 images were used to host MySQL instances for each microservice so they would have access to their own database as specified in Microservice Design. The files that were used to create the docker images are stored in the DockerFiles folder.

Due to the limitations of Cloudflare the user facing microservices FrontEnd and Betting need to be able to support HTTPS which requires them to have SSL certificates. The certificates were created and both of the images for those microservices were updated to use the certificates and an updated server.xml starting on line 103 that would use HTTPS. For more information view the Dockerfile-frontendservice file.

Kubernetes

To finally deploy the web application Kubernetes was used and a Deployment.yaml was created to use the docker images that were created to create the microservices. There are volume claims done for the MySQL databases so that their data is persistent and the databases are connected to the microservices using environment variables.

Conclusion

To conclude the website was created using a microservice architecture and deployed at espn.ninepiece2.tk/FrontEnd using Kubernetes on my personal server which can be further explained here.

The website that was created is a prototype and other pages can be easily added now that a framework has been created for them. Currently the Home button does not work and will error out however logging in and creating account work as well as the NFL Home and Teams pages and the Betting page after logging in. Other pages may be added at a later time. As the website is running off my personal server it is slow sometimes and does require some patients.