While exploring ideas to try out the Redis database service, software engineer Simon Prickett from San Diego decided to build a mock transit ticketing system. Redis is an open source database service that supports multiple different data structures such as strings, hashes, and lists.
Prickett’s goals for the project included building a sales terminal that would allow users to complete transactions for the transit system, an entry gate where commuters would use their passes to gain entry to the transit system, and a system monitor that would log all events happening in said system. How many times can I use the word system in a sentence?
Utilizing a kit available from MonkMakes, the Clever Card Kit, the transit pass comes in the form of an RFID card, or a smart card as it is referred to in this project. The smart card will be re-usable and is used to interact with the sales terminal and entry gates. The sales terminal lets users purchase more transit passes and relay any necessary information to the Redis database, while the entry gate will read the user’s smart card and send the information to Redis to inform the system if the user’s overall pass count should be decremented.
Redis Labs will enable developers to use their cloud to host databases up to 30Mb in size for free after a brief setup period. This option was chosen to prove out the transit system project and to get a brief introduction to Redis. The sales terminal and the entry gate are the two parts of the project that are configured to interact with the database. After reading a user’s smart card and purchasing information, the sales terminal will send the smart card’s serial number and purchase information to the database. This information is stored as data associated with a user’s card. Furthermore, the project was taken a step further by providing different options a user has to purchase. This included a single-use pass, ten-trip pass, and a two-hour pass.
On the other hand, the entry gate reads a user’s smart card and then completes an action based on the type of transit pass the user has. For single use passes it will delete the serial number from the system representing that the card is no longer valid. For multiple passes, it will decrement the number of passes remaining. As for the system monitor, it does not use the database part of Redis at all but rather outputs information about the state of the system through messages received from Redis.
A much more detailed description of the project can be found on the project creator’s write up and demo of the project. Also included is the software workflow as well as many snippets of the code used in the Raspberry Pi. For just looking to try out the Redis database, this projects sure went the extra mile to demo the system.