Giter VIP home page Giter VIP logo

event-sourced-cart's Introduction

Event sourced shopping cart in node

This is a simple shopping cart API in node built using event sourcing

## Concepts

Product

A product consists of:

  • An ID
  • A name
  • A description
  • A price
{
    "id": 1,
    "name": "Awesome Red Pen",
    "description": "The most awesome red pen you will ever see!",
    "price": 10
}

Cart Item

A cart item consists of:

  • An ID
  • A quantity
  • A product ID
  • A product name
  • A product description
  • A unit price
  • A line total
{
    "id": 2,
    "quantity": 2,
    "name": "Awesome Red Pen",
    "description": "The most awesome red pen you will ever see!",
    "price": 10,
    "total": 20
}

#### Cart Item Events

  • CartItemCreated
  • CartItemQuantityUpdate
  • CartItemDeleted

Cart

A cart consists of:

  • An ID
  • A collection of cart items
  • A total
{
    "id": 3,
    "total": 20
}

Requests

Add item to cart

POST to http://localhost:3000/carts/:cartID/items

{
  "id": 1,
  "quantity": 4
}

Update a cart item

PUT to http://localhost:3000/carts/:cartID/items/9999

{
  "id": 1,
  "quantity": 4
}

Get the items in a cart

GET to http://localhost:3000/carts/1/items

event-sourced-cart's People

Contributors

jmz avatar

Watchers

 avatar James Cloos 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.