Closed martindale closed 9 years ago
Awesome work. Reviewing. First thought is that there is a super huge amount of commits here ... that may be fine for this PR so we can keep the commit history, but normally that wouldn't be the case.
Yes, quite a few commits – I started the original project over a year ago, and this simply extends that work. I'm happy to squash everything into several logical commits if that makes more sense from a historical perspective.
First of all, I think we should consider pulling this in since it would be a way to demo what we want the thing to be. It would be nice to have an app that we can all work on. And getting to a demo quickly will help validate the idea. However I have criticisms:
So my basic suggestions are:
I'm worried this PR may go too far in the direction of "make something that looks like it works so we can show people", but that doesn't actually solve the problem we're trying to solve, and will make it harder to solve the problem, because it introduces a bunch of patterns that may be inappropriate once we actually solve them.
Good feedback. As discussed on Slack, I do already plan on addressing several of these items – not the least of which is isomorphism, which also depends on writing a new datastore for Maki that replaces the MongoDB dependency. This is already planned (see martindale/maki#58), just will be accelerated for inclusion here.
Other relevant issues that address your points include martindale/maki#21 (P2P requirement), martindale/maki#77 (View Compositing), and martindale/maki#80 (Offline Sync, or network independence).
I'll have more updates come daybreak. Thanks for the extensive review!
Eric, I don't believe Maki or Converse are appropriate technologies for datt. It doesn't seem to me that Maki solves any of our problems. Converse looks like a centralized bulletin board. I don't believe we are better off trying to leverage this technology. I think it will make things harder.
When I worked at reddit, I collaborated with Chain to add a bitcoin tipping feature into reddit. Since reddit.com is open-source, this was easily done. It took one day. If we wanted to start with an existing reddit-like repository, reddit itself is an option. However, we did that only because I worked at reddit. Trying to take that project and make it decentralized means we start with a huge amount of technical debt. None of it was designed with decentralization in mind. It is harder to convert a centralized application and make it decentralized because everything has to be rethought.
I believe the way forward is to build the p2p protocol I outlined along with a database into an app that works both in node and a browser. Browser-side, we hook this app up to the datt ember UI along with the datt design work. I don't see any way Maki or Converse helps with that.
On the contrary, Maki's been built from the ground up with decentralization in mind – take a look at the fabric
branch to see how peer-to-peer messaging works between nodes (tracked since last October in martindale/maki#21). It should to be much easier to leverage the infrastructure I've established for all the other Maki-powered apps, and I think we'll get it done faster.
I mentioned yesterday that I now have the peer messaging working in the browser; I'll be pushing an update to this pull request once I've consumed your proposal for the protocol, and can include a working demo of multiple nodes communicating. I've also begun migrating the datastore class towards an isomorphic store, but we shouldn't wait on that change – in the "make it work, make it right, make it fast" mantra, we're still in the "make it work" part.
I don't have any particular affinity to Maki over building something from scratch here, but I am fairly convinced that we're incredibly close to a working prototype already and think we should move forward with what we have.
We've settled on an architecture based on what was datt-node and dat-react.
This imports all the work I've added on top of the
converse
base. There's another WIP proposal (martindale/converse#24) that pulls the changes into converse itself, but that's largely for archival purposes. This pull request implements the API and messaging infrastructure for a single local node, to later be joined to the p2p network as described by @ryanxcharles.How this works, generally: Models that are specific to the DATT network are defined as Maki "Resources", which have a static set of methods (query, update, destroy, etc.), hooks (
pre:create
, etc.), and events (vote
andgilding
, for example). Here, we define the loose behaviors that are necessary for a single node to validate individual operations (or "transactions") that mutate the state of the DATT database for a single node.Most of the core logic is in
index.js
. While monolithic and somewhat daunting at ~400 lines, this can easily be broken out and modularized – I propose a simple folder with one-resource-per-file, perhaps in a location like./resources
.API documentation is also automatically exposed via
/api
. For an example, take a look at the currently deployed converse API.