Skip to content

Pokemon Club is a PoC for an SNS App leveraging a graph database built natively for globally distributed deployment in hyper-scale, with the help of raft consensus algorithm and architecture of shared-nothing

wey-gu/pokemon_club

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Pokemon Club

This is a DEMO Project for:

Today, let's build a new SNS for the Pokemon Trainers, the Pokemon Clubhouse ;)

Pokemon Club is targeting to connect all Pokemon Trainers for their meetup or grouping to fight in certain Pokemon Go Gym.

Like FB or Linkedin, we for sure have the User System with relational DB backed and users metadata of age, avatar, location, and Pokemons she owned, etc. Users as a trainer can create meetups and share posts in Pokemon Club and her friends can get the news feed and comment, join or chat to her.

Apart from the main features, we will only focus on one feature to help trainers explore new friends recommended by the App, based on the Pokemons this trainer owns.

Now we assume either in streaming/ real-time or the batch way, we had put trainer and pokemon relationship in our Nebula Graph DB, and then to create a humble API to get the recommended trainer friends:

/v1/recommended_friends/<user>
     +
     |          +--------------+         +----------------+
     |          |              |         |                |
     +---------->  API Server  +--------->  Nebula Graph  |
                |              |         |                |
                +--------------+         +----------------+

Build and Run

You can run it locally:

pip install -r requirements.txt
export NG_ENDPOINTS="<graphd_host1>:9669,<graphd_host2>:9669,"
gunicorn --bind :$PORT main:app --workers 1 --threads 1 --timeout 60

Or via GCP Cloud Run:

export PROPJECT_ID=<GCP_PROJECT_ID>
# build locally(I know we can/should build in GCP, let's do it locally this time haha) and push to GCP Container Regsitery
docker build -t gcr.io/$PROPJECT_ID/pokemon_club:v1 .
docker push gcr.io/$PROPJECT_ID/pokemon_club:v1

# deploy to Cloud Run
gcloud run deploy pokemon-club-v1 \
    --image gcr.io/$PROPJECT_ID/pokemon_club:v1 \
    --region us-west1 \
    --platform managed \
    --memory 128Mi
# goto Cloud Web Console: https://console.cloud.google.com/run/detail/us-west1/pokemon-club-v1
# Edit and Deploy New Version --> VARIABLES
# add Env VAR: NG_ENDPOINTS with Value: <public_graphd_host1>:9669
# click Deploy

Verify it

$curl https://pokemon-club-v1-****.a.run.app/v1/recommended_friends/Tom | jq
[
  "Sue",
  "Wey",
  "Jerry"
]

About

Pokemon Club is a PoC for an SNS App leveraging a graph database built natively for globally distributed deployment in hyper-scale, with the help of raft consensus algorithm and architecture of shared-nothing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published