0

I've come across Graph Databases recently and I am wondering how much sense does it make to use in my scenario and I'd like some more expert advice on it. I am building microservices for an application and I am currently using Postgres as my data source. My simplest scenario is as follow:

  • Users can purchase Items from a Venue.
  • When the total amount spent in Items is equal to X (e.g. $5) the User receives a Bonus Point
  • A Venue can give away a Reward in exchange of N Bonus points
  • A Venue has to keep track of the number of purchases and the number Rewards given out
  • The User has to track how many Bonus points has earned from a specific Venue

At the moment I am using, as mentioned earlier, Postgres. Each of the components in here are a microservice, so Users have a microservice and a database, Venues have another and Transactions have another one. Here a diagram to visualize it better.

enter image description here

I hope it makes it clear that I would have to query and assemble a lot of the data on the fly based on the request needed. So for instance in order to get how many Bonus Points a User has for a specific Venue I would need to create a table in my User Service where I store how many more purchases a User has to do in a particular Venue to get Bonus Points and how many Bonus Points does a User have in a particular venue to spend and how many Rewards a User has redeemed from a Venue. So, yeah, it gets ugly very quickly. Considering then that I need the reverse as well from the Venue point of view for metrics.

Now it looks to me like a Graph database would be a great fit for this implementation, as every node has a direct relationship to the next node and therefore would be more efficient and less complex to query the data.

So I would have my REST endpoints which use Postgres to retrieve simple user data (such as name, email etc...) or venues data (such as venue name, co-ordinates etc...) and then use the user/venue id to query the graph database for the rest of the information. I could even remove the transaction microservice at this point. Something like this

enter image description here

What would be the actual Pros and Cons of this type of architecture? Does it actually make sense?

Thank you for your kind responses

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.