A web application (with multiple API project options) that uses MariaDB HTAP!

Overview

Bookings

Bookings is a web application that, backed by the power of the MariaDB Connectors and the MariaDB X4 Platform, unleashes the power of smart transactions on hundreds of millions of records with lightning fast query performance without having to add any indexes!

This README will walk you through the steps for getting the Bookings web application up and running using MariaDB HTAP. To ensure success, please follow the instructions in order.

Note: The code provided within this repository is completely open source. Please feel free to use it as you see fit.

Table of Contents

  1. Requirements
  2. Introduction to MariaDB
    1. MariaDB Platform
    2. MariaDB SkySQL
  3. Get the code
  4. Set up the HTAP database instance
    1. Get the data, create the schema, and load the data
    2. Set up replication
    3. Create app data
  5. Set up the web application
    1. Anatomy of the app
    2. Build and run the app
  6. Additional resources
    1. Smart transactions
    2. Cross-engine queries
  7. Support and Contribution
  8. License

Requirements

This sample application, no matter which API project you target, will requires the following to be installed/enabled on your machine:

  • MariaDB Client, used to connect to MariaDB instances.
  • Bash (if you are using Windows 10, you will need to enable the Windows Subsystem for Linux), used to run the data download script

Introduction to MariaDB

MariaDB Platform

MariaDB Platform integrates transactional and analytical products so developers can build modern applications by enriching transactions with real-time analytics and historical data, creating insightful experiences and compelling opportunities for customers – and for businesses, endless ways to monetize data.

To get started using MariaDB locally you can:

MariaDB Hybrid Transactional-Analytical Processing (HTAP)

MariaDB Platform supports Hybrid Transactional-Analytical Processing (HTAP) through a combination of MariaDB Enterprise Server, MariaDB ColumnStore, and MariaDB MaxScale.

Here's a simple architecture diagram of MariaDB X4 Platform.

For more details on how to manually deploy MariaDB X4 please refer to the official documentation.

MariaDB SkySQL

SkySQL is the first and only database-as-a-service (DBaaS) to bring the full power of MariaDB Platform to the cloud, including its support for transactional, analytical and hybrid workloads. Built on Kubernetes, and optimized for cloud infrastructure and services, SkySQL combines ease of use and self-service with enterprise reliability and world-class support – everything needed to safely run mission-critical databases in the cloud, and with enterprise governance.

Get started with SkySQL!

Get the code

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

$ git clone https://github.com/mariadb-corporation/dev-example-bookings.git

Set up the HTAP database instance

In order to run the Bookings application you will need to have a MariaDB instance to connect to. For more information please check out "Get Started with MariaDB".

Get the data, create the schema, and load the data

This application uses (US domestic) flight data freely available from the Bureau of Transportation on time performance dataset. The [get_flight_data.sh] shell script will be used to download the flight data (between 1990 and 2020) into a folder called data.

Complete the following steps.

  1. Download the flight data (approx. 180 million records, ~30 GB). Depending on your internet connection this may take some time. However, you can simply modify get_flight_data.sh script to adjust the amount of flight information that is downloaded. Doing so will not disrupt subsequent steps.
$ ./get_flight_data.sh
  1. Create the databases and tables load data. Be sure to include your database instance specific information (host url, port number, username, and password)
$ ./create_and_load.sh host_url port user password

Note: Remember to wrap argument values in single quotes if they contain special characters (e.g. !)

By default the create_and_load.sh script has ssl enabled and assumes a MariaDB SkySQL certificate authority chain file exists next to it. Feel free to modify accordingly.

Set up replication

Using MariaDB replication, MariaDB Enterprise Server replicates writes from InnoDB tables to the ColumnStore tables, ensuring that the application can perform analytical processing on current data.

Combining MariaDB replication with MariaDB MaxScale configured as a Binlog Server, MariaDB Enterprise Server can host InnoDB and ColumnStore on the same server.

This application uses replication on a single table called flights, which exists travel.flights (InnoDB) and travel_history.flights (ColumnStore).

Direct access

To set up replication on an HTAP instance you have direct access to add the following replication filter to the MaxScale configuration file (/etc/maxscale.cnf).

[replication-filter]
type         = filter
module       = binlogfilter
match        = /[.]flights/
rewrite_src  = innodb
rewrite_dest = columnstore

For more information on configuring MariaDB HTAP please review the official Enterprise Documentation.

SkySQL

MariaDB SkySQL provides MariaDB Platform for Smart Transactions service, delivering HTAP capabilities. Simply connect to a MariaDB SkySQL (HTAP) instance and execute the following queries.

