{"id":21526897,"url":"https://github.com/lambdaclass/mirra_backend","last_synced_at":"2025-05-08T03:54:13.610Z","repository":{"id":194402932,"uuid":"690699995","full_name":"lambdaclass/mirra_backend","owner":"lambdaclass","description":"Multiplayer 2D physics engine, matchmaking, market and leaderboard for 2D and 3D Games","archived":false,"fork":false,"pushed_at":"2025-05-07T22:02:51.000Z","size":70224,"stargazers_count":70,"open_issues_count":145,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-08T03:54:04.252Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lambdaclass.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-12T17:38:58.000Z","updated_at":"2025-04-28T15:06:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"fcb4ccca-e1ee-47d7-9860-4c83f13494e1","html_url":"https://github.com/lambdaclass/mirra_backend","commit_stats":null,"previous_names":["lambdaclass/lambda_game_engine","lambdaclass/lambda_backend_game_engine","lambdaclass/mirra_backend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaclass%2Fmirra_backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaclass%2Fmirra_backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaclass%2Fmirra_backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaclass%2Fmirra_backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lambdaclass","download_url":"https://codeload.github.com/lambdaclass/mirra_backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252996331,"owners_count":21837620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T01:47:02.835Z","updated_at":"2025-05-08T03:54:13.603Z","avatar_url":"https://github.com/lambdaclass.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mirra Backend\nMirra Backend is an umbrella project that contains several apps within it.\n\nThe objective is to split the project into multiple applications (modules) based on their responsibilities. This will allow us to add decoupled modules that can be used together without having a dependency between them.\n\n## Setup Guide\n\nThis guide will help you install the necessary tools and run the backend services for the Mirra project.\n\n## 1. Install Nix\n\nRun the following command in the terminal:\n\n```bash\ncurl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install\n```\n\nThe installer will ask you for the sudo password, and then print the details about what steps it will perform to install Nix. You have to accept this to proceed with the installation\n\nMake sure there weren't any errors during the installation and, if there are none, close the shell and start a new one.\n\nTo test if Nix generally works, just run GNU hello or any other package:\n\n```bash\nnix run nixpkgs#hello\n```\n\nIf you see:\n\n```bash\n\u003e Hello, world!\n```\n\nThen Nix has been installed correctly. For more details, check the [Nixcademy installation guide](https://nixcademy.com).\n\n## 2. Install Devenv\n\nNix MUST be installed before devenv (devenv depends on nix).  \nThe following command installs devenv:\n\n```bash\nnix-env -if https://install.devenv.sh/latest\n```\n\nFor devenv to manage caches for you, add yourself to trusted-users in nix conf:\n\n```bash\nsudo su -\nvim /etc/nix/nix.custom.conf\n```\n\nInside Vim, press `i` to edit and add the following line, replacing `your-user` with your actual username:\n\n```bash\ntrusted-users = root your-user\n```\n\n\nSave and exit Vim (`Esc`, then `:wq` and Enter).  \n\n- If you don't know your user, you can type the following in a terminal:\n\n```bash\nwhoami\n```\n\nThen after you're done with Vim, You have to restart the nix-daemon\n\n```bash\nsudo launchctl kickstart -k system/systems.determinate.nix-daemon\n```\n\n## 3. Clone the repository\n\n```bash\ngit clone https://github.com/lambdaclass/mirra_backend.git\n```\n\n## 4. Install the Elixir package manager\n\n```bash\ncd mirra_backend\ndevenv shell\nmix archive.install github hexpm/hex branch latest\n```\n\n## 5. Install Protobuf\n\nProtobuf is used to serialize WebSocket messages. Install it with:\n\n```bash\nbrew install protobuf\nmix escript.install hex protobuf\n```\n\n⚠️ **Note:** If you used `brew`, add the `escripts` folder to your `$PATH` (follow the instructions after installation).\n\n## 6. Install JS Protobuf for the client\n\n```bash\ncd assets\nnpm install google-protobuf\nnpm install -g protoc-gen-js\ncd ..\n```\n\n## 7. Start the applications\n\nTo build and run all the applications, run the following command:\n\nFrom `mirra_backend/` folder, run:\n\n```bash\ndevenv up\n```\n\nIf you want to have access to the Elixir console, instead do:\n\n```bash\ndevenv shell postgres\n```\n\nThen in another terminal:\n\n```bash\ndevenv shell\nmake start\n```\n\n⚠️ **Note:** Make sure you’ve run `devenv up` at least once before executing these commands.\n\n## Applications\n\n- [Arena](#arena)\n- [Game Client](#game-client)\n- [Gateway](#gateway)\n- [ChampionsOfMirra](#championsofmirra)\n- [GameBackend](#configurator)\n\n### Arena\nThis app is responsible for handling the game logic and is composed of 2 parts:\n\n- The management of the game itself, where player connections are established, their actions are received, and events are resolved. For example, in response to a player's move event, this app receives it and communicates with the 2D physics engine to execute it. It is also responsible for sending game updates to clients.\n- A 2D physics engine where entity movements are handled, and collisions between them are checked.\n\nTo run this app individually, you can use the following commands:\n\n```\ncd apps/arena/\nmake deps\nmake start\n```\n\nFor more information, you can read its [documentation](apps/arena/README.md)\n\n### Game Client\nThis app is a representation of the arena using simple 2D shapes and polygons that interact with each other. This provides a developer-friendly way to understand what is happening.\n\nFor now, this client is only connected to the Arena app, but it could be integrated with any other application.\n\nTo run this app individually, you can use the following commands:\n\n```\ncd apps/game_client/\nmake deps\nmake start\n```\n\nFor more information, you can read its [documentation](apps/game_client/README.md)\n\n### Gateway\nReceives messages via websocket and routes them to the corresponding game's application.\n\n### ChampionsOfMirra\nApplication for Champions Of Mirra game. Has modules for:\n  - Battle - Simulates battles. For now, only allows fights between a user and a level from the campaign.\n  - Campaigns - Creates a campaign with customizable difficulty, in the shape of 5 units per level.\n  - Items - Handles logic for Items. Consumes from the Items app for general items logic.\n  - Units - Handles logic for Units. Consumes from the Units app for general items logic.\n  - Users - Handles logic for Users. Consumes from the Users app for general items logic.\n\n### GameBackend\nPersistance layer and shared logic:\n- Users logic that's general among all games. This module is quite incomplete for now, since users are only made of a unique username.\n- Units logic that's general among all games. Defines the schemas for the characters of every game. These act like templates for Units, which are instances of them tied to a user or a campaign level.\n- Items logic that's general among all games. Defines the schemas for the item templates of every game. These act like templates for Items, which are instances of them that belong to a user and can be equipped to a unit.\n\nWhat's important to note is that each game's application decides how to use the functionalities these applications have. For example, take a look at how Champions of Mirra implements `Champions.Units.select_unit/3` and `unselect_unit/2`. For the first one, we have some rules on how and when a unit can be selected, so we check they are met before calling the `GameBackend` app. For the second one, we don't care for the context it is called in, so we just call `GameBackend.Units.unselect_unit/2` instantly. Another game might have different requirements for unit selection/unselection, and it would be handled in its own `NewGame.Units` module.\n\n### Configurator\nThis app is in charge of the configurations. Think either full game config or feature flags for A/B testing\n\nIn it you will be able to create new configurations and decide the default version to be used. Configurations are inmutable to allow rollbacks and easier A/B testing, you can always create a new one based on the default one or one in particular\n\n[Read more](/apps/configurator/README.md)\n\n### Future iterations\nIn future iterations, we will add the following apps:\n\n- Bots\n- Matchmaking\n- Marketplace\n- Chat\n- Inventory\n- Leaderboard\n\nAnd some more.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdaclass%2Fmirra_backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flambdaclass%2Fmirra_backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdaclass%2Fmirra_backend/lists"}