Skip to content
/ DiscoDB Public
forked from LT69018/DiscoDB

Web app for searching and saving music you want to listen to || Built using React/Express/MySQL || CMSC461 Database Administration Group Project Spring 2024 completed by Coby Ziv, Jess Turner, Daniel Williams, and Ayush Nigam.

Notifications You must be signed in to change notification settings

jatcs/DiscoDB

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Review Assignment Due Date ^ due 4-29

DiscoDB

This repository contains the code for our database application, "DiscoDB".

The goal is to allow users to search for and save albums to "listening lists", similar to how goodreads allows readers to save books they want to read.

The frontend is hosted on port 3000, the backend is hosted on port 8080. See the Dockerfiles.

Currently, the system is set to run for one user with this information:

{
    user_id: 123456
    username: "testUser"
}

Make sure to run POST /create_user?username="testUser"&user_id=123456 so that this user is created and you can interact with their listening tables :)

Appearance

When you open the app you are greeted with a search header that looks like this!

New!

Now you can enter something to the text box on the HomePage (We store it in location.state.searchString) then it takes you to the SearchResults page and shows you what you entered. I applied a similar procedure to store the result of the user's searchBy dropdown selection.

So far, there is no API call to actually query the database based on the input.

Progress by 4/17: HomePage sends searchString to SearchResults page so it can request the search info from the backend and display it.

Directory Structure / Docker

Note: You may have to have docker desktop running in order to start up and run our docker image.

Reference repository: https://github.com/docker/awesome-compose/blob/master/react-express-mysql/

.
├── backend
│   ├── Dockerfile
│   ...
├── db
│   └── password.txt
├── compose.yaml
├── frontend
│   ├── ...
│   └── Dockerfile
└── README.md

For ease, I will write this on files that are from this reference:

/* ======================== (start) REFERENCE:github/docker ==================   */
/* Description of our usage of the reference + any modifications made if at all. */
/* ----------------------------------------------------------------------------- */
const exampleCodeFromReference = exampleFuncCall();
/* ======================== ( end ) REFERENCE:github/docker ==================    */
  • this is ommitted for *.json because I can't make comments :P

1. Pulling the current dataset

  1. Go to this Google Drive link
  2. download all of the files in the folder (the files are titled as follows: "discogs_20240201_artists_modified", "found_missing_releases_masters", "main_releases_modified", and "recovered_missing_releases_modified").
  3. Navigate to db/Miniature database code and change DATASET_FOLDER_PATH in config.py to the path to wherever you stored the dataset files.
  4. Run pip install mysql-connector-python and pip install lxml in your terminal to download the necessary packages used in parsing the data.
  5. Execute the following commands in your MySQL server:
     SET GLOBAL max_allowed_packet=1073741824;
     SET GLOBAL wait_timeout = 6000;
     SET GLOBAL net_read_timeout = 6000;
     SET GLOBAL connect_timeout = 6000;
    
  6. Run setup_sql.py

2. Deploy with docker compose

There are two options for deploying our web app, the first is to use Docker Containers. Command:

docker compose up -d

Note from Jess T. : I recommend the -d flag because if you don't your console gets filled up with status logs. Just use docker desktop to see the logs.

Output:

$ docker compose up -d
Creating network "react-express-mysql_default" with the default driver
Building backend
Step 1/16 : FROM node:10
 ---> aa6432763c11
...
Successfully tagged project-discodb_frontend:latest
WARNING: Image for service frontend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating project-discodb_db_1 ... done
Creating project-discodb_backend_1 ... done
Creating project-discodb_frontend_1 ... done

2.5. Deploy manually

If you do not have access to docker, or have issues. The second recommended approach is to do the following:

  1. Go into each folder (backend, frontend) in a separate command window , and run 'npm install' followed by 'npm start'. This will deploy the backend Node.js webserver and the React frontend respectively. Please see the DB folder for more instructions on getting the mysql database setup.

Expected result

Listing containers must show containers running and the port mapping as below.

Command:

docker ps

Output:

$ docker ps
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS                   PORTS                                                  NAMES
f3e1183e709e        project-discodb_frontend   "docker-entrypoint.s…"   8 minutes ago       Up 8 minutes             0.0.0.0:3000->3000/tcp                                 project-discodb_frontend_1
9422da53da76        project-discodb_backend    "docker-entrypoint.s…"   8 minutes ago       Up 8 minutes (healthy)   0.0.0.0:80->80/tcp, 0.0.0.0:9229-9230->9229-9230/tcp   project-discodb_backend_1
a434bce6d2be        mysql:8.0.19                   "docker-entrypoint.s…"   8 minutes ago       Up 8 minutes             3306/tcp, 33060/tcp                                    project-discodb_db_1

