Skip to main content

Creating Your Development Setup

This guide discusses setting up the Polar Edge Analytics repository for local development.

Prerequisites

This guide assumes you have the following already set up (TODO: add references on how to get these configured)

  • Node.js installed; we recommend using nvm (MacOS/Linux) or fnm (Windows) to manage your Node.js version
  • pnpm installed
  • Docker Desktop installed

LocalGet SetupScouting

Setting up the Polar Edge Analytics repository requires running a local instance of the database. We currently provide a shell script located at apps/web/lib/database/scripts/db-start.sh to do so, with plans to run this script automatically in the future.

If the repository root directory, run pnpm install to install dependencies across the entire repository. We recommend installing the turbo CLI globally to make running commands easier. This can be done by running pnpm i -g turbo.

ForDeveloping developingapplications often requires the use of environmental variables. These are used to configure various secrets and environment-specific configuration (i.e., is this running on someone's laptop or is it the hosted version of the scouting site,site). In order to prevent API keys from being leaked on the internet, these are stored in a file that is only oneon your machine and not tracked by Git.

A file titled .envenv.example fileexists in the apps/scouting folder. This is currentlya required.template Foryou convenience,can weuse providein creating your .env.local. To create your .env.local, do the following:

  1. Create a copy of the .env.example file withinand rename the copy to apps/web.env.local
  2. directory.
  3. Create a new application in the Discord Developer Portal. After creating the app, go to the tab titled "OAuth2." Copy the contentsclient ofid value, and set DISCORD_CLIENT_ID to this filevalue intoin another calledyour .env.local.

    Click

    the NOTE:"Reset thisSecret" filebutton isin currentlythe unavailable,Discord itDeveloper portal to get the client secret, and do the same. You should beNEVER shortly...

    share
    the

    Setsecret Upvalue.

  4. Your
  5. Still .env.localin

    Therethe areOAuth2 6tab, Valuesadd thatthe youfollowing needURL to putthe inRedirects section: http://localhost:3000/api/auth/callback/discord

  6. Add your .env.localDiscord file. 
    DATABASE_URL=postgres://postgres:postgres@localhost:5432/polar_edge
    AUTH_DISCORD_ID= #application id in discord developer portal
    AUTH_DISCORD_SECRET= #oauth secret in discord developer portal
    AUTH_SECRET= #generate with openssl rand -base64 32 in terminal
    TBA_API_KEY= #api key from tba if using tba features
    ADMIN_USERS= #your_discord_user_name_here

    To get AUTH_DISCORD_ID and AUTH_DISCORD_SECRET:

    1.Gousername to https://discord.com/developers/applications

    2.Click on New Application and Make a New Application

    3.Go to OAuth2

    4.Client ID is found under the Client Information Tab, and Reset Secret for Client Secret.

    To get AUTH_SECRET, go on terminal and run "openssl rand -base64 32 in terminal". Make sure to put this in "".

    To get TBA_API_KEY, go on https://www.thebluealliance.com/account and make a new API Key.

    ADMIN_USERS is your discord username.

    After .env.local is Set Up

    Once dependencies are installed and the .env.local filesfor areADMIN_USERS. configured,This value is shown in the bottom left corner of Discord

This should be all the setup required for everyday development of the scouting application. To get the development server canrunning, befirst runensure via:

you
have Docker running. Running pnpm dev:scouting or turbo dev #--filter ifscouting turbowill CLIlaunch installedthe globallydatabase, pnpmand runstart devup #the ifscouting turboapp.

CLI

Get not installed globally

Basecamp(ing)

WIP, docs coming soon as this is a bit more complicated...