Giter VIP home page Giter VIP logo

rms's Introduction

RMS (Restaurant Management System)

Disclaimer:

  • I build this project with a package of mine called [Dust]:(https://github.com/Cyberbugz/dust).
  • The aim to help me to build a DDD architecture with some helpers based on experience with such architecture.
  • I put mind handling redundant procedures I do in my work.
  • There's a room for improvements, still a good start point.
  • Feel free to ask about it.

Steps to get up and running:

  • Prerequisite:
    • Docker installed on your machine.
    • Docker compose cli installed on your machine.
    • Port 8080 should not be busy.
  • Change directory to root folder.
  • Run docker compose up -d --build.
  • Once images are built and started run docker compose exec api bash
  • Inside the container run composer install && php artisan migrate --seed
  • Seeding in the previous step just for the purpose of testing on Postman if needed.
  • Application now running on http://localhost:8080.

Notes:

  • You can run tests inside the api container by executing php artisan test command.
  • Presumptions:
    • No authentication required for this challenge as per the provided document.
    • Inventory replenishment flow not required for this challenge.
    • Merchant email is a static email we got from the config.
  • My approach for this challenge were based solely on requirements, in a real world scenario I'd handle the inventory structure differently in a way that gives us traceability, also I'd use fixed threshold instead of percentage but that's up to business requirements and planning team.
  • Caching is applicable in some parts of this project, I assumed it's not required.

Action:

Create order POST /api/orders

Request body:

{
    "products": [
        {
            "product_id": 1,
            "quantity": 2
        }
    ]
}

Responses:

Order created 201:
{
    "data": {
        "id": 1,
        "status": "Pending",
        "products": [
            {
                "id": 1,
                "name": "Burger",
                "price": "100.5",
                "ingredients": [
                    {
                        "id": 1,
                        "name": "Beef",
                        "amount": 150
                    },
                    {
                        "id": 2,
                        "name": "Cheese",
                        "amount": 30
                    },
                    {
                        "id": 3,
                        "name": "Onion",
                        "amount": 20
                    }
                ],
                "quantity": 2
            }
        ],
        "sub_total": 201
    }
}
Invalid field value Or missing value 422:
{
    "message": "The products.0.quantity field must be at least 1.",
    "errors": {
        "products.0.quantity": [
            "The products.0.quantity field must be at least 1."
        ]
    }
}
{
    "message": "The products.0.product_id field is required.",
    "errors": {
        "products.0.product_id": [
            "The products.0.product_id field is required."
        ]
    }
}
Insufficient ingredients 422:
{
    "message": "Insufficient ingredients to prepare the order!"
}

List products GET /api/products

Responses:

Product list 200:
{
    "data": [
        {
            "id": 1,
            "name": "Burger",
            "price": 100.5,
            "ingredients": [
                {
                    "id": 1,
                    "name": "Beef",
                    "amount": 150
                },
                {
                    "id": 2,
                    "name": "Cheese",
                    "amount": 30
                },
                {
                    "id": 3,
                    "name": "Onion",
                    "amount": 20
                }
            ]
        }
    ],
    "links": {
        "first": "http://localhost:8080/api/products?page=1",
        "last": "http://localhost:8080/api/products?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "links": [
            {
                "url": null,
                "label": "« Previous",
                "active": false
            },
            {
                "url": "http://localhost:8080/api/products?page=1",
                "label": "1",
                "active": true
            },
            {
                "url": null,
                "label": "Next »",
                "active": false
            }
        ],
        "path": "http://localhost:8080/api/products",
        "per_page": 20,
        "to": 1,
        "total": 1
    }
}

rms's People

Watchers

Manson Xasthur 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.