Giter Site home page Giter Site logo

mvp's Introduction

Version 1.1

Brief: Design an API for a vending machine, allowing users with a “seller” role to add, update or remove products, while users with a “buyer” role can deposit coins into the machine and make purchases. Your vending machine should only accept 5, 10, 20, 50 and 100 cent coins.

Tasks: REST API should be implemented consuming and producing “application/json” Implement product model with amountAvailable, cost, productName and sellerId fields Implement user model with username, password, deposit and role fields Implement

CRUD for users (POST shouldn’t require authentication)

Implement CRUD for a product model (GET can be called by anyone, while POST, PUT and DELETE can be called only by the seller user who created the product)

Implement /deposit endpoint so users with a “buyer” role can deposit 5, 10, 20, 50 and 100 cent coins into their vending machine account Implement /buy endpoint (accepts productId, amount of products) so users with a “buyer” role can buy

products with the money they’ve deposited. API should return total they’ve spent, products they’ve purchased and their change if there’s any (in 5, 10, 20, 50 and 100 cent coins),

v1.1 Software now take supported coins as input. Default is still 5,10,20,50,100

Implement /reset endpoint so users with a “buyer” role can reset their deposit

Run project:

docker-compose up -d

Stop project:

docker-compose down

Test:

make test

Integration testing(POSTGRESQL):

make test-integration

TODO:

Add API documentation

Replace chi router with echo framework since it offer a nicer error handling where the errors are returned and could be handled by a middleware, Or consider passing the errors down by context and resolving in a middleware

Instead of seperating sql code in a private method and wrap it with error handling, Could let codegenerating generate the functions from sql files and call the generated function directly in the repository wrapper

DONE:

Write a ci/cd pipeline

Replace authorization: Use Casbin authorization for users and roles enforcing, Store username and password in separate service or database with ids that we can reference in our database

mvp's People

Contributors

arnested avatar artback avatar

Watchers

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