Questions??: Feel free to contact Atharva Kashyap ([email protected])
- First, clone the repository onto your preferred folder inside your local machine.
- Then,
cd
into the repository folder on your local machine. - If you wish to create a branch and work inside that branch, make sure you perform
git checkout -b "<your-branch-name>"
. This is to create a new branch. You can then performgit status
to check if your branch was created successfully. - Now, perform
yarn install
. This is to make sure all theyarn
packages are installed into your local project. - Then, change directory into
server
, which you can do by runningcd server
. - Now, perform
yarn install
again inside theserver
folder to make sure to install necessary modules inside this folder. - This should set-up your project on the local machine. You can now change directory by going back one level. You can do this by performing
cd ..
. Then, you should be able to runyarn start
and a reactapp should get started on your web browser. (If you get an error see note below)
NOTE: If you get an error which mentions
Attempting to bind to HOST environment variable: x86_64-conda-linux-gnu
, it means that theHOST
env variable needs to be set. For testing runHOST=localhost
in the current shell beforeyarn start
to run the server locally, otherwiseHOST
should be set toaurmr-control
(assuming you're on theaurmr-control
workstation) so that other things can find the server.
For Your Information: graphql playground is something that runs on localhost:4000
that provides a space for you to write and test out queries and mutations before making it official and adding it to your app. It also provides you a nice UI that prompts you suggestions when writing your queries and mutations. To get this working, please follow the steps below.
- First, perform
cd server
so that you are in yourserver
folder. - Then, perform
npx prisma generate
- Finally, perform
node src/index.js
- You should stop, run
npx prisma generate
, and then re-runnode src/index.js
after any edit within yourserver
folder. Then refresh your playground to see changes. - If you make any edits to
schema.prisma
, it is important to runprisma migrate dev --name <give-your-migration-a-name>
. This is because you made some edits to your database and you want those changes to be reflected. - The column names of models that you define in your schema must be exactly same as the models you define in your
graphql.schema
. In other words, the column names that you have for your prisma table needs to be exactly the same as the column names that you give to your graphql schema. - Extra (high-level) information about how the server side of things are working: graphql serves to provide a "front-end" experience, which means this is what you use in the reactapp to query and get information from. graphql then contacts prisma through a mode called
resolvers.js
, which then contacts the database to obtain the data.
Here is the link to the Schema file: Schema
Each row of this table keeps track of one Amazon Product. It has columns that keeps track of asin, size, weight, and list of Attributes.
model AmazonProduct {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
asin String @unique
name String
size_length Float?
size_width Float?
size_height Float?
size_units String?
weight Float?
weight_units String?
attributes AmazonProductAttribute[]
bins ProductBin[]
}
Each row of this table keeps track of a particular attribute. The value of the attribute is unique. In other words, having two attributes with the name value is not possible.
model Attribute {
id Int @id @default(autoincrement())
value String @unique
AmazonProducts AmazonProductAttribute[]
}
Connects products to attributes. Each product can have multiple Attributes.
model AmazonProductAttribute {
AttributeId Int
AmazonProductId Int
attribute Attribute? @relation(fields: [AttributeId], references: [id])
amazonProduct AmazonProduct? @relation(fields: [AmazonProductId], references: [id])
@@id([AttributeId, AmazonProductId])
}
Evaluation: An "Experiment" that has various products in various bins and various picks. It can be thought of as a setup.
Bin: Each row of this table keeps track of a BinId (as specified by the QR code stickers on the bins). It also keeps track of a list of ProductBin combination of all the products inside the bin.
ProductBin: This keeps track of a Product, the bin its placed in, the evaluation for which it is part of, and a unique id. There can be multiple of the same product in the same bin (but each of them will have a unique id).
Pick: A pick that specifies a particular ProductBin's unique id to simulate a pick.
model Pick {
id Int @id @default(autoincrement())
ProductBinId Int
ProductFromBin ProductBin @relation(fields: [ProductBinId], references: [id])
Outcome Boolean?
TimeTakenSec Float?
}
model Bin {
id Int @id @default(autoincrement())
BinId String @unique
AmazonProducts ProductBin[]
}
model ProductBin {
id Int @id @default(autoincrement())
AmazonProductId Int
binId String
evalId Int
amazonProduct AmazonProduct? @relation(fields: [AmazonProductId], references: [id])
bin Bin? @relation(fields: [binId], references: [BinId])
evaluation Evaluation? @relation(fields: [evalId], references: [id])
picks Pick[]
}
model Evaluation {
id Int @id @default(autoincrement())
name String @unique
Setup ProductBin[]
}
You can find some example scripts that was used for interacting with the database here.
AddBin
-> Provide a csv file with bins and its sizes use AddBin script to add them to the database.AddProd
-> Provide a csv file with products and its details and use the AddProd scrpt to add them to the database.getProductDetailsScrape_Updated
-> Provide a csv with amazon product links and scrape the web to get the product details. Make sure the time for each scrape query is spaced out by at least 2 minutes.
In the server
folder, inside the src
folder, there is schema.graphql
, which has all the queries, mutations, and models (as defined #Schema Outline). So, if you want to add a query or a mutation (to edit the database), then you will need to define that in either type Query
or type Mutation
first.
Then, in the server/src
folder, there is resolvers.js
. After defining the queries and mutations in the schema.graphql, you will need to say what those queries and mutations should do in-terms of interacting with the database. For this, you will need to define the functionalities in the resolvers.
Finally, in the server/prisma/schema.prisma
, you can define the tables for the database side. If you were to add more tables or more columns to existing tables, then you will need to edit it here first and then add the same to schema.graphql.
In the src
, inside the components
folder, the important ones are the following:
ManualEval.tsx
-> Frontend for handling the stowing process.PickHandler.tsx
-> Frontend for handling the picking process.Evaluator.tsx
-> Frontend for random generation of product configurations in bins. Not currently in use but could be built on for future use.
In the src
, inside the GraphQLQueriesMuts
folder, the important ones are the following:
Query.tsx
-> All the queries that are used for Stowing and PickingMutation.tsx
-> All the mutations that are used for Stowing and Picking