Skip to content

Latest commit

 

History

History
132 lines (88 loc) · 4.31 KB

README.org

File metadata and controls

132 lines (88 loc) · 4.31 KB

Luncho Server

What it does?

  • The Luncho server provides API so that your app or web site can show both Luncho prices and local prices. The API provides required data in LunchoData structure to client libraries. The client libraries calculate Luncho and local prices locally using cached LunchoData at the client side. So, the calculation is local and fast.
  • The Luncho server provides OpenAPI so that you can generate the client libraries.
  • The Luncho server hosts the Luncho app web site.

Supported lauguages and platforms

  • Client
    • Python
    • TypeScript and Fetch
  • Server
    • Python3 or Pypy3
    • FastAPI (Web framework)
    • gunicorn (Optional)
  • Supported platforms
    • Google App Engine, standard or flexible
    • or any Docker compatible server
    • or any Python

Installation

(Optional) Access key for foreign exchange (forex) rate data

  • By default, we use exchangerate.host which is a free exchange rate data provider. The Luncho server updates the forex data at 00:06 UTC every day. LunchoData expires at the time. If 24-hour update cycle of the forex data is OK for you, skip to the installation as you don’t need to do anything about the exchange rate.
  • However, if you want to use one hour update rather than the default 24-hour update, create a user account on Fixer.io and set your access key to FIXER_API_KEY environment variable or write it in app.yaml if you run on Google App Engine. If you don’t use, don’t set it.

    export FIXER_API_KEY=XXXXXXXX

(Optional) Google Cloud Storage

  • Optionally you can use Google Cloud Storage (GCS) for backing up the exchange rates that will be used when any of above foreign exchange rate API is unavailable. Set your bucket name to GCS_BUCKET environment variable or write it in app.yaml if you run on Google App Engine. Usually it is the same as the URL of GAE app.

    export GCS_BUCKET=luncho-hirano.appspot.com

    If you don’t use, don’t set it. The server saves the data in data/exchange-last.json file.

Local installation

  • Install pypy3 pypy3.7 (Python 3.9) or newer

    (Mac) brew install pypy3 (Win) ? (Linux) ?

  • Install Rust that is required to run pip

    curl –proto ‘=https’ –tlsv1.2 -sSf https://sh.rustup.rs | sh (restart bash to add rustup to PATH) rustup install nightly ; rustup default nightly

  • Run the install script to install pypy3 and so on. Check it before run!

    bin/install-packages.sh

  • You have pypyenv dir that includes site-packages.

Build client libraries and the app

bin/build.sh

Run a local Luncho server

bin/start-gunicorn.sh

Run on Google App Engine

  • Install gcloud SDK
  • Make a project and deploy gcloud auth login (gcloud app create –project=luncho-hirano or your project name) gcloud config set project luncho-hirano (or your project name) gcloud app deploy –quiet

Docker installation

  • build docker compose build –progress plain
  • run docker run luncho-server_app

(Optional) Generation of client libraries with OpenAPI generator, patch a generated file and build

pypy3 main.py gen bin/build.sh

Test

  • Unit test server
    • pytest test/test_server.py
  • Unit test Python client library
    • bin/start-gunicorn.sh
    • pytest test/test_client_lib.py
  • Unit test Python client library generated by the Open API generator
    • cd ../luncho_python/test; pytest

Author

Dr HIRANO Satoshi, Peace and Passion, University of Tokyo (AIST)

Copyright 2019-2022 The National Institute of Advanced Industrial Science and Technology (AIST), Japan