Skip to content

Repository files navigation

proj-courses

Sprint Planning Doc:

This repo contains the code for the CMPSC 156 legacy code project "Courses Search".

The project provides a web application where users can search for UCSB courses in various ways.

Users with a Google Account can also store past, current or future schedules of courses for particular quarters.

Deployments

Note: CMPSC 156 Student teams should not change the prod/qa links below to match their team's links; you should maintain the README.md file so that it can be merged into the https://github.com/ucsb-cs156/proj-courses/ repo at the end of the quarter.

Type Link
prod https://courses.dokku-00.cs.ucsb.edu/
qa https://courses-qa.dokku-00.cs.ucsb.edu/

Setup before running application

Before running the application for the first time, you need to do the steps documented in docs/oauth.md.

Otherwise, when you try to login for the first time, you will likely see an error such as:

Authorization Error; Error 401: invalid_client; The OAuth client was not found.

You will also need a value for UCSB_API_KEY; you can obtain a value for that by following the instructions at this link: https://ucsb-cs156.github.io/topics/apis/apis_ucsb_developer_api.html

Optionally, you can set UCSB_COURSES_API_HOST to override the host used for the UCSB Curriculum/Subjects/Quarter APIs (default: https://api.ucsb.edu), e.g. to point at a caching proxy instead of the UCSB API directly.

Getting Started on localhost

  • Open two separate terminal windows
  • In the first window, start up the backend with:
    mvn spring-boot:run
    
  • In the second window:
    cd frontend
    npm install  # only on first run or when dependencies change
    npm start
    

Then, the app should be available on http://localhost:8080

If it doesn't work at first, e.g. you have a blank page on http://localhost:8080, give it a minute and a few page refreshes. Sometimes it takes a moment for everything to settle in.

If you see the following on localhost, make sure that you also have the frontend code running in a separate window.

Failed to connect to the frontend server... On Dokku, be sure that PRODUCTION is defined.  On localhost, open a second terminal window, cd into frontend and type: npm install; npm start";

Getting Started on Dokku

On Heroku, you'll need to set the following configuration variable:

  • Using the Dokku CLI:
    dokku config:set <dokku app name> PRODUCTION=true
    

You'll also need to follow the OAuth set up instructions here: docs/oauth.md.

If you get the following message on Dokku, it probably means that you failed to setup the PRODUCTION environment variable.

Failed to connect to the frontend server... On Dokku, be sure that PRODUCTION is defined.  On localhost, open a second terminal window, cd into frontend and type: npm install; npm start";

Additional environment variables that are needed may be found in .env.SAMPLE

In particular, you will need a value for the UCSB_API_KEY. This is documented in docs/ucsb_api_key.md

Accessing swagger

To access the swagger API endpoints, use:

To run React Storybook

Accessing Database Console

Partial pitest runs

This repo has support for partial pitest runs

For example, to run pitest on just one class, use:

mvn pitest:mutationCoverage -DtargetClasses=edu.ucsb.cs156.courses.controllers.PSCourseController

To run pitest on just one package, use:

mvn pitest:mutationCoverage -DtargetClasses=edu.ucsb.cs156.courses.controllers.\*

To run full mutation test coverage, as usual, use:

mvn pitest:mutationCoverage

Rate Limiting

This app implements per-IP rate limiting using Bucket4j backed by a Caffeine in-memory cache. Each IP starts with an initial bucket of tokens, and the bucket refills at a configurable rate per minute.

The limit can be configured via environment variables, which override the corresponding properties in application.properties.

Environment Variable Property Default Description
RATE_LIMIT_INITIAL_BUCKET_SIZE app.ratelimit.initialBucketSize 200 Initial number of tokens (requests) available per IP address
RATE_LIMIT_REFILL_PER_MINUTE app.ratelimit.refillPerMinute 100 Number of tokens refilled per minute per IP address

Requests exceeding the limit receive an HTTP 429 response.

Releases

Packages

Used by

Contributors

Languages