After the application starts, navigate to http://localhost:3000 in your web browser.

The backend service container has the port 80 mapped to 80 on the host.

$ curl localhost:80
{"message":"Hello from MySQL 8.0.19"}

Stop and remove the containers

Command:

docker compose down

Output:

$ docker compose down
Stopping project-discodb_frontend_1 ... done
Stopping project-discodb_backend_1  ... done
Stopping project-discodb_db_1       ... done
Removing project-discodb_frontend_1 ... done
Removing project-discodb_backend_1  ... done
Removing project-discodb_db_1       ... done
Removing network project-discodb_default

In case of failure (How I somewhat reset a docker image)

Section Author: Jess Turner

Run the following commands. I know this isn't ideal at all because it deletes ALL your docker containers, but this is just what may have worked as of 4/22 when I wanted to reset my backend docker image.

  • Recalling the problem in case you wonder if you are in this same "emergency" that I had: ( I updated the packages and I was constantly getting package not found "cors" errors as well as the app was using the wrong port, 5001 (i.e. when viewing the docker layers) likely because of docker caching an earlier version of the system which used that port )
docker system prune
docker build --no-cache backend

I suppose you can replace backend with whichever image is giving you trouble :P

Then you can re-run the app with docker compose up -d as usual.

In case of failure (How I somewhat reset a docker image)

Section Author: Jess Turner

Run the following commands. I know this isn't ideal at all because it deletes ALL your docker containers, but this is just what may have worked as of 4/22 when I wanted to reset my backend docker image. Unfortunately this doesn't consistently work, but it's worth a try :/

  • Recalling the problem in case you wonder if you are in this same "emergency" that I had: ( I updated the packages and I was constantly getting package not found "cors" errors as well as the app was using the wrong port, 5001 (i.e. when viewing the docker layers) likely because of docker caching an earlier version of the system which used that port )
docker system prune
docker build --no-cache backend

I suppose you can replace backend with whichever image is giving you trouble :P

Then you can re-run the app with docker compose up -d as usual.

Other commands that may help in case of failure

According to this github thread on docker/postgress, you can do docker rm [instance-name]

For example, on 4-25 ~8:45pm, I'm trying to reset the mySQL docker image (i.e. delete and re-create) using a different database table name based on my change in the compose.yaml file. This is what I attempted before rerunning "docker compose up". It didn't work for me, but it may work for you :p

PS C:\...\jturn>docker ps -a
CONTAINER ID   IMAGE                      COMMAND                  CREATED          STATUS                      PORTS                    NAMES
7a91f30eea9c   project-discodb-frontend   "docker-entrypoint.s…"   31 minutes ago   Up 31 minutes               0.0.0.0:3000->3000/tcp   project-discodb-frontend-1
8d94fb992915   project-discodb-backend    "docker-entrypoint.s…"   31 minutes ago   Exited (1) 29 minutes ago                            project-discodb-backend-1
d15ae67dfa4c   mysql:8.0.27               "docker-entrypoint.s…"   31 minutes ago   Exited (0) 30 seconds ago                            project-discodb-db-1
PS C:\...\jturn>docker rm project-discodb-db-1
project-discodb-db-1

[Internal] Sharing information between pages

^ Note for developers:

  • Send information by using navigate
import { useNavigate } from 'react-router-dom';


export default function SenderComponent() {
    const navigate = useNavigate();
    const value = "Send me!"; // usually from state. See "CustomSearchBar.js"
    // example from "Home/CustomSearchBar.js"
    navigate("/RecipientPage", {state:{attributeName: value}});
}
  • Receive information by using location
import { useLocation } from 'react-router-dom';
// i.e. This is routed at "/RecipientPage"
export default function RecipientComponent() {
    // initialize location variable!
    location = useLocation();

    console.log("Received data: ", location.state.attributeName);
}

About

Web app for searching and saving music you want to listen to || Built using React/Express/MySQL || CMSC461 Database Administration Group Project Spring 2024 completed by Coby Ziv, Jess Turner, Daniel Williams, and Ayush Nigam.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 69.5%
  • JavaScript 16.1%
  • Python 13.0%
  • Other 1.4%