Giter VIP home page Giter VIP logo

order-management's Introduction

Overview

Toy project to play with Polymer

Tech stack:

  • Frontend: Polymer, Lodash
  • Backend: Node.js, ExpressJS, Mongoose
  • Database: MongoDB

Deployment

Application

Assumption

I assumed that an order only contains one type of drink.

##Source code structure

  • Back-end
    • routes/rest.js: main back-end file, communicate with database and expose data/functionality to frontend via JSON RESTful web service.
  • Front-end
    • public/index.html: application’s main page
    • public/add-order-form.html: custom element for adding new order.
    • public/all-orders.html: custom element for tracking all orders.
    • public/shared-styles.html: shared styles and custom SVG icon set.

Data model

Database includes two following collections:

  • Drinks: contains information for all drinks type
{
"type" : <drink type>,
"name" : <drink name>,
"size" : <drink size>,
"price" : <drink price>
}
  • Orders: contains information for all orders:
{
"type" : <drink type>	,
"name" : <drink name>,
"size" : <drink size>,
"price" : <drink price>,
"quantity" : <quantity>,
"amount" : <total amount>,
"time" : <order date>,
}

Main requirement

0) Adding orders

  • Add new order on desktop alt text
  • Add new order on mobile

1)Keep track of all orders (total sales)

All orders are displayed in a table, default sorted by order time in descending order. Date time is in UTC, not local time.

  • View all orders on desktop: alt text

  • View all orders on mobile:

2) Group orders by type of orders (coffee or tea)

Using “filter by type” to group order by drinks’ type: coffee or/and tea

alt text

3) Group orders by type of size (tall, grande or venti)

Using “filter by size” to group order by drinks’ size: tall, grande and/or venti

alt text

Additional question

0) What if we want a new type of coffee, a new type of tea?

A new type of drink can be easily added from the database. Front-end is implemented in a way that dynamically read all drink type and display on UI. For example, I added following a new drink type “Americano”:

{
	"size" : "Tall",
	"price" : "1.98",
	"name" : "Americano",
	"type" : "Coffee"
}

alt text

1) What if we want a new size?

New size can be added in the same way as adding new drink type except we need to add CSS code for new drink size. CSS can be added to add-order-form.html file as follow:

iron-icon.<name of new size> {
    height: <desired height which is relative to other sizes>;
    width: <desired width which is relative to other sizes >;
}

For example: I add a “Mini” size for “Cappuccino” into database:

{
	"size" : "Mini",
	"price" : "2.75",
	"name" : "Cappuccino",
	"type" : "Coffee"
}

And as new CSS to add-order-form.html file as follow

iron-icon.Mini {
    height: 24px;
    width: 24px;
}

alt text

2) How would you change the model to add hot/cold options?

Add hot/cold will require adding a new property in drink model. On the frontend, we also need to add a new input field such as radio button group for users to select the hot/cold option.

3) (optional) How would you change the model to support adding condiments to drinks (perl, grass jelly,...)

We can follow either of two below methods to support condiments:

  • First method: We will treat condiments just like properties of drink same as adding hot/cold options. We will need to add a new property to the database and add new input field on the front end. This way is simple to implement but may create a large number of drinks result from combinations of multiple drinks with multiple condiments.
  • Second method: we will treat condiment as separate items that have their own price. They will be ordered separately from drinks. Order total amount will be the sum of drink amount and condiments amount. We will need to add separate condiments section to add order screen. This method requires considerable effort on front-end side but will eliminate the complexity of management of a large number of drinks like the first method.

order-management's People

Contributors

shazilhasan avatar bobevenup avatar bobbui 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.