Putting it All Together : a Technology Stack on top of a (Neo4j) Graph Database
(UPDATED June 2024) For many practical use cases, one needs a full data-management solution, not just a database.
So, armed with the Schema Layer discussed in the previous part, the next natural step is to add a web API and possibly a User Interface.
The Web API Layer / Data Manager
The Web API Layer ("Data Manager") is in some ways the most straightforward layer - because the "heavy lifting" is done by the Schema Layer.
I've been involved in projects that utilized an inadequate Schema Layer - and in those situations the API Layer ends up taking on an immense amount of responsibility that don't logically belong there; the end result being a lot of difficult, error-prone and non-modular development that feels like "pulling teeth"!
By contrast, with a well-developed Schema Layer that provides a wide range of services, it becomes a relative breeze to build an API Layer. The API Layer can then concentrate on roles that logically belong there, such as receiving JSON commands, parsing them, and invoking the appropriate methods of the Schema Layer and of the specialized libraries, which do most of the work.
With such a well-defined modular role, the development focus of the API Layer can be to provide a set of useful, convenient, and intuitive request-handling commands, typically for the UI and/or to provide a web endpoint.
The BrainAnnex.org project uses the Flask platform to provide a number of typical operations in this layer - such as to add or edit nodes in the database - and it's fairly easy to add additional operations... or duplicate this layer to meet one's needs.
The API Layer can also take on responsibilities such as:
- authentication
- implementing a master-slave architecture that doesn't require direct Neo4j database support (which would necessitate the licensed version of Neo4j.)
The Edge Between the Back End and the Front End
Let's consider a more detailed diagram of the architecture used in the Brain Annex project:
The above technology stack is explained in this short video.Note that Flask is being used for two separate purposes in this architecture:
1) to implement a web API
2) to serve dynamic web pages (with embedded Vue.js - or in principle REACT, etc - for high interactivity)
The reason I favor this combined approach is that it lends itself very well to the philosophy of gradual incremental changes : at an early stage, Flask can serve pages with little interactivity (such as reports, or just simple controls), to get things started. Over time, increased levels of interactivity can get grafted in, leading to a gradual handover of responsibilities from Flask to Vue (or other framework).
In the very early version of the web-app page, Flask has full responsibility over it - which won't win awards for graceful interactivity, but is infinitely better than not having anything!
In later versions, as development on that page progresses, Flask does little other that pass over the data to the front-end framework (embedded in the page and served by Flask); at page load, the front-end framework takes over most or all of the presentation and interactivity.
Of course, the front-end framework can also query the web API for any data not passed to it by Flask at page-creation time.
For submitting data to the server, such as forms, Flask can do in a clumsy "web 1.0" way (with page reloads) - which is a way to tide over until, upon further development, the front end takes over those tasks, and can do them with elegant interactivity, with no page reloads.
An alternate architecture, probably a more common approach, is to have standalone pages (NOT served by Flask), purely managed by the front-end framework... and only interacting with the backend thru web API calls. That's perfectly fine - but in that case you're starting your pages with zero, rather than enjoying a running start with quick-'n-dirty pages easily schlepped together by Flask. The Brain Annex project favors incremental approaches - but it's modular, and you can opt to utilize its layers thru the web API, and then do your own front end as it suits you.
The User Interface Layer
The API Layer takes care of the data management; so that the UI can focus on the front-end user experience.
As far as I'm concerned, excellence in the UI is truly "the final frontier"!
That's the layer that ultimately makes the fundamental difference for the user. Most users won't care if the system has "the engine of a Ferrari", if the vehicle looks and feels like a beaten-up junk car!
All the other layers are in place, and - while there's plenty of room for improvement (and for more documentation) - the foundations are fairly solid and extensive, and as of June 2024 the Brain Project layers below the UI are a hair away from leaving a late-Beta stage (and the NeoAccess library left the Beta stage long ago.) The UI is a different story; it's the cutting edge of development - and a lot of possibilities exist to explore.
The BrainAnnex.org project uses the Vue.js platform and the Cytoscape.js library to provide a dual modality for displaying/editing data: tabular form and graph form ("balls and edges".)
Also, BrainAnnex makes use of a Class-based UI, whereby some of the data Classes (as defined in the Schema layer) are associated with ad-hoc software ("plugins") to display/edit data of that class in a particular manner. Historically, the early versions of BrainAnnex utilized this approach to implement a multimedia content management system - but now that's just one use case.
The UI Layer is a very active area of development. Just like for the API Layer, one might opt to supplement, based on one's needs, the existing layer provided by BrainAnnex - or replace it with a custom one.
Things start getting especially exciting and powerful when the UI is aware of the different data types (for example, as specified in the Schema layer), and has the capability to personalize the display and editing mode of data records based on their types ("classes") - perhaps with plugins to provide modularity and easy expansion.
Well, that's exactly what the new version (5) of the open-source project Brain Annex does!
One use case of such a system is to be a multimedia content management system, which is what the old ("vintage") versions of Brain Annex was, before switching to being Neo4j-based, and morphing into a far more general system, a transition that started in late 2020 (project's history.)
Armed with an API, and possibly a UI, one can for example create a standalone web app, or a control panel for an existing website or web app. For example, the diagram at the very top of this page is how Brain Annex does it.
For more information about this layer, please see this short video.
Special-Purpose Modules
Now that we have a whole technology stack, how about looking into special-purpose modules? We'll do that across articles on a variety of special topics, such as a discussion (and available open-source implementation) of full-text search!
Comments
Post a Comment