Best Way to set up the High-Level Architecture of my Game Site Idea?

Hey, Everyone! I have been loving learning Elixir and finally settled on it being the functional language that I want to get good at and do personal projects with. Now that I have read a couple of books and done a few online courses (all the books and courses were awesome btw!)I want to start my first project!

Now I don’t know if this is the place for this type of question but from what I have seen the elixir community is awesome so please forgive if it’s not. btw if anyone is interested in helping/mentoring that would be much appreciated as well :slight_smile:

The idea I have is to use an umbrella app to create a homepage app and several io type game apps (think slither.io, agar.io, etc.). The homepage will be a liveview that links to each game and has the total players across all games displayed. Meanwhile each game will have its own domain name, its own phoenix app (will likely use sockets and a javascript game framework such as phaser) and be routed to based on the hostname using master proxy.

I have tried to do some research on the best architecture to make this both efficient and maintainable. I made a diagram with some notes below and would love any feedback/advice!

(Sorry for the inconvenience - Just realized my account is too new to upload photos, so the best I can do is post a link to it being hosted elsewhere. For now, I uploaded it to Imgur but let me know if there is a better option!)

Link to diagram on Imgur

1* - GitHub - jesseshieh/master_proxy will route requests to the correct endpoint in the umbrella app based on host name

2* - The homepage will have a live player count of users playing any game within the umbrella. Not sure if this should be requesting the data itself or getting broadcast to it. I believe it is a similar problem to this discussion and what I gathered from Jose’s last response is to use phoenix tracker with the local counters and then have this home page fetch the count directly or from an ets table

3* - Game 1…N will then query the count of players on each server of matching type from the global phoenix tracker state Count ets table (minimal overflow is ok, or try to connect to a full game and upon failure move to next option), then it will either join a server with space or have horde dynamic supervisor register/create a new genserver for it to join.

4* - Upon joining the specific game (channel:topic) the corresponding player count will be incremented via 1…N local counters. Players then play the game and updates are broadcast with pubsub to the connected sockets (core game logic is here)

5* - local counters will manage the game server’s player updates of new players joining or players leaving. At a certain interval, it will sum the count of all players by game and globally which will later be sent to phoenix tracker on an interval (along with individual topic count)

6* - Phoenix tracker will then sync with other nodes, track local counters state, and write to a Counts ets table to be used by the homepage getting total people connected to all games and for new players to see which game servers are able to be connected to or full.