Multiplayer Mancala implemented using Elixir/OTP, Phoenix, LiveView, and Rust.
http://www.mancala.brettkolodny.com
This project is made up of three main parts:
- The Phoenix web framework
- An OTP game server
- NIFs written in Rust
Within Phoenix is the code that handles the website's routes, and player authentication, and front end code written with built in Eex templates and LiveView. This code ensures that the player's data is present before they join a game, the game they are creating exists or is available to be created, and then communicates to the game server to dynamically display the current state of the player's game.
The game server is built upon Erlang's GenServer architecture and exposes an api for the code within Phoenix to interact with different game instances in order to update the game based on the player's input. Each time a game is created a new game server is created, and registered within a supervisor process that oversees every game server. This ensures that if a game server were to crash it is restarted without affecting the rest of the application, and that games are deleted after enough time has passed. The game server calls the rust NIFs to determine the new state of the game.
The game logic itself is implemented using Rust NIFs (native implemented functions). This code is responsible for determining the game's state after a player's turn and determining if the game has a winner.
This application is hosted on an AWS EC2 instance.