Skip to content

Commit

Permalink
Merge branch 'master' into tim/mongoose-schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
timobraz authored Mar 5, 2024
2 parents 928309b + 7cc0c5f commit 2c75ab2
Show file tree
Hide file tree
Showing 79 changed files with 4,664 additions and 3,152 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
env: { node: true, es2020: true },
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
ignorePatterns: ['.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
};
8 changes: 7 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- Title format: short pr description -->

## Description

<!-- Briefly explain the steps you took to complete this PR/solve the issue -->

## Screenshots
Expand All @@ -20,16 +21,21 @@
-->

## Steps to verify/test this change:

- [ ] Verify changes work as expected on staging instance
<!-- Add more steps here… -->

## Final Checks:

- [ ] Verify successful deployment

(optional)

- [ ] Write tests
- [ ] Write documentation

## Issues

<!-- Link the issue you're closing -->
Closes #

Closes #
32 changes: 16 additions & 16 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,38 @@ on:
branches:
- master
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_and_deploy:
name: Build and deploy PeterPortal
runs-on: ubuntu-latest

concurrency:
group: build-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
if: (github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'no deploy'))
environment:
name: ${{ (github.event_name == 'pull_request' && format('staging-{0}', github.event.pull_request.number)) || 'production' }}
url: https://${{ (github.event_name == 'pull_request' && format('staging-{0}.', github.event.pull_request.number)) || '' }}peterportal.org

steps:
- name: Check Out Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install Dependencies
run: npm install
env:
HUSKY: 0

- name: Build and deploy
run: npx sst deploy --stage ${{ (github.event_name == 'pull_request' && format('staging-{0}', github.event.pull_request.number)) || 'prod' }}
Expand All @@ -46,11 +54,3 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
NODE_ENV: ${{ github.event_name == 'pull_request' && 'staging' || 'production' }}

- name: Comment staging URL
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ github.event_name == 'pull_request' }}
with:
header: staging url
recreate: true
message: Deployed staging instance to https://staging-${{ github.event.pull_request.number }}.peterportal.org
32 changes: 14 additions & 18 deletions .github/workflows/clean-up-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,40 @@ name: Clean up PR
on:
pull_request:
types: [closed]
branches:
- master

