Giter VIP home page Giter VIP logo

food-delivery's Introduction

Food Delivery

A demo backend for food delivery which is written in Java 11 with Gradle build tool and uses MySQL as database.

Setup Database

  • Download MySQL docker image:
docker pull mysql:5.7
  • Start MySQL with root password and a local folder for persisting MySQL data. Replace YOUR_LOCAL_FOLDER with your local folder and YOUR_PASSWORD with your password.
docker run -d -p 3306:3306 -v YOUR_LOCAL_FOLDER:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=YOUR_PASSWORD --name mysql mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

Create Database Schema

Change to sql/ directory, run the following command to create database schema:

docker exec -i mysql mysql -uroot -pYOUR_PASSWORD < schema.sql

Install JDK

Install JDK 11 if you don't have. Please follow the document on AdoptOpenJDK to install.

Build App

Under the project root directory, run the following command, it will create an jar(eg: fd-0.0.1-SNAPSHOT.jar) file in build/libs/:

./gradlew build -x test

Create App Docker image

Jib is used to create Java docker image:

./gradlew jibDockerBuild

You can find the image food-delivery by:

docker images

Load Raw Data to Database

There are two raw data sources:

If the raw data sources changed, please use RESTAURANT_DATA_URL and USER_DATA_URL as environment variables to pass correct URLs to Docker, eg:

RESTAURANT_DATA_URL=https://.../restaurant_with_menu.json

USER_DATA_URL=https://.../users_with_purchase_history.json

Run the following command to extract, transform and load data to database, set the environment variable LOAD_DB_DATA as:

  • 1: to load raw restaurant data only.
  • 2: to load raw user data only.
  • 3: to load both restaurant and user data.
docker run -i -e DB_URL=mysql:3306 -e LOAD_DB_DATA=3 --rm --link mysql:mysql --name food-delivery food-delivery

Or you can run the app directly by:

LOAD_DB_DATA=3 java -jar build/libs/fd-0.0.1-SNAPSHOT.jar

Run App

Run the app by the following command:

docker run -d -p 8080:8080 -e DB_URL=mysql:3306 --link mysql:mysql --name food-delivery food-delivery

API Doc

  • After starting the app, you can browse the REST API doc on http://localhost:8080/swagger-ui.html.
  • Or there is an Open API yaml document under apiDoc/, you can use any Swagger Viewer to view the document.

food-delivery's People

Contributors

yenchu avatar

Watchers

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