Git Product home page Git Product logo

flask-analytical-app's Introduction

Analytics REST API

This REST API will provide analytics for a given day.

To run the application

1. System Requirements

  • Python 3.8
  • pip3

2. Install Requirements

make setup

3. Run the application

To load to database, DATA_DIR ENV is expected to set. Otherwise, it will be ignored. The repo includes sample data.

export DATA_DIR=./sample-data

Run the app

make run

Sample cURL request

curl --location 'http://localhost:5000/analytics' \
--header 'Content-Type: application/json' \
--data '{
    "day":"2019-08-01"
}'

Output

{
    "commissions": {
        "order_average": 2235862.332815922,
        "promotions": {
            "1": 5852160.0,
            "3": 720612.0,
            "4": 222168.94385922147
        },
        "total": 22358623.32815922
    },
    "customers": 10,
    "discount_rate_avg": 1.5928759968214223,
    "items": 3082,
    "order_total_avg": 16499829.576384336,
    "total_discount_amount": 150457385.3559189
}

Local development

Useful commands

Command Description
make setup-dev Install requirements
make check_format Check which files will be reformatted
make format Format files
make lint Lint checks
make test-unit Run unit tests
make clean-app Clean app

Note: Check Makefile for more commands

flask-analytical-app's People

Contributors

shehanishanka avatar

Watchers

 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.