Create a replication filter.

SELECT set_htap_replication('flights','travel','travel_history');

Confirm a replication filter has been added.

SELECT show_htap_replication();

For more information on configuring HTAP replication for SkySQL please check out the official documentation.

Create app data

This application is merely meant for demonstration purposes so you will need to provide relevant data within the following:

  • travel.flights
  • travel.tickets
  • travel.trips

Creating searchable flights

You will need to supply future flights that can be booked. The process for this is to first add a flight and then create a ticket for that flight. Consider the following example.

An upcoming flight (option) from LAX to ORD on May 5th, 2020.

INSERT INTO `flights` (`year`, `month`, `day`, `day_of_week`, `fl_date`, `carrier`, `tail_num`, `fl_num`, `origin`, `dest`, `crs_dep_time`, `dep_time`, `dep_delay`, `taxi_out`, `wheels_off`, `wheels_on`, `taxi_in`, `crs_arr_time`, `arr_time`, `arr_delay`, `cancelled`, `cancellation_code`, `diverted`, `crs_elapsed_time`, `actual_elapsed_time`, `air_time`, `distance`, `carrier_delay`, `weather_delay`, `nas_delay`, `security_delay`, `late_aircraft_delay`) VALUES (2020, 5, 5, 5, '2020-05-05', 'DL', NULL, 1280, 'LAX', 'ORD', '0600', '0600', NULL, NULL, NULL, NULL, NULL, '0913', '0913', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

INSERT INTO `tickets` (`id`, `fl_date`, `fl_num`, `carrier`, `origin`, `dest`, `price`) VALUES (1, '2020-05-05', 1280, 'DL', 'LAX', 'ORD', 240.00);

Creating upcoming trips

Currently you need to create upcoming trips manually. To do this you will need to have a flight, ticket, and trip record. Consider the following example.

An upcoming trip from ORD to LAX on July 4th, 2020.

INSERT INTO `flights` (`year`, `month`, `day`, `day_of_week`, `fl_date`, `carrier`, `tail_num`, `fl_num`, `origin`, `dest`, `crs_dep_time`, `dep_time`, `dep_delay`, `taxi_out`, `wheels_off`, `wheels_on`, `taxi_in`, `crs_arr_time`, `arr_time`, `arr_delay`, `cancelled`, `cancellation_code`, `diverted`, `crs_elapsed_time`, `actual_elapsed_time`, `air_time`, `distance`, `carrier_delay`, `weather_delay`, `nas_delay`, `security_delay`, `late_aircraft_delay`) VALUES (2020, 7, 4, 2, '2020-07-04', 'DL', NULL, 1170, 'ORD', 'LAX', '1420', '1420', NULL, NULL, NULL, NULL, NULL, '1730', '1730', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

INSERT INTO `tickets` (`id`, `fl_date`, `fl_num`, `carrier`, `origin`, `dest`, `price`) VALUES (2, '2020-07-04', 1170, 'DL', 'ORD', 'LAX', 276.00);

INSERT INTO `trips` (`id`, `ticket_id`) VALUES (1, 2);

Set up the web application

Anatomy of the app

This application is made of two parts:

  • Client
    • communicates with the API.
    • is a React.js project located in the client folder.
  • API
    • uses a MariaDB Connector to connect to MariaDB.
    • contains multiple projects, located in the api folder.

See the README's in client and api for more information on how to get started!

Build and run the app

Additional resources

Smart transactions

At this point you might be wondering, what are smart transactions?

At their core, smart transactions are the standard transactions that databases have been performing for decades – ultimately powering the online interactions we’ve become accustomed to. The difference with modern applications is the use of real-time analytics before, during and/or after these transactions.

Pre-transaction

This application uses real-time analytics before a flight is booked. Each flight ticket option contains information calculated from the historical records (average delay, average duration, flight score, etc.) within the flights table.

Post-transaction

This application also uses real-time analytics after a flight has been booked, and a trip has been created.

Cross-engine queries

This application uses cross-engine queries to maximize the potentials of the MariaDB X4 Platform. Cross-engine querying is the ability to access, via MaxScale, both the transactional and analytics data within a single query.

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 [email protected] or on Twitter.

License

License

Owner
MariaDB Corporation
MariaDB Corporation
Simple Wayland HotKey Daemon

swhkd Simple Wayland HotKey Daemon This project is still very new and I'm making new decisions everyday as to where I should drive this project. I'm u

Aakash Sen Sharma 407 Dec 30, 2022
A bot to view Dilbert comics directly from Discord and get updates of the comics automatically.

A bot to view Dilbert comics directly from Discord and get updates of the comics automatically

Raghav Sharma 3 Nov 30, 2022
Learn the basics of Python. These tutorials are for Python beginners. so even if you have no prior knowledge of Python, you won’t face any difficulty understanding these tutorials.

01_Python_Introduction Introduction 👋 Python is a modern, robust, high level programming language. It is very easy to pick up even if you are complet

Milaan Parmar / Милан пармар / _米兰 帕尔马 245 Dec 30, 2022
Procedural 3D data generation pipeline for architecture

Synthetic Dataset Generator Authors: Stanislava Fedorova Alberto Tono Meher Shashwat Nigam Jiayao Zhang Amirhossein Ahmadnia Cecilia bolognesi Dominik

Computational Design Institute 49 Nov 25, 2022
Collatz Sanısını Test Eden Ve Kanıtlayan Bir Python Programı

Collatz Sanısı Collatz Sanısını Test Eden Ve Kanıtlayan Bir Python Programı. Kullanım Terminalde: 1- git clone https://github.com/detherminal/Collatz-

Cemal Mert 2 May 07, 2022
take home quiz

guess the correlation data inspection a pretty normal distribution train/val/test split splitting amount .dataset: 150000 instances ├─8

HR Wu 1 Nov 04, 2021
Aerial Ace is a helper bot for poketwo which provide various functionalities on top of being a pokedex.

Aerial Ace is a helper bot for poketwo which provide various functionalities on top of being a pokedex.

Devanshu Mishra 1 Dec 01, 2021
A command line interface tool converting starknet warp transpiled outputs into readable cairo contracts.

warp-to-cairo warp-to-cairo is a simple tool converting starknet warp outputs (NethermindEth/warp) outputs into readable cairo contracts. The warp out

Michael K 5 Jun 10, 2022
A collection of Workflows samples for various use cases

Workflows Samples Workflows allow you to orchestrate and automate Google Cloud and HTTP-based API services with serverless workflows.

Google Cloud Platform 76 Jan 07, 2023
A simple 3D rigid body simulation written in python

pyRigidBody3d A simple 3D rigid body simulation written in python

30 Oct 07, 2022
An example repository for how to generate results using PyBaMM

PyBaMM results This repository provides a template for generating results (for example, for a paper) using PyBaMM Installation Install PyBaMM using a

PyBaMM Team 7 Oct 09, 2022
Hartree-Fock Workshop for the Han-sur-Lesse Winterschool of 2021

Hartree-Fock course for the Han-sur-Lesse Winterschool of 2021 Requirements For going through these exercises, please install the Anaconda suite. Next

Ivo Filot 2 Nov 16, 2022
A project to find out all the words in a crossword.

A project to find out all the words in a crossword.

Kalpesh Dhoundiyal 1 Feb 06, 2022
Fried Chicken Programming Language

Fried-Chicken Fried Chicken Programming Language How To Run Once downloaded and opened, choose any file for code. Any file extensions work. Just make

Attachment Studios 9 Jul 11, 2022
A series of basic programs written in Python

Primeros programas en Python Una serie de programas básicos escritos en Python

Madirex 1 Feb 15, 2022
Generates Windows 95 and 95 OEM keys using the modulus 7 check algorithm

w95keygen-python windowskeygen.py - Generates Windows 95 and 95 OEM keys using the modulus 7 check algorithm Just download and drop in the directory y

Joshua Alto 1 Dec 06, 2021
A basic animation modding workflow for FFXIV

AnimAssist Provides a quick and easy way to mod animations in FFXIV. You will need: Before anything, the VC++2012 32-bit Redist from here. Havok will

liam 37 Dec 16, 2022
C++ Environment InitiatorVisual Studio Code C / C++ Environment Initiator

Visual Studio Code C / C++ Environment Initiator Latest Version : v 1.0.1(2021/11/08) .exe link here About : Visual Studio Code에서 C/C++환경을 MinGW GCC/G

Junho Yoon 2 Dec 19, 2021
A community-driven python bot that aims to be as simple as possible to serve humans with their everyday tasks

JARVIS on Messenger Just A Rather Very Intelligent System, now on Messenger! Messenger is now used by 1.2 billion people every month. With the launch

Swapnil Agarwal 1.3k Jan 07, 2023
Easy to use phishing tool with 65 website templates. Author is not responsible for any misuse.

PyPhisher [+] Description : Ultimate phishing tool in python. Includes popular websites like facebook, twitter, instagram, github, reddit, gmail and m

KasRoudra 1.1k Dec 31, 2022