|
| 1 | +# Getting started with developing for the Critter Capture Club |
| 2 | + |
| 3 | +Prerequisites: |
| 4 | + |
| 5 | +- Clone the repo |
| 6 | +- Ensure you have `pnpm` installed |
| 7 | +- Run `pnpm install` to install the dependencies |
| 8 | + |
| 9 | +To get started with development, you have a couple options. |
| 10 | + |
| 11 | +## UI only development |
| 12 | + |
| 13 | +If you're interested on working on the UI, you can use the production API by default. |
| 14 | + |
| 15 | +Run `pnpm --filter=@critter/ui start` to start the development server and point your browser to http://localhost:5173. Make any changes you'd like and submit a PR for it! |
| 16 | + |
| 17 | +## UI & API development |
| 18 | + |
| 19 | +If you're interested in working on both the UI and API, there are a couple more steps to complete. |
| 20 | + |
| 21 | +- Ensure you have `docker` installed and running on your machine |
| 22 | +- You will need to copy the `src/services/api/.env.example` file to `src/services/api/.env` and supply the correct environment variables. |
| 23 | + |
| 24 | +### Variables you will need to change |
| 25 | + |
| 26 | +- `TWITCH_CLIENT_ID` |
| 27 | +- `TWITCH_CLIENT_SECRET` |
| 28 | +- `TWITCH_USERNAME` |
| 29 | + |
| 30 | +Go to the [Twitch Developer Dashboard](https://dev.twitch.tv/console) and create a new application to get your `TWITCH_CLIENT_ID` and `TWITCH_CLIENT_SECRET`. Ensure that you set the redirect URL to `http://localhost:35523/auth/redirect` & `http://localhost:35523/admin/redirect`. |
| 31 | + |
| 32 | +You also need to specifiy the username of the bot you'd like to use in the `TWITCH_USERNAME` variable. For development, it makes sense to use your own. |
| 33 | + |
| 34 | +- `STORAGE_ACCOUNT_NAME` |
| 35 | +- `STORAGE_ACCOUNT_KEY` |
| 36 | +- `CONTAINER_NAME` |
| 37 | + |
| 38 | +Currently, we don't support the Azurite emulator for local development, so you'll need to have an Azure storage account and container that you can use. |
| 39 | + |
| 40 | +### Variables you could change |
| 41 | + |
| 42 | +- `JWT_SECRET` |
| 43 | + |
| 44 | +This is the secret that the API uses to sign the JWTs. For local development, you can stick to the default value but know that it makes the token insecure. |
| 45 | + |
| 46 | +- `COMMAND_PREFIX` |
| 47 | + |
| 48 | +This is the prefix that the bot will respond to. If you're developing in a channel with other people/bots, it's a good idea to change this so you don't have commands that conflict with others. |
| 49 | + |
| 50 | +- `CHANNELS_TO_LISTEN_TO` |
| 51 | + |
| 52 | +This is an array of channels that the bot will join and listen to. Probably just stick to your own channel for local development. |
| 53 | + |
| 54 | +### Variables you probably should keep the same |
| 55 | + |
| 56 | +- `UI_URL` |
| 57 | +- `REDIS_HOST` |
| 58 | +- `REDIS_PORT` |
| 59 | +- `REDIS_PASSWORD` |
| 60 | +- `REDIS_SSL` |
| 61 | +- `POSTGRES_USER` |
| 62 | +- `POSTGRES_PASSWORD` |
| 63 | +- `POSTGRES_DB` |
| 64 | +- `POSTGRES_HOST` |
| 65 | +- `HOST` |
| 66 | +- `PORT` |
| 67 | + |
| 68 | +These are all the default values that are used when the local docker compose file is ran. Unless you have a reason to change them, it's best to keep them the same. |
| 69 | + |
| 70 | +### Running the services |
| 71 | + |
| 72 | +In the root of the repo, run `docker compose up` to start the remaining services needed for the API to function. |
| 73 | + |
| 74 | +- Edit the file found in `apps/ui/src/services/backstage/local.ts` and point the `apiBaseUrl` to the API URL you're running locally. (You can probably just uncomment the line.) |
| 75 | + |
| 76 | +You can now make changes to both the UI and API and submit a PR for it! |
| 77 | + |
| 78 | +- Run `pnpm --filter=@critter/api start` to start the API (you can use `pnpm --filter=@critter/api dev` to start the API in "watch" mode.) |
| 79 | +- Run `pnpm --filter=@critter/ui start` to start the UI |
| 80 | + |
| 81 | +### Seeding the database |
| 82 | + |
| 83 | +You will need to seed the database with the correct data. |
| 84 | + |
| 85 | +The most important thing to to set a role for your account so you can access the UI. Create an entry in the `Roles` table, add your username and set yourself as an Admin. (This will be scripted soon.) |
| 86 | + |
| 87 | +### Running the chat service |
| 88 | + |
| 89 | +You will need to authenticate the bot in order for it to connect to Twitch. When running both the UI & the API, go to http://localhost:5173/status and authenticate the bot with the correct credentials. |
0 commit comments