Skip to content

Commit

Permalink
Merge pull request #134 from junwha0511/dev
Browse files Browse the repository at this point in the history
Milestone 4
  • Loading branch information
queuedq authored Jun 20, 2021
2 parents c9d52ab + 254aef6 commit a9ca234
Show file tree
Hide file tree
Showing 64 changed files with 1,019,320 additions and 111 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: '4.4'
- name: Test with Maven
run: mvn test
run: mvn test -X
- name: Build with Maven
run: mvn package
14 changes: 6 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ target

# Package Files #
*.jar

# *.war
# *.nar
# *.ear
# *.zip
# *.tar.gz
# *.rar

*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar


# # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
Expand Down
53 changes: 47 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,55 @@ FROM ubuntu:20.04
# https://serverfault.com/questions/949991/how-to-install-tzdata-on-a-ubuntu-docker-image
ENV DEBIAN_FRONTEND noninteractive

# Open 8080 port
EXPOSE 8080

RUN apt-get update && \
apt-get install -y git && \
apt-get install -y openjdk-11-jdk && \
apt-get install -y maven && \
apt-get install -y curl
apt-get install -y openjdk-11-jdk

RUN apt-get install -y maven git curl wget && \
apt-get install -y gnupg


ENV MONGO_VERSION=4.4.6 \
MONGO_MAJOR=4.4 \
MONGO_PACKAGE=mongodb-org \
MONGO_REPO=repo.mognodb.org

