title: Microservices Architecture: Cross Service data sharing
body: <p>Consider the following micro services for an online store project:<br>
  Users Service keeps account data about the store's users (including first name, last name, email address, etc')</p>
  
  <p>Purchase Service keeps track of details about user's purchases.</p>
  
  <p>Each service provides a UI for viewing and managing it's relevant entities.
  The Purchase Service index page lists purchases. Each purchase item should have the following fields:<br>
  id, full name of purchasing user, purchased item title and price.<br>
  Furthermore, as part of the index page, I'd like to have a search box to let the store manager search purchases by purchasing user name.</p>
  
  <p>It is not clear to me how to get back data which the Purchase Service does not hold - for example: a user's full name.
  The problem gets worse when trying to do more complicated things like search purchases by purchasing user name.</p>
  
  <p>I figured that I can obviously solve this by syncing users between the two services by broadcasting some sort of event on user creation (and saving only the relevant user properties on the Purchase Service end). That's far from ideal in my perspective. How do you deal with this when you have millions of users? would you create millions of records in each service which consumes users data?</p>
  
  <p>Another obvious option is exposing an API at the Users Service end which brings back user details based on given ids. That means that every page load in the Purchase Service, I'll have to make a call to the Users Service in order to get the right user names. Not ideal, but I can live with it.</p>
  
  <p>What about implementing a purchase search based on user name? Well I can always expose another API endpoint at the Users Service end which receives the query term, perform a text search over user names in the Users Service, and then return all user details which match the criteria. At the Purchase Service, map the relevant ids back to the right names and show them in the page. This approach is not ideal either.</p>
  
  <p>Am I missing something? Is there another approach for implementing the above? Maybe the fact that I'm facing this issue is sort of a code smell? would love to hear other solutions.</p>