vastolf / pizza-planet

A coding interview project that tracks people & the pizzas they consume (yum!)
0 stars 0 forks source link

Pizza Planet

Below you will find details on how to set up this repo for local testing. You will need to install the node modules as well as one global module to get this running in a way that is easy to test.

Basic requirements

Step 1: Clone the Repo

Run the following command to clone the repo:

git clone git@github.com:vastolf/pizza-planet.git

Step 2: Ensure you are using Node 18

Like most node developers, I use nvm to manage my node version. If you don't have nvm, install it

nvm install 18
nvm use 18

Step 3: Install the Gatsby CLI

This will allow you to more easily view the fully built site locally, and test the API endpoints. We could technically test via gatsby develop but this way we ensure the actual build is passing.

npm install -g gatsby-cli

Step 4: Install Node Modules

Run the following commands to enter the project folder and install all the necessary node modules. Note: If you are not using node 18 this will not work.

cd pizza-planet
npm install

Step 5: Set up .env variables

I've set up a template .env file that you can use to set the local environment variables. These env variables will be the MYSQL credentials necessary to connect to the Database.

Run the following commands:

cp .env.template .env.production
cp .env.template .env.development

Now open each .env file and either:

Step 6: Build & Serve the project

Run the following command to build the project into the /public directory; this could take up to a minute depending on your machine:

npm run build

Once the build is complete, you will need to serve it to view it locally. Run the following command:

gatsby serve

This will serve the files that were build into /public, as well as allow our API functions to be accessed.

Step 7: View & manually test the site

You can now view the site at http://localhost:9000

You should see:

You may manually test all sections of the site work by interacting with them via the browser.

Step 8: Run unit tests

To run unit tests, keep the gatsby serve terminal instance open & running, and open an additional Terminal. It is necessary that the site is still being served or the API endpoints cannot be tested.

In the new terminal:

cd pizza-planet
npm test

This will run jest which we are using for our unit testing.

Information regarding development choices

Here I will explain my reasoning for the various choices I made during development.

Packages

All other packages in package.json are peer dependencies of other packages listed above, mostly type definitions

CSV data import

I am not sure if it was a requirement to actually load the data from a CSV, but I assumed it was just important that the data got into the database somehow. Generally if I needed to do something like this, I'd use a package like csvtojson. This can very easily be implemented following a guide such as this one.

If you need me to implement this, please let me know and I can do so.

Final Notes

Just like to raise some points regarding the project: