Skip to content

Commit

Permalink
Fix spelling, add music bot
Browse files Browse the repository at this point in the history
  • Loading branch information
Atlinx committed Jul 21, 2023
1 parent da98e4a commit a9101f1
Show file tree
Hide file tree
Showing 23 changed files with 291 additions and 278 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ Available on:
- [Github Pages](https://rucogs.github.io/rucogs-docs)

## Contributing
1. To edit the doucmentation it you'll need [Python](https://www.python.org/downloads/)

1. To edit the documentation it you'll need [Python](https://www.python.org/downloads/)

2. Install mkdocs-material with:
`pip install mkdocs-material`
`pip install mkdocs-material`

3. Running the documentation locally

```bash
> mkdocs serve
```

4. The documentation automatically builds and deploys to Github Pages when you push to the main branch.
```bash
> mkdocs serve
```

4. The documentation automatically builds and deploys to Github Pages when you push to the main branch.
1 change: 1 addition & 0 deletions docs/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ nav:
- website
- backend
- Discord Bot: discord-bot
- Music Bot: music-bot
- DevOps: devops
53 changes: 25 additions & 28 deletions docs/backend/config.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Config

The behaviour of the server is determined by config files located underneath `src/config`. Config files end in `.config.json`, and are automatically ignored by the repository's `.gitignore` to avoid leaking sensitive information into the git commit history.
The behavior of the server is determined by config files located underneath `src/config`. Config files end in `.config.json`, and are automatically ignored by the repository's `.gitignore` to avoid leaking sensitive information into the git commit history.

There are two config files needed:

- `auth.config.json`
- `server.config.json`

Expand All @@ -12,52 +13,48 @@ The repository provides templates files ending in `.config.template.json` for th

- `type` - The type of server this config file is for. It can be set to either `"production"` or `"debug"`. If you are using `"debug"`, make sure to also name the config as `auth.debug.config.json`.
- `rootUsers` - An array of root users that can have complete access to the backend.
- Users are objects with a `username` and a `password`.
- Users are objects with a `username` and a `password`.
- `jwt` - Settings for JSON web tokens. We use JSON web tokens for authentication
- `secret` - A string used to sign a JSON web token. This can be set to anything, but must be kept a secret.
- `secret` - A string used to sign a JSON web token. This can be set to anything, but must be kept a secret.
- `oauth` - Settings for authentication
- `discord` - Settings for discord authentication.
- `stategyConfig`
- `clientID` - Discord OAuth client ID. You can find this on the Discord developers dashboard on the COGS discord account.
- `clientSecret` - Discord OAuth client secret. You ask an existing webmaster for the secret.
- `google` - Settings for google authentication. Even though Google login functionality is implemented in both the backend and the frontend, it is currently unused in favor of only having Discord authentication. Therefore, filling out the google settings is optional.
- `stategyConfig`
- `clientID` - Google OAuth client ID. You can find this on the Google developer dashboard on the COGS google account.
- `clientSecret` - Google OAuth client secret. You ask an existing webmaster for the secret.
- `discord` - Settings for discord authentication.
- `strategyConfig`
- `clientID` - Discord OAuth client ID. You can find this on the Discord developers dashboard on the COGS discord account.
- `clientSecret` - Discord OAuth client secret. You ask an existing webmaster for the secret.
- `google` - Settings for google authentication. Even though Google login functionality is implemented in both the backend and the frontend, it is currently unused in favor of only having Discord authentication. Therefore, filling out the google settings is optional.
- `strategyConfig`
- `clientID` - Google OAuth client ID. You can find this on the Google developer dashboard on the COGS google account.
- `clientSecret` - Google OAuth client secret. You ask an existing webmaster for the secret.

## Server Config

- `type` - The type of server this config file is for. It can be set to either `"production"` or `"debug"`. If you are using `"debug"`, make sure to also name the config as `server.debug.config.json`.
- `mongoDB` - MongoDB settings
- `url` - Connection string to MongoDB database.
- `dbName` - Name of the database. For production it should be `maindb`.
- `url` - Connection string to MongoDB database.
- `dbName` - Name of the database. For production it should be `maindb`.
- `nodemailer` - Nodemailer settings. See the [Nodemailer section](#nodemailer) for more information.
- `backendDomain` - The domain for the backend.
- `frontendDomain` - The domain for the frontend.

### Nodemailer

For debugging purposes you can use a free platform like [mailtrap](https://mailtrap.io/) to preview emails.
For debugging purposes you can use a free platform like [mailtrap](https://mailtrap.io/) to preview emails.

```yaml
"nodemailer": {
"nodemailer":
{
"host": "smtp.mailtrap.io",
"auth": {
"user": "",
"pass": ""
},
"port": 2525
}
"auth": { "user": "", "pass": "" },
"port": 2525,
}
```

For the release config you can use Gmail transport settings, so the emails are sent using our noreply gmail account:

```yaml
"nodemailer": {
"nodemailer":
{
"service": "Gmail",
"auth": {
"user": "[email protected]",
"pass": ""
}
}
```
"auth": { "user": "[email protected]", "pass": "" },
}
```
4 changes: 2 additions & 2 deletions docs/backend/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ Tools:
- MongoDB - Our database.
- GraphQL - An alternative communication method to REST, that allows users of the API to query exactly the data they need.
- Apollo GraphQL - A GraphQL client/server library
- Typetta - A Typescript ORM. We use Typetta to connect and interact with our MongoDB database. Typetta can automatically create a GraphQL endpoint, as well as provide per-column security for making queries in that endpoint.
- Typetta - A Typescript ORM. We use Typetta to connect and interact with our MongoDB database. Typetta automatically creates a GraphQL endpoint, and provides per-column security on queries sent to that endpoint.
- Node.JS - An asynchronous event-driven Javascript runtime that lets you build network applications.
- Express.JS - A web server framework for Node.JS

## Contents

- [Config](config.md)
- [Structure](structure.md)
- [Structure](structure.md)
31 changes: 15 additions & 16 deletions docs/backend/structure.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@

# Structure

## Folder Structure

- `src` - Contains
- `server.ts` - The entry point of the backend. It reads the command line arguments or environment variables to start a server in devlopment or production mode.
- `config` - Stores config files that change how the backend runs. See the [Config section](#config) for more information
- `_tools` - Contains code used by Node.JS scripts defined in our `package.json`.
- `controllers` - Contains "controllers" which are scripts or folderes of scripts that perform certain functionality. This is a more structured version of `utils` and `misc` folders.
- `generated` - Auto-generated code based on our GraphQL schema
- `graphql` - Contains the GraphQL schema defined in Typescript
- `middlewares` - Middleware for Typetta
- `misc` - Contains miscallenous helper code
- `routes` - Contains all the routes in the backend. Note that accessing data is done by Apollo server's GraphQL endpoint, rather than through manually configured routes.
- `shared` - Code that's shared between the backend and frontends
- `utils` - Utility code.
- `dist` - Where the release version of the backend is stored once you build it.
- `src` - Contains
- `server.ts` - The entry point of the backend. It reads the command line arguments or environment variables to start a server in development or production mode.
- `config` - Stores config files that change how the backend runs. See the [Config section](#config) for more information
- `_tools` - Contains code used by Node.JS scripts defined in our `package.json`.
- `controllers` - Contains "controllers" which are scripts or folderes of scripts that perform certain functionality. This is a more structured version of `utils` and `misc` folders.
- `generated` - Auto-generated code based on our GraphQL schema
- `graphql` - Contains the GraphQL schema defined in Typescript
- `middlewares` - Middleware for Typetta
- `misc` - Contains miscellaneous helper code
- `routes` - Contains all the routes in the backend. Note that accessing data is done by Apollo server's GraphQL endpoint, rather than through manually configured routes.
- `shared` - Code that's shared between the backend and frontends
- `utils` - Utility code.
- `dist` - Where the release version of the backend is stored once you build it.
- `gulpfile.js` - Script that automates copying assets over when you build the backend.
- `rucogs.service` - Service file for hosting backend. See [DevOps/Hosting](../devops/hosting.md) for more information.
- `tsconfig.json` - Configuration for Typescript
Expand All @@ -29,7 +28,7 @@
- `mock` - Runs a mock server with dummy data from the `dist/_tools` folder
- `mock:recompile` - Recompiles the backend and runs it with dummy data.
- `tools` - Runs the server in tool mode
- Tool mode is used at the moment to automatically generate a GraphQL Typescript typings from the running Apollo server. The generated files are placed under the `src/generated` folder.
- Tool mode is used at the moment to automatically generate a GraphQL Typescript typings from the running Apollo server. The generated files are placed under the `src/generated` folder.
- `tools:recompile` - Recompiles the backend and runs it in tool mode
- `generate` - Generates Typetta and GraphQL typings.
- `generate:typetta` - Generates Typetta typings.
Expand All @@ -47,4 +46,4 @@

```bash
> npm run script_name
```
```
75 changes: 37 additions & 38 deletions docs/devops/ci_cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,45 @@ Continuous integration and deployment is the process of automatically running un

## Website

We use this for our website, since it's hosted on Github Pages. Inside our `rucogs.github.io` repository, we have `.github/workflows/gh-pages-deployment.yml` workflow show below. This workflow automatically builds and deploys the website to Github Pages any time there is a commit made to the `main` branch.
We use this for our website, since it's hosted on Github Pages. Inside our `rucogs.github.io` repository, we have `.github/workflows/gh-pages-deployment.yml` workflow show below. This workflow automatically builds and deploys the website to Github Pages any time there is a commit made to the `main` branch.

```yaml
name: Deploy to GitHub Pages

on:
push:
branches:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
with:
persist-credentials: false
- name: Use Node.js (Latest)
uses: actions/setup-node@v2
with:
node-version: '14'
check-latest: true
- name: Build
run: |
npm install -g @angular/cli
npm install
npm run build
cp dist/index.html dist/404.html
- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: dist # The folder the action should deploy.
- name: Checkout
uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
with:
persist-credentials: false
- name: Use Node.js (Latest)
uses: actions/setup-node@v2
with:
node-version: "14"
check-latest: true
- name: Build
run: |
npm install -g @angular/cli
npm install
npm run build
cp dist/index.html dist/404.html
- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: dist # The folder the action should deploy.
```
## Backups
We also use Github Actions to automate backups of both the database and users' uploaded files. Inside our `rucogs-infrastructure-backup` repository, we have `.github/workflows/actions.yml` workflow shown below. This workflows requires the URI connection string to the MongoDB database, as well as the

We also use Github Actions to automate backups of both the database and users' uploaded files. Inside our `rucogs-infrastructure-backup` repository, we have `.github/workflows/actions.yml` workflow shown below. This workflows requires the URI connection string to the MongoDB database, as well as the

```yaml
name: 📦 Make Backups
Expand Down Expand Up @@ -88,15 +87,15 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: mongodump
path: mongodump.zip
path: mongodump.zip
uploads-backup:
name: Uploads Backup
runs-on: ubuntu-latest
steps:
- name: Download uploads folder
run: sshpass -p "${{ secrets.BACKEND_ROOT_PASS }}" scp -o StrictHostKeyChecking=no -r "${{ secrets.BACKEND_URI }}:${{ env.BACKEND_UPLOADS_DIR }}" ./uploads
- name: Zip uploads
run: 7z a uploads.zip uploads
Expand All @@ -106,7 +105,7 @@ jobs:
name: uploads
path: uploads.zip
retention-days: 1
create-release:
needs: [mongodb-backup, uploads-backup]
name: Create Release
Expand All @@ -132,7 +131,7 @@ jobs:
Backed up to ready to go! 🚀
draft: false
prerelease: false
upload-release-artifacts:
needs: create-release
name: Upload Release Artifacts
Expand All @@ -146,7 +145,7 @@ jobs:
with:
name: ${{ matrix.artifact_name }}
path: ./
- name: Upload Artifact to Release
id: upload-release-asset
uses: softprops/action-gh-release@v1
Expand All @@ -160,18 +159,18 @@ jobs:

### Environment Variables

Nonsensitive configuration can be done in the workflow file itself
Nonsensitive configuration can be done in the workflow file itself

- `MONGODB_TOOLS_DOWNLOAD` - A environment variable that links to a download for `mongodump`, a tool that can dump the contents of the database into a file.
We use this to create a backup of the MongoDB database hosted on MongoDB Atlas.
- `BACKEND_UPLOADS_DIR` - A environment variable that holds the absolute path to directory of the uploads folder within the backend server.
- ` cron: "0 0 * * 0"` - Sets up a the backup action to run every month using a cron expression. You can use [crontab.guru](https://crontab.guru/) to build a cron expression.
At the moment it runs the action at 00:00 on Sundays.
- `BACKEND_UPLOADS_DIR` - A environment variable that holds the absolute path to directory of the uploads folder within the backend server.
- ` cron: "0 0 * * 0"` - Sets up a the backup action to run every month using a cron expression. You can use [crontab.guru](https://crontab.guru/) to build a cron expression.
At the moment it runs the action at 00:00 on Sundays.
### Secrets
### Secrets
Sensitive information is stored as a repository secret on our Github repository. Here is a list of the follow secrets that can be configured
- `MONGO_URI` - The [MongoDB connection string](https://www.mongodb.com/docs/manual/reference/connection-string/) used to connect to our `MainDB` databse
- `MONGO_URI` - The [MongoDB connection string](https://www.mongodb.com/docs/manual/reference/connection-string/) used to connect to our `MainDB` database
- `BACKEND_URI` - The ssh connection string to the backend. It's typically `[email protected]` where `123.45.678` represents your server's ip address.
- `BACKEND_ROOT_PASS` - The root password of the database.
- `BACKEND_ROOT_PASS` - The password of the backend for the user you specified in the `BACKEND_URI`.
12 changes: 6 additions & 6 deletions docs/devops/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

- [What is a Database?](https://www.oracle.com/database/what-is-database)
- [Introduction to MongoDB](https://www.mongodb.com/docs/manual/introduction/)
- Explains the overall structuring of MongoDB a NoSQL database
- Ex. documents make up collections, which make up databases.
- Explains the overall structuring of MongoDB a NoSQL database
- Ex. documents make up collections, which make up databases.
- [SQL Tutorial - Full Database Course for Beginners](https://www.youtube.com/watch?v=HXV3zeQKqGY)
- Despite using MongoDB, a NoSQL database, we are still using the database like a traditional SQL one. We use collections as tables, and documents with fixed fields.
- Despite using MongoDB, a NoSQL database, we are still using the database like a traditional SQL one. We use collections as tables, and documents with fixed fields.

## Overview

We use MongoDB as our database. Specifically, we use MongoDB's cloud database service called MongoDB Atlas. MongoDB Atlas provides a cluster of databases, so it adds a layer of redundancy in case one database fails. We have a `RUCOGS` organization on Atlas. Underneath Atlas we have a `rucogs.github.io` project, and within that is `MainDB` -- our entire database. We currently use the free-tier of MongoDB, which gives us 512 MB of free storage.
We use MongoDB as our database. Specifically, we use MongoDB's cloud database service called MongoDB Atlas. MongoDB Atlas provides a cluster of databases, so it adds a layer of redundancy in case one database fails. We have a `RUCOGS` organization on Atlas. Underneath Atlas we have a `rucogs.github.io` project, and within that is `MainDB` -- our entire database. We currently use the free-tier of MongoDB, which gives us 512 MB of free storage.

Files are not stored on databases, since that would be wasteful. Instead, files are often uploaded to dedicated servers, with database entries only containing a link that can fetch the file from the server. The files for our backend are stored within the backend. See [backend section](../backend/index.md) for more information.

Expand All @@ -24,5 +24,5 @@ Files are not stored on databases, since that would be wasteful. Instead, files
It's important to pass on access of the database as new Webmasters replace old ones.

Members with access to Database as of **5/27/23**:
- Alan Tong

- Alan Tong
Loading

0 comments on commit a9101f1

Please sign in to comment.