RUN wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add - && \
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list && \
set -x && \
apt-get update && \
apt-get install -y \
${MONGO_PACKAGE}=$MONGO_VERSION \
${MONGO_PACKAGE}-server=$MONGO_VERSION \
${MONGO_PACKAGE}-shell=$MONGO_VERSION \
${MONGO_PACKAGE}-mongos=$MONGO_VERSION \
${MONGO_PACKAGE}-tools=$MONGO_VERSION \
&& rm -rf /var/lib/apr/lists/* \
&& rm -rf /var/lib/mongodb \
&& mv /etc/mongod.conf /etc/mognod.conf.orig

RUN mkdir -p /data/db /data/configdb && \
chown -R mongodb:mongodb /data/db /data/configdb

RUN mkdir -p /root/project
VOLUME /data/db /data/configdb
EXPOSE 27017


RUN mkdir -p /root/tomcat/ && cd /root/tomcat && \
mkdir -p /root/project && \
wget https://mirror.navercorp.com/apache/tomcat/tomcat-9/v9.0.46/bin/apache-tomcat-9.0.46.tar.gz && \
tar -xvf apache-tomcat-9.0.46.tar.gz

# Set WORKDIR
WORKDIR /root/project

# Deploy
COPY ./run.sh /root/project/
CMD bash
COPY ./target/cse364-project.war /root/tomcat/apache-tomcat-9.0.46/webapps/ROOT.war

RUN rm -rf /root/tomcat/apache-tomcat-9.0.46/webapps/ROOT && \
chmod +x /root/tomcat/apache-tomcat-9.0.46/bin/catalina.sh

CMD mongod --fork --logpath /var/log/mongodb.log; /root/tomcat/apache-tomcat-9.0.46/bin/catalina.sh run
165 changes: 148 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,167 @@
# CSE-364-Software-Engineering
# FastFit

## What we've done in each milestones
(This project is for UNIST CSE364 Software Engineering course.)

- [Milestone 1](/docs/milestones/milestone1.md)
- [Milestone 2](/docs/milestones/milestone2.md)
- [Milestone 3](/docs/milestones/milestone3.md)
![main_page](docs/images/main_page.png)



## What is FastFit?

FastFit is a movie recommendation system. We quickly(*fast*) find movies that *fits* your taste.

IMDb, an online database of movies, provide numerous information about movies. However, they don't have a recommendation system to look for more movies that fit your taste. So we created FastFit. We'll recommend movies based on your information or favorite movies.

FastFit provides both a web app and a REST API. Whether you are an end user or a developer, choose the service that is right for you.

Curious to see how it works? Feel free to check [How It Works](/docs/how-it-works.md) page.

## Getting Started

### Running the server

To use FastFit, you first need to run the server. After successfully running the server, **please wait about 10 minuites** until the database is filled. When you see the message `--- Start Service ---`, you can start sending requests to the server.

#### Deploying WAR file to Apache Tomcat on Docker (Recommended)

1. First, prepare the `cse364-project.war` file. You can find it in the releases page of the repository, or you can build it manually. To build the WAR file manually, run the following command.

```shell
mvn clean package -P war-build -P init
```

2. Move the .war file into `./target` directory. If you built it manually, it will be already there.

3. Build the Docker image and run it. FastFit uses the port 8080 by default, and you might want to publish the port using the `-p` option.

```shell
docker build -t cse364 ./
docker run -p 8080:8080 -it cse364
```


#### Running JAR on Docker using run.sh

Once the Docker image is created, you can run JAR in the Docker container instead of deploying to Tomcat.

1. Run Docker conatiner with entry point bash.

```shell
docker run -it --entrypoint=bash cse364
```

2. Execute `run.sh`

```shell
. run.sh
```

#### Running JAR manually

1. Install MongoDB on the host machine, and start the `mongod` service.

2. Build a .jar file.

---
```shell
mvn clean package -P init
```

## Docker Build and Run
3. Run the .jar file in the target folder.

```shell
java -jar target/cse364-project-1.0-SNAPSHOT.jar
```

### Using the web application

We provide a simple web application that serves as an interface for end users.

You can get movie recommendations by your information or your favorite movie. There are buttons on the main page that links to each recommendation page.

- **Recommendation by your information :** Enter your gender, age, occupation, or a list of your favorite movie genres. We'll suggest 10 movies you might enjoy according to the provided information. You can omit some fields if you want.

- **Recommendation by your favorite movie :** Enter your favorite movie title with its release year in the parentheses. (e.g. `Toy Story (1995)`) We'll recommend 10 similar movies for you.

Or, you can check our own recommendations on the main page. "All Movies" section shows the overall top 10 recommended movies. Next comes the genre sections. They show top 10 recommended movies by each genre.

Some input fields only accepts a limited number of values. To check which values are allowed, please see the [Available Inputs](/docs/available-inputs.md) page.

For more information, please see the [Web App](/docs/web.md) reference page.

### Using the REST API

For developers, there is a REST API to fetch the data in JSON format. This is a standard way to communicate the data programmatically, and it allows you to handle the data in any way you desire.

For example, you can get movie recommendations by your information as follows:

```shell
curl -X GET http://localhost:8080/users/recommendations -H 'Content-type:application/json' -d '{"gender": "M", "age": "24", "occupation": "college student", "genres": "animation|sci-fi"}'
```
$ docker build -t cse364 .
$ docker run -it cse364
root@[CONTAINER_ID]:~/project# . run.sh

FastFit API will send the movie recommendations.

```json
[
{
"title": "Make Mine Music (1946)",
"genres": "Animation|Children's|Musical",
"imdb": "http://www.imdb.com/title/tt0038718",
"poster": "https://....jpg"
},
{
"title": "Faust (1994)",
"genres": "Animation|Comedy|Thriller",
"imdb": "http://www.imdb.com/title/tt0109781",
"poster": ""
},
{
"title": "Brother from Another Planet, The (1984)",
"genres": "Drama|Sci-Fi",
"imdb": "http://www.imdb.com/title/tt0087004",
"poster": "https://....jpg"
},
"..."
]
```

## Build
For more information, please see the [REST API](/docs/api.md) reference page.

## Development Guide

### Build

```
$ mvn package
$ mvn package [-P profile1 -P profile2 ...]
```

## Test
#### Maven profiles

We use Maven profiles to customize build configurations.

- `init` : Enables a Spring batch job to initialize the MongoDB and fill the data. The batch job doesn't run when the database is already filled. Use this option in most cases.
- `war-build` : Builds a WAR package instead of a JAR package.

### Test

To test the codebase, run:

```
$ mvn test
```

How to check coverage: After running the test command, open `target/site/jacoco/index.html` file in the browser.
After running the test command, open `target/site/jacoco/index.html` file in the browser to check the code coverage.

## References

- [Web App](/docs/web.md)
- [REST API](/docs/api.md)
- [Command Line Program (Deprecated)](/docs/cli.md)
- [Available Inputs](/docs/available-inputs.md)
- [How It Works](/docs/how-it-works.md)

## Usage
## Update History

- [Command Line Program](/docs/cli.md)
- [REST API Server](/docs/api.md)
- [Milestone 1](/docs/milestones/milestone1.md)
- [Milestone 2](/docs/milestones/milestone2.md)
- [Milestone 3](/docs/milestones/milestone3.md)
- [Milestone 4](/docs/milestones/milestone4.md)
Loading

0 comments on commit a9ca234

Please sign in to comment.