title: How to connect Flux to Sinatra API
body: <p>I'm using React for a web application, and I've started learning about Flux. I like the concept of a unidirectional data flow, but I'm having some problems understanding how that connects to an API. </p>
  
  <p>I have a back end written in Sinatra. What I'm confused about is how does the data flow from an interaction with the component to the back end and back again? Is it that the database and what Flux calls a Store are two different things?</p>
  
  <p>The way I'm interpreting it is like this:</p>
  
  <p>User interacts with React View => </p>
  
  <p>Action Creator sends data to back end => </p>
  
  <p>back end responds to Action Creator with new data/success/error => </p>
  
  <p>Action Creator sends action and response to Dispatcher => </p>
  
  <p>the Dispatcher sees the action and calls the callback based on that Action, 
  passing it the back end response => </p>
  
  <p>the Store updates itself using the back end response => </p>
  
  <p>the Store sends the change event and the data to the React View => </p>
  
  <p>the React View renders => </p>
  
  <p>(cycle repeats)</p>
  
  <p><img src="https://i.stack.imgur.com/kiX29.png" alt="Flux flow"></p>
  
  <p>What confuses me is how the stores work. Do I need two stores like how I'm interpreting it? Or is the back end supposed to be the store?</p>