Mariadb-Developer-Examples/orders
Rob Hedgpeth d296119d31 Merge branch 'master' into skysql_field
# Conflicts:
#	bookings/src/db.js
#	flights/src/db.js
#	orders/src/db.js
#	places/src/db.js
2020-03-31 10:05:43 -05:00
..
media moved folders for casing 2020-02-26 16:46:35 -08:00
schema Update create.sql 2020-03-05 14:50:44 -06:00
src Merge branch 'master' into skysql_field 2020-03-31 10:05:43 -05:00
README.md moved folders for casing 2020-02-26 16:46:35 -08:00
create_schema.sh moved folders for casing 2020-02-26 16:46:35 -08:00

README.md

Orders

Orders is a web application written in React.js and Node.js that, backed by the power of the MariaDB Node.js Connector, introduces you to the power, performance, and simplicity of MariaDB by simulating online eCommerce (ordering) traffic.

The following will walk you through the steps for getting this application up and running (locally) within minutes! This application is completely open source. Please feel free to use it and the source code as you see fit.

Table of Contents

  1. Environment and Compatibility
  2. Getting start with MariaDB
    1. The Basics
    2. Create the schema
  3. Requirements to run the app
  4. Getting started with the app
    1. Grab the code
    2. Build the code
    3. Run the app
  5. Support and Contribution
  6. License

Environment and Compatibility

This sample was created using the following techologies:

This sample was tested on macOS v.10.14.6.

Overview

Introduction to MariaDB

MariaDB platform unifies MariaDB TX (transactions) and MariaDB AX (analytics) so transactional applications can retain unlimited historical data and leverage powerful, real-time analytics in order to provide data-driven customers with more information, actionable insight and greater value – and businesses with endless ways to monetize data. It is the enterprise open source database for hybrid transactional/analytical processing at scale.

Getting start with MariaDB

To download and deploy MariaDB check out the instructions here. You can also make use of the MariaDB Image available on Docker Hub.

Create the schema

Next you can create the schema necessary for this application by running

$ ./create_schema.sh

or executing the SQL within (create.sql)(schema/create.sql) directly

CREATE DATABASE `orders`;

CREATE TABLE `orders` (
  `description` varchar(100) NOT NULL DEFAULT ''
) ENGINE=InnoDB;

Requirements to run the app

This project assumes you have familiarity with building web applications using ReactJS and NodeJS technologies.

The following is required to run this application:

  1. Download and install MariaDB.
  2. Download and install Node.js.
  3. git (Optional) - this is required if you would prefer to pull the source code from GitHub repo.
    • Create a free github account if you dont already have one
    • git can be downloaded from git-scm.org

Getting started with the app

Grab the code

Download this code directly or use git (through CLI or a client) to retrieve the code.

Configure the code

Configure the MariaDB connection by adding an .env file to the Node.js project.

Example implementation:

DB_HOST=<host_address>
DB_PORT=<port_number>
DB_USER=<username>
DB_PASS=<password>
DB_NAME=<database>

The environmental variables from .env are used within the db.js for the MariaDB Node.js Connector configuration pool settings:

var mariadb = require('mariadb');
require('dotenv').config();

const pool = mariadb.createPool({
    host: process.env.DB_HOST, 
    user: process.env.DB_USER, 
    password: process.env.DB_PASS,
    port: process.env.DB_PORT,
    multipleStatements: true,
    connectionLimit: 5
});

Build the code

Once you have retrieved a copy of the code you're ready to build and run the project! However, before running the code it's important to point out that the application uses several Node Packages.

Executing the CLI command

$ npm install

within

  • src: the Node.js project
  • client: the React.js project

folders will target the the relative package.json file and install all dependencies.

Run the app

Once you've pulled down the code and have verified that all of the required Node packages are installed you're ready to run the application! It's as easy as 1,2,3.

  1. Using a command line interface (CLI) navigate to the src directory.

  1. Run the command:
$ npm start

  1. Open a browser window and navigate to http://localhost:3000.

Support and Contribution

Thanks so much for taking a look at the Bookings app! As this is a very simple example, there's plenty of potential for customization. Please feel free to submit PR's to the project to include your modifications!

If you have any questions, comments, or would like to contribute to this or future projects like this please reach out to us directly at developers@mariadb.com or on Twitter.

License

License