{"id":14969084,"url":"https://github.com/mariadb-corporation/dev-example-bookings","last_synced_at":"2025-10-26T06:30:59.391Z","repository":{"id":42279655,"uuid":"252234081","full_name":"mariadb-corporation/dev-example-bookings","owner":"mariadb-corporation","description":"A web application (with multiple API project options) that uses MariaDB HTAP!","archived":false,"fork":false,"pushed_at":"2022-12-12T11:44:06.000Z","size":28106,"stargazers_count":12,"open_issues_count":4,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-31T16:11:48.913Z","etag":null,"topics":["mariadb","mariadb-connector","mariadb-database","mariadb-htap","mariadb-server","mariadb-skysql","nodejs","python","python3","reactjs"],"latest_commit_sha":null,"homepage":"https://mariadb.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mariadb-corporation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-01T16:50:20.000Z","updated_at":"2025-01-11T14:54:35.000Z","dependencies_parsed_at":"2023-01-27T18:46:46.180Z","dependency_job_id":null,"html_url":"https://github.com/mariadb-corporation/dev-example-bookings","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariadb-corporation%2Fdev-example-bookings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariadb-corporation%2Fdev-example-bookings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariadb-corporation%2Fdev-example-bookings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariadb-corporation%2Fdev-example-bookings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mariadb-corporation","download_url":"https://codeload.github.com/mariadb-corporation/dev-example-bookings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238276041,"owners_count":19445330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mariadb","mariadb-connector","mariadb-database","mariadb-htap","mariadb-server","mariadb-skysql","nodejs","python","python3","reactjs"],"created_at":"2024-09-24T13:41:06.423Z","updated_at":"2025-10-26T06:30:58.688Z","avatar_url":"https://github.com/mariadb-corporation.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bookings\n\n**Bookings** is a web application that, backed by the power of the MariaDB Connectors and the [MariaDB X4 Platform](https://mariadb.com/resources/blog/deploying-mariadb-platform-x4/#smart), unleashes the power of [smart transactions](https://mariadb.com/resources/blog/introducing-mariadb-platform-x4-smart-transactions-and-cloud-native-storage/) on hundreds of millions of records with lightning fast query performance without having to add any indexes!\n\n\u003cp align=\"center\" spacing=\"10\"\u003e\n    \u003ckbd\u003e\n        \u003cimg src=\"media/demo.gif\" /\u003e\n    \u003c/kbd\u003e\n\u003c/p\u003e\n\nThis 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.\n\n**Note:** The code provided within this repository is completely open source. Please feel free to use it as you see fit.\n\n# Table of Contents\n1. [Requirements](#requirements)\n2. [Getting started with MariaDB](#introduction)\n3. [Get the code](#code)\n4. [Set up the HTAP database instance](#getting-started)\n    1. [Get the data, create the schema, and load the data](#data)\n    2. [Set up replication](#htap-replication)\n    3. [Create app data](#app-data)\n5. [Set up the web application](#application)\n    1. [Anatomy of the app](#app-anatomy)\n    2. [Build and run the app](#build-run)\n6. [Additional resources](#resources)\n    1. [Smart transactions](#smart-transactions)\n    2. [Cross-engine queries](#cross-engine-queries)\n7. [Support and Contribution](#support-contribution)\n8. [License](#license)\n\n## Requirements \u003ca name=\"requirements\"\u003e\u003c/a\u003e\n\nThis sample application, no matter which API project you target, will requires the following to be installed/enabled on your machine:\n\n* [MariaDB Client](https://mariadb.com/products/skysql/docs/clients/), used to connect to MariaDB instances.\n* [Bash](https://www.gnu.org/software/bash/) (if you are using Windows 10, you will need to enable the Windows Subsystem for Linux), used to run the data download script\n\n## Getting started with MariaDB \u003ca name=\"introduction\"\u003e\u003c/a\u003e\n\n[MariaDB](https://mariadb.com) is a community-developed, commercially supported relational database management system, and the database you'll be using for this application.\n\nIf you don't have a MariaDB database up and running you can find more information on how to download, install and start using a MariaDB database in the [MariaDB Quickstart Guide](https://github.com/mariadb-developers/mariadb-getting-started).\n## Get the code \u003ca name=\"code\"\u003e\u003c/a\u003e\n\nDownload this code directly or use [git](git-scm.org) (through CLI or a client) to retrieve the code using `git clone`:\n\n```\n$ git clone https://github.com/mariadb-corporation/dev-example-bookings.git\n```\n\n## Set up the HTAP database instance \u003ca name=\"getting-started\"\u003e\u003c/a\u003e\n\nIn 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](https://mariadb.com/get-started-with-mariadb/)\".\n\n### Get the data, create the schema, and load the data \u003ca name=\"data\"\u003e\u003c/a\u003e\n\nThis application uses (US domestic) flight data freely available from the [Bureau of Transportation on time performance dataset](https://www.transtats.bts.gov/DL_SelectFields.asp?Table_ID=236\u0026DB_Short_Name=On-Time). The [get_flight_data.sh] shell script will be used to download the flight data (between 1990 and 2020) into a folder called _data_. \n\nComplete the following steps.\n\n1. 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](get_flight_data.sh) script to adjust the amount of flight information that is downloaded. Doing so will not disrupt subsequent steps. \n\n```bash \n$ ./get_flight_data.sh\n```\n\n2. Create the databases and tables load data. Be sure to include your database instance specific information (host url, port number, username, and password)\n\n```bash\n$ ./create_and_load.sh host_url port user password\n```\n\n**Note:** Remember to wrap argument values in single quotes if they contain special characters (e.g. !)\n\nBy default the [create_and_load.sh](create_and_load.sh) script has ssl enabled and assumes a MariaDB [SkySQL certificate authority chain file](https://mariadb.com/products/skysql/docs/operations/connecting/#certificate-authority) exists next to it. Feel free to modify accordingly.\n\n### Set up replication \u003ca name=\"htap-replication\"\u003e\u003c/a\u003e\n\nUsing 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. \n\nCombining MariaDB replication with MariaDB MaxScale configured as a Binlog Server, MariaDB Enterprise Server can host InnoDB and ColumnStore on the same server.\n\nThis application uses replication on a single table called `flights`, which exists `travel.flights` (InnoDB) and `travel_history.flights` (ColumnStore).\n\n#### Direct access\n\nTo set up replication on an HTAP instance you have direct access to add the following [replication filter](https://mariadb.com/docs/deploy/htap/#filter-configuration) to the MaxScale configuration file (`/etc/maxscale.cnf`).\n\n```\n[replication-filter]\ntype         = filter\nmodule       = binlogfilter\nmatch        = /[.]flights/\nrewrite_src  = innodb\nrewrite_dest = columnstore\n```\n\nFor more information on configuring MariaDB HTAP please review the official [Enterprise Documentation](https://mariadb.com/docs/deploy/htap/#maxscale-configuration).\n\n#### SkySQL\n\nMariaDB SkySQL provides MariaDB Platform for Smart Transactions service, delivering HTAP capabilities. Simply connect to a MariaDB SkySQL (HTAP) instance and execute the following queries.\n\nCreate a replication filter.\n\n```sql \nSELECT set_htap_replication('flights','travel','travel_history');\n```\n\nConfirm a replication filter has been added.\n\n```sql\nSELECT show_htap_replication();\n```\n\nFor more information on configuring HTAP replication for SkySQL please check out the [official documentation](https://mariadb.com/products/skysql/docs/operations/htap-replication/).\n\n### Create app data \u003ca name=\"app-data\"\u003e\u003c/a\u003e\n\nThis application is merely meant for demonstration purposes so you will need to provide _relevant_ data within the following:\n\n* travel.flights\n* travel.tickets\n* travel.trips\n\n**Creating searchable flights**\n\nYou 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.\n\nAn upcoming flight (option) from LAX to ORD on May 5th, 2020.\n\n```sql\nINSERT 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);\n\nINSERT INTO `tickets` (`id`, `fl_date`, `fl_num`, `carrier`, `origin`, `dest`, `price`) VALUES (1, '2020-05-05', 1280, 'DL', 'LAX', 'ORD', 240.00);\n```\n\n**Creating upcoming trips**\n\nCurrently 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.\n\nAn upcoming trip from ORD to LAX on July 4th, 2020.\n\n```sql\nINSERT 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);\n\nINSERT INTO `tickets` (`id`, `fl_date`, `fl_num`, `carrier`, `origin`, `dest`, `price`) VALUES (2, '2020-07-04', 1170, 'DL', 'ORD', 'LAX', 276.00);\n\nINSERT INTO `trips` (`id`, `ticket_id`) VALUES (1, 2);\n```\n\n## Set up the web application \u003ca name=\"application\"\u003e\u003c/a\u003e\n\n### Anatomy of the app \u003ca name=\"app\"\u003e\u003c/a\u003e\n\nThis application is made of two parts:\n\n* Client\n    - communicates with the API.\n    - is a React.js project located in the [client](client) folder.\n* API\n    - uses a MariaDB Connector to connect to MariaDB.\n    - contains multiple projects, located in the [api](api) folder.\n        - [Node.js](api/nodejs)\n        - Python (coming soon!)\n\nSee the README's in [client](client/README.md) and [api](api/README.md) for more information on how to get started!\n\n### Build and run the app \u003ca name=\"build-run\"\u003e\u003c/a\u003e\n\n## Additional resources \u003ca name=\"resources\"\u003e\u003c/a\u003e\n\n### Smart transactions \u003ca name=\"smart-transactions\"\u003e\u003c/a\u003e\n\nAt this point you might be wondering, what are smart transactions?\n\nAt 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.\n\n**Pre-transaction**\n\nThis 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.\n\n\u003cp align=\"center\"\u003e\n    \u003ckbd\u003e\n        \u003cimg src=\"media/flight_1.png\" /\u003e\n    \u003c/kbd\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ckbd\u003e\n        \u003cimg src=\"media/flight_2.png\" /\u003e\n    \u003c/kbd\u003e\n\u003c/p\u003e\n\n**Post-transaction**\n\nThis application also uses real-time analytics after a flight has been booked, and a trip has been created. \n\n\u003cp align=\"center\"\u003e\n    \u003ckbd\u003e\n        \u003cimg src=\"media/trip_1.png\" /\u003e\n    \u003c/kbd\u003e\n\u003c/p\u003e\n\n### Cross-engine queries \u003ca name=\"cross-engine-queries\"\u003e\u003c/a\u003e\n\nThis 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.  \n\n\u003cp align=\"center\"\u003e\n    \u003ckbd\u003e\n        \u003cimg src=\"media/cross_engine.png\" /\u003e\n    \u003c/kbd\u003e\n\u003c/p\u003e\n\n## Support and Contribution \u003ca name=\"support-contribution\"\u003e\u003c/a\u003e\n\nPlease feel free to submit PR's, issues or requests to this project project or projects within the [official MariaDB Corporation GitHub organization](https://github.com/mariadb-corporation).\n\nIf you have any other questions, comments, or looking for more information on MariaDB please check out:\n\n* [MariaDB Developer Hub](https://mariadb.com/developers)\n* [MariaDB Community Slack](https://r.mariadb.com/join-community-slack)\n\nOr reach out to us diretly via:\n\n* [developers@mariadb.com](mailto:developers@mariadb.com)\n* [MariaDB Twitter](https://twitter.com/mariadb)\n\n## License \u003ca name=\"license\"\u003e\u003c/a\u003e\n[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=plastic)](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariadb-corporation%2Fdev-example-bookings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmariadb-corporation%2Fdev-example-bookings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariadb-corporation%2Fdev-example-bookings/lists"}