Skip to content

hanfeiyu/DOTA2_Wiki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOTA2_Wiki

DOTA2_Wiki is a full-stack application which helps users search the information of DOTA2 heros, items, abilities and famous players, as well as recommend potential suitable Heros based on users' interests.

Users can choose recommended Heros from the recommendation table and store them in the cache.

The cache will not be lost after users logout, but recommendation table will be regenerated everytime when users query for recommendation.

P.S.

DOTA2 is an Action RTS game, developed by Valve Corporation.

All our data is gathered from real DOTA2 data from the DOTA2 game client and official website.

Architecture

DOTA2_Wiki is a full-stack application with server-based frontend and serverless backend.

Cloud Architecture

Environment

DOTA2_Wiki was developed on MacOS, using Eclipse IDE. Dependencies includes Java 11+, PHP 7.3+, Maven 3.6+.

Frontend

Introduction

DOTA2_Wiki frontend is developed using HTML/CSS and PHP/Bootstrap. Source code of frontend can be found under frontend/src.

To make sure PHP files correctly parsed by Apache server, you'll have to check if your Apache server is running, then either reset your Apache server root path to somewhere else or copy frontend folder to your Apache root, /Library/WebServer/Documents for MacOS.

Configuration

For MacOS, simply (re)start Apache server:

sudo apachectl restart

Then copy frontend folder to Apache root path:

sudo cp -r [your_local_DOTA2_Wiki]/frontend /Library/WebServer/Documents

Check if your Apache server working or not by enter the following link in your Browser (Chrome preferred):

localhost/frontend/index.html

If seeing the background, then your frontend configuration is good to go.

Backend

Introduction

DOTA2_Wiki backend is developed using Java 11, Maven 3.6.3. Source code can be found under backend/src/main/java/lambda.

The backend is completely serverless deployed on AWS with multiple AWS services. Before deploying DOTA2_Wiki, you may want to familiarize with them first:

Except for AWS services, DOTA2_Wiki uses SAAF as development/deployment framework. You may also want to familiarize with SAAF as well.

Configuration

Once all the things mentioned above are no longer a problem, you may start backend deployment.

RDS:

Fist set up an Aurora serverless RDS instance and take care of your RDS password. Notice: Type of the RDS instance must be specified as Aurora -> Serverless -> MySql

EC2:

After RDS instance created, you can boot up a EC2 instance with any type (free tier: T2.micro) to create and populate data into RDS database:

chmod 600 [your_pem_file]
ssh -i [your_pem_file] ubuntu@[your_EC2_instance_IP]

sudo apt update && sudo apt install -y mysql-server mysql-client libmysqlclient-dev

Then go on clone DOTA2_Wiki repo:

git clone https://github.com/hanfeiyu/DOTA2_Wiki
cd DOTA2_Wiki

Import Dota2Wiki.sql file into RDS instance. Login your RDS instance using the password you created for RDS instance previously:

mysql -h [your_RDS_endpoint] -P 3306 -u [your_RDS_username] -p [your_RDS_password]
source ~/DOTA2_Wiki/backend/Dota2Wiki.sql;

Lambda:

Let's start with building the generic lambda function package:

cd [your_local_DOTA2_Wiki]/backend
mvn clean -f pom.xml
mvn verify -f pom.xml

Then go to your AWS account and create the following ten lambda function APIs:

DOTA2_Wiki_GetItem	 
DOTA2_Wiki_GetAbility
DOTA2_Wiki_DropCache
DOTA2_Wiki_GetView	 
DOTA2_Wiki_DeleteCache
DOTA2_Wiki_GetPlayer
DOTA2_Wiki_GetRec	 
DOTA2_Wiki_GetCache	 
DOTA2_Wiki_PutCache	 
DOTA2_Wiki_GetHero

For each function:

  1. MUST set functions in the same VPC and sub-net(s) with your RDS instance.
  2. MUST Add four environment variables for each function:
Key Value
DB_ENDPOINT [your RDS endpoint]
DB_NAME Dota2wiki
DB_PASSWORD [your RDS password]
DB_USERNAME [your RDS username]
  1. Set Timeout inside Basic settings to 1+ min.
  2. MUST upload lambda_test-1.0-SNAPSHOT.jar under backend/target and click Save.

You may test each function individually by creating a simple test JSON using Test button, to ensure that all of them work correctly.

API Gateway:

Similar to creating Lambda functions, each funtion will need an API Gateway to route invocations from anywhere in the world outside VPC. You will need to create ten corresponding API Gateways:

DOTA2_Wiki_DeleteCache	
DOTA2_Wiki_DropCache	
DOTA2_Wiki_GetAbility	
DOTA2_Wiki_GetCache		
DOTA2_Wiki_GetHero		
DOTA2_Wiki_GetItem		
DOTA2_Wiki_GetPlayer	
DOTA2_Wiki_GetRec		
DOTA2_Wiki_GetView		
DOTA2_Wiki_PutCache		

Each API Gateway shall:

  1. Select REST API as its API type.
  2. Select POST as its API method.
  3. Have its unique corresponding Lambda function linked.
  4. Save and deploy API.

After all API Gateways deployed, switch to worker.php and find function curlLambda($api). Replace all the $apigateway to the API Gateway that each funtion linked to.

Okay! Now the backend deployment should be done! Enjoy your journey with DOTA2 world!

Reference

Project Github Link

@Developers developed this application with ♥️

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published