concurrency:
group: deploy-${{ github.head_ref || github.run_id }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
clean-up-pr:
runs-on: ubuntu-latest
env:
STAGING_PREFIX: staging-${{ github.event.pull_request.number }}.
STAGE_NAME: staging-${{ github.event.pull_request.number }}

steps:
- name: Check Out Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install Dependencies
run: npm install
env:
HUSKY: 0

- name: Remove staging stack
run: npx sst remove --stage ${{ format('staging-{0}', github.event.pull_request.number) }} backend && npx sst remove --stage ${{ format('staging-{0}', github.event.pull_request.number) }} frontend
run: npx sst remove --stage staging-${{ github.event.pull_request.number }}
env:
CI: false
PUBLIC_API_URL: ${{secrets.PUBLIC_API_URL}}
PUBLIC_API_GRAPHQL_URL: ${{secrets.PUBLIC_API_GRAPHQL_URL}}
MONGO_URL: ${{secrets.MONGO_URL}}
SESSION_SECRET: ${{secrets.SESSION_SECRET}}
GOOGLE_CLIENT: ${{secrets.GOOGLE_CLIENT}}
GOOGLE_SECRET: ${{secrets.GOOGLE_SECRET}}
GRECAPTCHA_SECRET: ${{secrets.GRECAPTCHA_SECRET}}
ADMIN_EMAILS: ${{secrets.ADMIN_EMAILS}}
PRODUCTION_DOMAIN: ${{secrets.PRODUCTION_DOMAIN}}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Deactivate deployment
uses: strumwolf/[email protected]
with:
environment: staging-${{ github.event.pull_request.number }}
token: ${{ secrets.GITHUB_TOKEN }}
onlyDeactivateDeployments: true
20 changes: 12 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,34 @@ name: Lint

on:
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint and check formatting
runs-on: ubuntu-latest

concurrency:
group: lint-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

steps:
- name: Check Out Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install Dependencies
run: npm install
env:
HUSKY: 0

- name: Lint
run: npm run lint
87 changes: 45 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,44 @@
PeterPortal is a web application aimed to aid UCI students with course discovery and planning. We consolidate public data available on multiple UCI sources on the application to improve the user experience when planning their course schedule.

Features include:
* Course catalog with:
* Grade distribution graphs/charts
* Visual prerequisite trees
* Schedule of classes
* Reviews

- Course catalog with:
- Grade distribution graphs/charts
- Visual prerequisite trees
- Schedule of classes
- Reviews

![catalogue](https://github.com/icssc/peterportal-client/assets/8922227/e2e34103-a73e-4fd9-af44-69b707d1e910)
![coursepage](https://github.com/icssc/peterportal-client/assets/8922227/2df5a284-0040-4720-a9be-c08978b6bfb1)
* Professor catalog with:
* Schedule of classes
* Grade distribution graphs/charts
* Reviews
* Peter's Roadmap, a drag-and-drop 4-year course planner

- Professor catalog with:
- Schedule of classes
- Grade distribution graphs/charts
- Reviews
- Peter's Roadmap, a drag-and-drop 4-year course planner

![roadmap](https://github.com/icssc/peterportal-client/assets/8922227/7849f059-ebb6-43b4-814d-75fb850fec01)

## 🔨 Built with

* [PeterPortal API](https://github.com/icssc/peterportal-api-next)
* Express
* React
* SST and AWS CDK
* MongoDB
* GraphQL
* TypeScript
* Vite
- [PeterPortal API](https://github.com/icssc/peterportal-api-next)
- Express
- React
- SST and AWS CDK
- MongoDB
- GraphQL
- TypeScript
- Vite

## First time setup

### Committee Members

1. Clone the repository to your local machine:
```
git clone https://github.com/icssc/peterportal-client
```

```
git clone https://github.com/icssc/peterportal-client
```

2. Check your Node version with `node -v`. Make sure you have version 18 or 20 LTS. If you don't, we recommend [nvm](https://github.com/nvm-sh/nvm) to manage node versions (or [nvm-windows](https://github.com/coreybutler/nvm-windows)).

Expand All @@ -47,14 +53,16 @@ Features include:
5. Setup the appropriate environment variables provided by the project lead.

6. Switch to a branch you will be working on for your current task (pick a name that's relevant to the issue).
```
git checkout -b [branch name]
```
```
git checkout -b [branch name]
```

### Open Source Contributors

1. Fork the project by clicking the fork button in the top right, above the about section.

2. Clone your forked repository to your local machine

```
git clone https://github.com/<your username>/peterportal-client
```
Expand All @@ -65,53 +73,48 @@ git clone https://github.com/<your username>/peterportal-client

5. Run `npm install` to install all node dependencies for the site and API. This may take a few minutes.

6. Create a .env file in the api directory with the following contents:
```
PUBLIC_API_URL=https://api-next.peterportal.org/v1/rest/
PUBLIC_API_GRAPHQL_URL=https://api-next.peterportal.org/v1/graphql
PORT=8080
```
Note: the port should also match the one set up on the frontend's proxy to the backend under `site/vite.config.ts` By default this is 8080.
6. Rename the `.env.example` file in the api directory to `.env`. This includes the minimum environment variables needed for running the backend.

7. (Optional) Set up your own MongoDB and Google OAuth to be able to test features that require signing in such as leaving reviews or saving roadmaps to your account. Add additional variables/secrets to the .env file from the previous step.
```
MONGO_URL=<secret>
SESSION_SECRET=<secret>
GOOGLE_CLIENT=<client>
GOOGLE_SECRET=<secret>
GRECAPTCHA_SECRET=<secret>
ADMIN_EMAILS=["<your email>"]
```

## Open Source Contribution Guide

1. Choose an issue you would like to work on under the issues tab. Leave a comment letting us know you'll work on this issue.

2. We recommend you switch to a branch you will be working on for each feature.

```
git checkout -b [branch name]
```

3. Once your feature is ready, [open a pull request](https://github.com/icssc/peterportal-client/compare) and a member from our team will review it. Follow the pull request template.

## Running the project locally (after setup)
1. Open two terminal windows and `cd` into the directory of your repo in each of them.

2. In the first terminal window, enter the client directory with `cd site`. Then run the Vite development server using `npm run dev`. Ensure the server is running on port 3000 by default.
1. Open a terminal in the root directory of the repo.

2. Run `npm run dev` to start both the backend Express server and frontend Vite dev server

3. In the second terminal window, enter the API directory with `cd api`. Then run the Express development server using `npm run dev`. Ensure the server is running on port 8080 by default.
3. Visit the link printed to the console by Vite!

Optionally, you can run the site/api separately by changing into their respective directories in two different terminal windows and running `npm run dev`

## Our Mission

🎇 Our mission is to improve the UCI student experience with course planning

## Where does the data come from?

We consolidate our data directly from official UCI sources such as: UCI Catalogue, UCI Public Records Office, and UCI WebReg (courtesy of [PeterPortal API](https://github.com/icssc/peterportal-api-next)).

## Bug Report

🐞 If you encountered any issues or bug, please open an issue @ https://github.com/icssc/peterportal-client/issues/new

## Other Disclaimer

✅ Although we consolidate our data directly from official UCI sources, this application is by all means, not an official UCI tool. We stride to keep our data as accurate as possible with the limited support we have from UCI. Please take that into consideration while using this Website.

## Terms & Conditions

📜 There are no hard policies at the moment for utilizing this tool. However, please refrain from abusing the Website by methods such as: sending excessive amount of requests in a small period of time or purposely looking to exploit the system.
13 changes: 13 additions & 0 deletions api/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# these are the minimum variables required to run the backend
PUBLIC_API_URL=https://api-next.peterportal.org/v1/rest/
PUBLIC_API_GRAPHQL_URL=https://api-next.peterportal.org/v1/graphql
PORT=8080 # should match the port on the frontend proxy under site/vite.config.ts

# below are stubs of variables/secrets for MongoDB, google oauth, and recaptcha
# these are necessary for features that require logging in
# MONGO_URL=<secret>
# SESSION_SECRET=<secret>
# GOOGLE_CLIENT=<client>
# GOOGLE_SECRET=<secret>
# GRECAPTCHA_SECRET=<secret>
# ADMIN_EMAILS=["<your email>"]
6 changes: 2 additions & 4 deletions api/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
env: { node: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
};
Loading

0 comments on commit 2c75ab2

Please sign in to comment.