# Developing Real-Time Insights

Follow these instructions to get started developing on Real-Time Insights.
Real-Time Insights is an mobile application meant to show information about streaming music consumption for Sony Music artists.
The application targets Android 12+ and iOS 14+, distributed through the Play Store and App Store.

These instructions are for macOS - linux users can skip like, half the steps.

Any text `in a code block like this` should be run in a terminal.

If you don't know how to do something, ask in the #rti-dev in Slack.

If there are improvements or pain points, please share that as well.

## Operating System Requirements

If you are using a company laptop, you may need to ask for extra permissions.

- [ ] macOS 12+ or linux 5.4+
- [ ] Ability to install applications

## Setup git and github

We manage code with `git`, and collaborate using github.com.

- [ ] Make a github account
- [ ] Get someone to invite you to [the filtr organization][]
- [ ] Install [homebrew](https://brew.sh)
- [ ] Install git and github desktop `brew install git github`

## Setup XCode

XCode installs some necessary build tools, and the Simulator to test changes without needing a device.

- [ ] Install [XCode from the Mac App Store][]
- [ ] Open XCode and agree to the developer terms of use
- [ ] Open XCode preferences (⌘+,), click on 'Locations', and make sure the command-line tools are set to the correct XCode version

![XCode Location Fix](./docs/xcode-command-line-tools-location.png)

## Get the latest code

- [ ] Clone [filtr/ama-frontend](https://github.com/filtr/ama-frontend)
- [ ] Ask another developer for a copy of their secret .env files
- [ ] Download the files, and move them to the ama-frontend folder - you will need to rename `env` to `.env` because macOS is silly

## Make an Auth0 account

Auth0 is where we have user accounts and management, so you can login to the app.

- [ ] First is getting invited to the **sme-dna** and **prod-dna-apps** Auth0 tenants

Next, make accounts for logging into RTI

- [ ] Make sure your user exists in the **sme-dna** Auth0 tenant
- [ ] Make sure your user has the RtiUser and RtiSuperuser roles

## Run the frontend

This will need to be done every time you open a terminal.

- [ ] Navigate to the ama-frontend folder

  cd ~/Documents/GitHub/ama-frontend

- [ ] Install dependencies (only needs to be run once)

  npm install

- [ ] Load the environment variables (run everytime)

  source .env

- [ ] Run the development server

If you only need to develop the frontend, run

    RELEASE_ENV=development npm run expo -- start

If you are going to be working on the backend and have it running, try

    npm start

- [ ] Scan the QR code - it will prompt to install the Expo Go app if you do not already have it

Congrats! Make yourself a ☕️ and remember to 🙆 once in a while!

[the filtr organization]: https://github.com/filtr
[xcode from the mac app store]: https://apps.apple.com/us/app/xcode/id497799835?mt=12
