We're currently trying to break down our monolith in microservices and I have currently a problem with a use case.
We have the following use cases/requests from the client
- The user can get bookdetails
- The user can manage private booknotes
- The user can manage private favoritelists of books
now we created a complex access process. there are a few filter which declare if you have a visibility on those books. They can change always as example, the customer buys a new subscription and have instant access to those books. Every request with a book, has to use this access logic. in most use case it's a simple access service, which returns if you have access to a book or not. So we can theoretically create a "access microservice".
But in the favoritelist we have a paging on the sql request. In this sql request are all the access filter included, which is indeed really painfully. My problem now is, how can I create a paging favoritelist, where another microservice defines a filter.
Currently my best solution is to get all favorites of a customer, filter all those favorites with the access service in cache and then make a paging in cache. But as always, there are customer with about 5'000 books in their favoritelist.
It sounds odd, that you can have a book in your favoritelist, which you can't see. This is because your subscription can expire and we don't want to remove this books from your favoritelist, if you buy a new subscription. Also there are different devices which have a smaller amount of books available. Which means on the website you can see the book, but on the smartphone app probably not. (there are different apps for different use cases)
How can I split those use case in good microservices? I'm currently reading alot about microservice and they say the microservice shouldn't call each other. How should the favoritelist service know which books a customer have access on the current device? the access service has a really large cohesion with almost every service, how can I remove this cohesion? I can't cache the access of a customer on the favoritelist service (we have about 1mio books and customers.).