SPOT Setup Quickstart
To run SPOT, you need a The Blue Alliance API Key, a MongoDB server, and a server running SPOT. The following sections describe how to set up the various components needed to run SPOT in different environments.
SPOT Server Setup
There are a few ways to set up the SPOT server. You can follow one of the below guides or host it yourself. If you’re looking to get SPOT up and running as fast as possible, follow the Glitch SPOT Server Setup. For development and testing, it’s recommended to follow the Local SPOT Server Setup.
Glitch SPOT Server Setup (video tutorial)
- Go to glitch.com and create an account.
- Once you have an account, in the top right corner of the screen, click “New Project” then “Import from GitHub”. Paste “https://github.com/HuskieRobotics/SPOT” as the URL for your repository.
- Glitch should automatically download all required dependencies and start your app. To view it, click the “Share” button in the top right corner of the screen, then click the “Live
- Site” link. This will copy it to your clipboard, so paste it into a web browser to navigate to your app.
- If you haven’t set up a config.json file yet, SPOT will display the setup form, where you can enter your MongoDB Database URL and other required information to set up SPOT.
Amazon Web Services SPOT Server Setup
- Browse to Huskie Robotics SPOT 1.0.1 AMI and click on the "Launch Instance" button to create a new EC2 instance.
- Don't immediately "Review and Launch"; instead, step through the wizard so you can open ports for HTTP and HTTPS.
- Generate a key pair for this EC2 instance. Download and save the private key, which is needed to connect to the instance in the future.
- After the EC2 instance is running, click on the Connect button in the EC2 Management Console for instructions on how to ssh into the instance.
- In the EC2 instance, edit /etc/nginx/sites-enabled/spot and specify the domain name of your server. For example:
server_name scouting.yourdomain.com; - Restart the nginx server:
sudo service nginx reload - Get and install certificates via certbot:
sudo certbot --nginx - Test automatic renewal of certificates:
sudo certbot renew --dry-run - Restart the node server:
sudo pm2 restart app - In a browser, connect to the domain for your server as specified in step 5 and complete the first-run configuration.
- When specifying "The MongoDB Connection URL for your database", use:
mongodb://localhost:27017/spotDatabase?retryWrites=true&w=majority - The MongoDB superuser password is 3061HuskieRoboticsSPOT
Local SPOT Server Setup (Windows)
- Download Node.js
- Clone the project (using git through the command line or a GUI like GitHub Desktop or VS Code)
- Inside of the project directory, which is the root directory of the cloned project, install node dependencies by running `npm i`
- To start SPOT, run `npm start` in the project directory.
- Once you do this, you should be able to navigate to SPOT by entering http://localhost:8080/ in a web browser.
- If you haven’t set up a config.json file yet, SPOT will display the setup form, where you can enter your MongoDB Database URL and other required information.
Config Setup
When you first launch SPOT, it should redirect you to a configuration screen. Here, you should input your Database URL, The Blue Alliance API Key and Match Key, and the event number for your team. When you click submit, the app will validate your data and then create a “config.json” file in the config/ folder with the information you inputted. To edit your configuration, you can navigate to /setup on the app (recommended) or edit the config.json file.
The Blue Alliance Setup
For matches to load into the admin page automatically, you need to obtain a The Blue Alliance API key.
- Navigate to https://www.thebluealliance.com/account, and create an account if necessary.
- Under the “Ready API Keys” section, create a new API key. Copy this into the setup form.
- You can look up your event’s event key by going to thebluealliance.com and searching for your event name in the upper-right search box. When you reach the event’s page, copy the event key from the URL (https://www.thebluealliance.com/event/2020ilch -> “2020ilch”) and input it into the setup form.
MongoDB Setup
Below are two ways to set up a MongoDB server. You can use the MongoDB Atlas option for both development and production, and it is the recommended way to set up the database.
Hosted MongoDB on MongoDB Atlas (recommended)
- Follow this tutorial through “Create a Database User” to set up a database in MongoDB atlas
- You can name your cluster whatever you want. The default value of “Cluster0” works fine.
- In the left panel, under “Databases” click “Clusters”
- In the menu for the cluster you created, click “Connect” then “Drivers” under “Connect to your application”
- Copy the connection string, replacing <username> and <db_password> with your database username and password created in step 1.
- Copy the connection string into the configuration form under Database URL (eg. mongodb+srv://<username>:<db_password>@<url>/databaseName?retryWrites=true&w=majority)
- Your database name (the last part of the string before URL parameters) can be anything. By default, it is “myFirstDatabase”
Local MongoDB on Windows 10
- Download MongoDB Community Server (5.0.6)
- Open the installer
- Choose “Complete” as the setup type
- Select “Install MongoDB as a Service”
- Select “Install MongoDB Compass” if you want MongoDB compass, a tool that lets you explore your database (selected by default).
- Install MongoDB Community Server
- If you don’t want the MongoDB server running at all times, follow these instructions
- Open up “Services” by searching “Services” in the start menu or under `Control Panel > Administrative Tools > View local services`.
- Once in the Services menu, find MongoDB Server (MongoDB). Right Click > Properties > Set “Startup Type” to Manual. You will need to navigate to this menu to start and stop the MongoDB server.
- Input Database URL in the setup form as "mongodb://localhost:27017/spotDatabase?retryWrites=true&w=majority" (without the quotes).