TigerBeetle Database powering bus ticket booking app

Sumeet More
3 min readNov 14, 2023

--

Disclaimer: This article is based on my current knowledge and understanding. If you have any query or see any improvement, please mention in the comment section. Currently I am not able to run Tigerbeetle DB on my local windows laptop so will update implementation section accordingly.

Recently TigerBeetle Database team had organized hackathon. Unfortunately I was not able to participate . However, I am a big fan of their database so I thought I will write a blog of idea which I would have submitted in hackathon. Here we go!!

Premise of our hackathon idea — Booking a bus ticket via app is great way to organize your long distance travel. During festive seasons or holiday seasons, this bus ticket booking app might face huge traffic and app should be able to deliver good experience in such scenario. Here is where TigerBeetle DB will help us to design an innovative product.

TigerBeetle is the world’s fastest financial accounting database(source of this information)

Before we start our discussion on architecture and implementation, one very important piece of information I want to share is wallet feature of this app. Our bus ticket booking app will have wallet feature where end users will put their money and while booking a ticket balance from wallet will be used. This wallet feature will be powered by Tigerbeetle DB as it is financial accounting database.

Architecture discussion —

W.r.t huge traffic, either app can give back user confirmation of their seat in same request or can accept their request and update user with final status after few seconds. I think later approach( i.e. informing user final status after few seconds) is more scalable in terms of architecture since it gives system some breathing space plus it improves user experience . We will go ahead with this approach.

There will be three tables in our NoSQL DB — tbl_user_requests, tbl_user_rquest_status,tbl_tickets_avaliability

tbl_user_requests will be used to store information of user requests and structure of the table is as shown below:

request id | user id | bus id | seat number

tbl_user_request_status will be used to store status of user requests and structure of the table is as shown below:

request id | status

tbl_tickets_availability will be used to know if particular seat is avaliable or not and structure of the table is as shown below:

bus id | seat number | is Available

Architecture flow:

First step— End users will call api to book bus ticket and request information will be saved in table tbl_user_requests.

Second and third step — Tigerbeetle DB has a powerful feature of performing batching processing to maximize throughput. So worker process will fetch batch of records from tbl_user_requests in every second and perform below steps

  • After fetching batch of records from tbl_user_requests, fetch all records from tbl_tickets_avaliability ( this information can be cached but for this article, I am keeping things simple as there is lot of moving parts already present in architecture)and discard records from batch of records of tbl_user_requests table who have requested for the seats which are already occupied.
  • Once we get filtered batch of records, worker process will submit this batch of records to Tigerbeetle DB to perform payment step.
  • Once we get response from TigerBeetle DB, worker process will update tbl_user_request_status table and tbl_tickets_availability table accordingly.

Fourth Step — end user’s mobile or web app will get updated by real time api based on latest information from tbl_user_request_status

Implementation Discussion [in progress] —

All APIs and worker process will be developed in .NET 7/.NET 8 . Currently I am facing below errors while running tigerbeetle db locally and I am trying different ways to resolve it.

Docker:

Exe:

~ Happy Coding

--

--

Sumeet More
Sumeet More

Written by Sumeet More

Software Engineer 2 at Microsoft | Backend Engineer and Architect| Blockchain & ML enthusiast | C#,.NET Core, Rust, Javascript and Go

Responses (2)