We love when a member of our developer community reaches out to us to tell us about something awesome they built using MarkLogic. This spotlight is on an application built by Jeff White, president of SyncOasis, to be a sample three-tier architecture using Vue.js in the client layer, Node.js/Express as the middle tier processing all of the business logic, and MarkLogic as the database.
If you have something you would like to share, please reach out to us at community firstname.lastname@example.org.
Q: How did you start working with MarkLogic? How long ago was that?
Jeff: I was trained as a Property and Casualty Insurance actuary and spent over 20 years in that career, with many of those years in senior leadership roles. Actuaries provide analytical information to insurance leaders and in some ways are like data scientists. In my work as an actuary, I spent much of my time creating the data stores used by the broader actuarial team. Since 2014, I have focused solely on improving how insurance companies use data.
I have been using MarkLogic since Spring 2017. I believe a document data store is the right database for insurance data since that data is (1) naturally hierarchical and (2) has many use cases for array data types. MarkLogic’s search and semantic capabilities, along with its encryption and security, make it a strong fit for insurance data.
Q: What inspired you to build this song-tracker app? Can you tell us a little bit about what it does?
Jeff: I wanted to better understand MarkLogic’s capabilities and its APIs, so I built a reference app using MarkLogic, Express, Node.js, and Vue.js. I also wanted to build an app with no MarkLogic server-side logic, so I could explore the full capabilities of the MarkLogic Node.js API.
My song-tracker app is based on the tab-tracker YouTube video series by Cody Seibert, which illustrates how to build an app in Vue.js. My song-tracker app allows the user to keep track of metadata for songs entered into the database. Once the user authenticates with the app, they can create new songs, “like” or bookmark existing songs, and edit existing songs. The individual song page contains the song metadata, lyrics, and YouTube music video.
I also wanted to help other new users, like myself, better understand how to use MarkLogic, so I open-sourced the app as a sample application. If I had found an app like this when I started delving into MarkLogic, it would have accelerated my learning.
Q: So how did it go? Any tips to share?
Jeff: Although I do not come from a traditional software engineering background, I do use programming languages and SQL when building data stores. Since I’m relatively new to software creation, it was no surprise to me that I encountered some hiccups along the way (such as how to properly use an iframe 😊); but overall, I found the process to be straightforward.
Implementing the app in a document-data model was much simpler and intuitive than in a relational database. For example, if I were to use a relational model to add the song “likes” or bookmarks to the database, I would have to use an extra mapping table to join the user table to the songs table. In the document-data model, I only needed to add an array of user URIs to the song document, which was far easier to implement and manage!
Here’s a tip about data modeling in the document world: there are usually multiple ways you can model your data, so your data model choice should be based on how you plan to use the data. In my case, I added an array of user URIs to the song document, which allows us to search the song documents for a single user URI. I could have added an array of bookmarked song URIs to the user document, but then I would need to search the song documents for multiple song URIs, which is a somewhat more complex search.
Q: What resources did you use to help you build the app?
Jeff: I wish I had found the examples included in the MarkLogic Node.js package earlier (under node_modules/marklogic/examples directory), they really helped me out. I also found that I needed to develop a strong understanding of MarkLogic’s search capabilities, as there are many ways to build searches in MarkLogic, so I relied on MarkLogic’s robust online documentation. I had also taken MarkLogic’s Developing MarkLogic Apps I – Node.js class, and often referred to that documentation.
Q: What are your plans for the future of this app? Can others collaborating with you?
Jeff: If there is interest from other users, a few enhancements I would like to add to my app are:
- A startup program that sets up the MarkLogic server (Forests, Databases, App Servers) with the proper settings and loads the seed data
- Showing facets on the songs page, allowing the user to filter by the song metadata
- Allowing more than the first 10 results in the songs page, with pagination for larger result sets
GitHub users are welcome to create issues in the app repository. You can email me at email@example.com.
Q: Looking back, are you happy with the outcome?
Jeff: I am pleased with how the app turned out. I plan to use this app as the base for future software development.
Want to follow along on Jeff’s journey?
- Read the Search Developer’s Guide
- Get Started with the Node.js Client API
- Take the 3-day MLU course on Developing MarkLogic Apps in Node.js
- Read the Node.js Application Developer’s Guide
- Review the examples in the MarkLogic node.js package. After installing the MarkLogic Node.js package to your project directory with ‘npm install marklogic’, examples can be found at <project directory>/node_modules/marklogic/example. Within the example directory, please read the ‘1readme.txt1 file for further information on configuring the examples.
- Go to the GitHub repository
- See screenshots of the application below
Figure 1: Listing of all songs, bookmarks, and recently viewed songs
Figure 2: Individual song page with metadata and lyrics
Figure 3: Edit song interface