This will be the API that will provide the capabilities for managing movie wishlists for people.
It will be able to:
- Login and create accounts
- Manage a list of movies associated with an account
- Fetch and fill information about movies from an external API such as IMDB
- Collect statistics regarding the popularity of each movie on the service.
https://www.postgresql.org/download/
In the postgres shell, run:
CREATE DATABASE testdb
This is the simplest way to set environment variables on your local machine that work for both Windows and Mac as long as you're using Visual Studio Code
Open the "Run and Debug" sidebar. (It's the Play Icon with a Bug on it.)
You should see a big "Run and Debug" button with the following text below:
To customize Run and Debug create a launch.json file.
Click that "create a launch.json file" link. It'll create a new JSON file which will be used to run the Java project from within VS Code.
The JSON file should look like this:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Current File",
"request": "launch",
"mainClass": "${file}",
"env": {
"DB_USER_NAME": "postgres",
"DATABASE_URL": "jdbc:postgresql://localhost:5432/testdb",
"API_KEY": "<your_api_key_here>"
}
},
{
"type": "java",
"name": "Launch MovieWishlistApplication",
"request": "launch",
"mainClass": "coms.w4156.moviewishlist.MovieWishlistApplication",
"projectName": "MovieWishlist",
"env": {
"DB_USER_NAME": "postgres",
"DATABASE_URL": "jdbc:postgresql://localhost:5432/testdb",
"API_KEY": "<your_api_key_here>"
}
}
]
}
If you have any problem creating this file, you can create the file manually at ./vscode/launch.json
at the root of the project folder.
Once this is done, you can use the "Run and Debug" section to choose between the two commands and click the Play button. It will automatically use the environment variables you defined.
If this technique doesn't work, or if you prefer to run commands from the terminal, you can use the instructions below
- Open a terminal and open the .bash_profile file by running:
open -e ~/.bash_profile
- Scroll down to the end of the file and add the the following:
export DB_USER_NAME=<YOUR POSTGRES USER NAME HERE>
export DB_USER_PASSWORD=<YOUR POSTGRES PASSWORD HERE>
export DATABASE_URL=<POSTGRES URL HERE>
- Save the file by pressing command+s and then close the file
- Execute the file either by opening a new terminal window or by running the command :
source ~/.bash_profile
- In the control panel, search for environment variable in the search bar
- Click on "Edit the system environment variables' and then on the Environment Variables button
- In the system vairiables, add the following variables and their respective values:
DB_USER_NAME=<YOUR POSTGRES USER NAME HERE>
DB_USER_PASSWORD=<YOUR POSTGRES PASSWORD HERE>
DATABASE_URL=<POSTGRES URL HERE>
- Click OK and apply the changes
- Open a new terminal for the changes to apply
Replacing with your username, password and the proper url. I believe postgres runs on port 5432 by default so the proper URL is usually
jdbc:postgresql://localhost:5432/testdb
I (Sachin) can dm you mine on Slack or you can sign up for one here https://api.watchmode.com/. There is a monthly quota of 1000 queries
In order for the API to make queries to WatchMode based off of your API key, you need to add the 'API_KEY' as a system environment variable in the same way you added the postgres database url, username and password. It is set up like this so we never have to push API keys to the git repo
run
mvn clean spring-boot:run
in order to launch the app.
Create a 'secrets.properties' file in the src/main/resources folder. Copy paste the database url, username and password for the local instance in this file.
On the command line run
mvn site
Or, in Intellij, open up the Maven panel, click on Lifecycle
and then double click site
.
The generated reports will the appear under target/site/project-reports.html
.
Here are the results of the latest checkstyle run:
Run
mvn test
Here are the results of the latest test run:
Documentation for many of our endpoints can be found in the Documentation folder
All the documentation for the GraphQL endpoint can be found in the GraphiQL IDE.
In order to access this IDE, you need to do a few things.
- Spin up a local instance of our service
- Authenticate by following the instructions in the Authentication portion of this README. Hold on to the token
- Download the ModHeader extension for Google Chrome
- Hit the /graphiql endpoint. At this point it should NOT work
- Use the ModHeader plugin to add a
Request Header
with name =Authorization
and value =Bearer <JWT>
- Where JWT is your token that you saved from before. Note the space after "Bearer"
The header should look like this:
After you have completed all these steps, you should be able to access the GraphiQL IDE
through the /graphiql endpoint. The documentation for this endpoint is visible in the Docs
pane which
can be opened by clicking on the button in the top right. See the screenshot below.
The documentation is interactive. You can click on the types to introspect
The SonarCloud dashboard for this project is located here
SonarCloud is very verbose, if all you are interested in is code coverage, then JaCoCo should suffice. Run
mvn clean verify
and then open target/site/jacoco/index.html
in a browser to view coverage
reports.
The authentication is handled using JSON Web Tokens; here is how it works:
- a client needs to hit the
createClient
endpoint with his email to be added to the database; he will receive his own JWT in the response - on every subsequent request, the client has to add the
Authorization: Bearer <JWT>
header so that he can be authenticated. If he fails to do so or the JWT is not valid, he will receive a403
error - clients have roles which give them access to certain endpoints. For now, there are three roles:
client
which grants basic access,rating
which grants access to rating endpoints, andadmin
, which grants access to admin endpoints used for updating clients
To run the client, read the instructions in client/README.md
There are a variety of ways a client could utilize our service.
- An app that uses ML to recommend users movies to watch based on their interests.
- Such an app might allow users to make watchlists and then based on those watchlists it would recommend more movies in that vein for users to watch.
- In this use case, the profile ID would correspond to a user ID.
- The app would use our service to group watchlists with users, take care of CRUD operations on those watchlists, and get information on the movies in the watchlists to display to the user (e.g. plot overview)
- A film news site that serves many listicles
- A Buzzfeed-like site for movies that groups movies based on some conceit (e.g. Scariest Movies of all Time, Best B-movies, Hidden Gems from the 90s, etc.)
- In this use case, the profile ID would be used as an article ID or perhaps a theme ID if the site had many listicles under one big theme (e.g. Best movies per decade)
- The site would use our service in order to logically group their lists of movies, perform CRUD on these lists, and to display where these movies are available to stream.
- A movie director information website
- A site dedicated to preserving information about film directors might find our service useful
- In this use case, the profile ID would be used as a director ID and each director would have an associated list of movies. The site moderators would maintain these lists of movies, using our service to perform CRUD on the lists of movies and rate the movies.
- Such a site might use our rating feature in order to determine the highest rated directors of all time based on the average ratings of their movies.