⚛ Event-based, functional data store. Bringing flux architecture to the backend.
👉 Flux architecture for the backend. Realtime data and time travel capabilities included.
Check out the 👉 Sample App to see the flux capacitor in action.
Alpha release - Keep your seatbelt fastened during the entire flight.
+------------------------+ +--------------------------------+
| Event: addUser | dispatch | Flux Capacitor Store | ╔══> Subscriber
| "Trump" | ══════════> +--------------------------------+ ║ (Websocket)
+------------------------+ | Event +-------------+ | Event ║
| ══════> | UserReducer | ════╗ | ════════╬══> Subscriber
+------------------------+ dispatch | +-------------+ ║ | ║ (Logger)
| Event: grantAccess | ══════════> | ║ | ║
| "Trump": "President" | | DB operations ║ | ╚══> ...
+------------------------+ +-----------------------------║--+
║
+--------------------------------------------------------║------+
| Database (after dispatching) ▽ |
+---------------------------------------------------------------+
| +-----------------------------------------------------------+ |
| | Events | |
| +-----------------------------------------------------------+ |
| | Dec 15 2008, 23:16:38 addUser "Barack" | |
| | Dec 15 2008, 23:17:14 grantAccess "Barack": "President" | |
| | Dec 19 2016, 22:40:05 addUser "Trump" | |
| | Dec 19 2016, 22:40:23 grantAccess "Trump": "President" | |
| +-----------------------------------------------------------+ |
| |
| +---------------+ +------------------------+ |
| | Users | | UserRights | |
| +---------------+ +------------------------+ |
| | Barack | | Barack "Ex-President" | |
| | Trump | | Trump "President" | |
| +---------------+ +------------------------+ |
+---------------------------------------------------------------+
And this is why event sourcing is awesome: We can always roll back to a consistent state 😉
Find code samples and real database data here:
You know what's better than writing a lot of good code? Writing only very few code that achieves the same!
< 20 SLOC
< 40 SLOC
< 40 SLOC
< 20 SLOC
< 10 SLOC
So how does it work? Find details here: Flux Capacitor Concept.
Reducers work slightly different. Their signature is (collection, event) => changeset
instead of (state, action) => state
. The action
and the event
are just synonyms. The real difference is that the flux capacitor reducers take a database collection and return a changeset (a set of database operations).
This is necessary, since we usually cannot hold the complete database in memory as opposed to Redux' state. Returning changesets makes it possible to write the reducers as pure synchronous functions, even though performing those database operations works asynchronously and might lead to side effects.
It is related to CQRS, but no traditional CQRS. Rather something between common CRUD and traditional CQRS.
Sacrificing the outstanding scalibility potential of full CQRS gives us the freedom to come up with some other nifty features instead:
Logo created by Sergey. Updated and refined by Jakob Mund. Thank you, guys!
The flux capacitor is released under the terms of the MIT license. See LICENSE for details.