Code Monkey home page Code Monkey logo

shopify_challenge's Introduction

README

This server side web api project is for the Shopify Summer 2019 Developer Intern Challenge. It is the barebones of an online marketplace, built with ruby, rails, and graphql.

It includes the basic functionalities

  • fetch products one at a time
  • fetch products all at once (with argument to only return products with available inventory)
  • purchase products which reduces the inventory by 1

As well as additional functionalities

  • Have a cart system with total price of cart
  • Create a shopping cart (with or without initial items)
  • Add items to shopping cart
  • Check out a shopping cart (reduces inventory and clears cart)

Example Queries

query {
  #to get all products in the marketplace
  #fetchAllProducts has a optional argument available
  #which shows all products with non-zero inventory count
  fetchAllProducts {
    title
    inventory_count
    price
  }
  
  #to get all products in the marketplace with available inventory
  fetchAllProducts(available:true) {
    title
    inventory_count
    price
  }
  
  #to fetch one product with the name "ice cream"
  fetchOneProduct(title:"ice cream") {
    title
    inventory_count
    price
  }
  
  #to fetch all orders (products with multiple quantities)
  #Orders represent a Product with a quantity value
  #useful for buying mutiple of same product
  fetchAllOrders {
      price
      quantity
      product {
        title
        inventory_count
        price
      }
  }
  
  #to fetch all carts
  #cart consists of multiple different orders
  fetchAllCarts {
    id
    total_cost
    orders {
      price
      #also has the other orders fields but let's just leave it here :)
    }
  }
}

Example Mutations

mutation {
  #purchase one ice cream
  purchaseProduct(product: "ice cream") {
    title
    inventory_count
  }
  
  #create an empty cart
  createCart() {
    id
    total_cost
  }
  
  #create a cart with 5 ice creams
  createCart(items: ["ice cream:5"]) {
    id
    total_cost
  }
  
  #note for the following mutations you need cart_id, which can be
  #queried for with fetchAllCarts
  
  #add additional items to cart #1
  addToCart(cart_id: 1, items: ["potato:2"]) {
    id
    total_cost
  }
  
  #"checks out" cart #1 by reducing inventory & clearing the cart
  checkOut(cart_id: 1) {
    id
    total_cost
  }
}

Versioning

  • Handled by Docker
  • Ruby v2.6
  • Rails v5.1.4

How to run the test suite

  • Run rails test to run custom unit tests
  • Unit tests are located in /tests/models
  • Tests include checking for correct query and mutation logic

Deployment instructions

  • The deployment for this app is handled by a Docker image, see Dockerfile for more details
  • To run locally, clone the repo and build and run docker image
  • sudo docker build -t app . and sudo docker run -it -p 80:80 app
  • Check your local host ip address under port 80 to see the server running
  • I have also set up a public IP address on Google Cloud
  • View the GraphIQL site at 34.73.184.101/graphiql
  • You can also post normally to 34.73.184.101/graphql

shopify_challenge's People

Contributors

jellyfer avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.