neu-cs4530 / spring24-project-team-208

spring24-project-team-208 created by GitHub Classroom
https://coveytownbattleship.onrender.com/
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Covey.Town

Covey.Town provides a virtual meeting space where different groups of people can have simultaneous video calls, allowing participants to drift between different conversations, just like in real life. Covey.Town was built for Northeastern's Spring 2021 software engineering course, and is designed to be reused across semesters. You can view our reference deployment of the app at app.covey.town, and our project showcase (Fall 2022, Spring 2022, Spring 2021) highlight select student projects.

Covey.Town Architecture

The figure above depicts the high-level architecture of Covey.Town. The frontend client (in the frontend directory of this repository) uses the PhaserJS Game Library to create a 2D game interface, using tilemaps and sprites. The frontend implements video chat using the Twilio Programmable Video API, and that aspect of the interface relies heavily on Twilio's React Starter App. Twilio's React Starter App is packaged and reused under the Apache License, 2.0.

A backend service (in the townService directory) implements the application logic: tracking which "towns" are available to be joined, and the state of each of those towns.

Running this app locally

Running the application locally entails running both the backend service and a frontend.

Setting up the backend

To run the backend, you will need a Twilio account. Twilio provides new accounts with $15 of credit, which is more than enough to get started. To create an account and configure your local environment:

  1. Go to Twilio and create an account. You do not need to provide a credit card to create a trial account.
  2. Create an API key and secret (select "API Keys" on the left under "Settings")
  3. Create a .env file in the townService directory, setting the values as follows:
Config Value Description
TWILIO_ACCOUNT_SID Visible on your twilio account dashboard.
TWILIO_API_KEY_SID The SID of the new API key you created.
TWILIO_API_KEY_SECRET The secret for the API key you created.
TWILIO_API_AUTH_TOKEN Visible on your twilio account dashboard.

In addition, you will also need a firebase project. Follow the instructions at https://firebase.google.com/ to create a new project. Once the project is created you need to set the permissions. First go to Firestore Database and then click the rules tab. Set your rules to always allow read, but never allow writes (only the backend is allowed to write). It should look like:

service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow write: if false; allow read: if true } } }

Next go to Authentication, click the settings tab, and then click user actions. Uncheck the boxes for enable create and enable delete. We only want our backend to be able to create users.

Finally, we need to get the admin key for our firebase project. Go to project settings, and then service accounts. Click on generate new private key, and this will download a JSON file containing the service account credentials. Copy all the contents of this file and add it to the .env in the townService directory as follows:

FIREBASE_SERVICE_ACCOUNT=**PASTE_FILE_CONTENTS**

Starting the backend

Once your backend is configured, you can start it by running npm start in the townService directory (the first time you run it, you will also need to run npm install). The backend will automatically restart if you change any of the files in the townService/src directory.

Configuring the frontend

Create a .env file in the frontend directory, with the line: NEXT_PUBLIC_TOWNS_SERVICE_URL=http://localhost:8081 (if you deploy the towns service to another location, put that location here instead)

Running the frontend

In the frontend directory, run npm start (again, you'll need to run npm install the very first time). After several moments (or minutes, depending on the speed of your machine), a browser will open with the frontend running locally. The frontend will automatically re-compile and reload in your browser if you change any files in the frontend/src directory.