Design
The following guide is intended for developers who want to make changes to the Nexus Graph. It will cover the design of various subsystems.
Module Layout
Elide is a mono-repo consisting of the following published modules:
Module Name | Description |
---|---|
nexusgraph-app | The user interface where user can use all features of Nexus Graph |
nexusgraph-db | Graph Data storage for nexusgraph CRUD API queries |
nexusgraph-graph | The core module that handles Graph rendering |
nexusgraph-nlp | The AI module that transforms text/audio into knowledge graphs |
nexusgraph-oauth | Handles Authentication |
nexusgraph-redux | The state management of the entire app |
High Level Design
The following diagram represents a high level component breakout of Nexus Graph. Names in italics represent class names whereas other names represent functional blocks (made up of many classes). Gray arrows represent module dependencies through the system.
Dependency Injection
In order to optimize our developer's experience, Nexus Graph runs against very different configurations in Dev/Test/Prod environments. This puts some challenges on the design of system. Dependency injection is one of them. For example, in dev mode, we want our UI engineer to go completely free by decoupling backend developments. We do that by running in-memory backend services. This means for those services, we need to automatically wire up different implementations in Dev and Prod environment.
To address that, we use Inversify to dynamically load 2 of our components:
- AI Entity Extraction Service
- Graph API Webservice
Redux Module
We are not using Redux Toolkit because we want greater control over our application states
We employ redux by defining a GlobalState and a bunch of slices, which include reduces, to manipulate these states.
The module also maintains the domain model of a "Graph" which includes 3 representations:
Basically, all Nexus Graph components agree on such data structure to model a graph. If a different representation is needed, such as in nexusgraph-graph module, where a node needs to encode its position on a graph canvas, a separate transformation would be needed
Please keep in mind that Nexus Graph uses intensively 2 of the Redux's recommended practices:
Graph Module
Our graph model is deeply nested, which causes a huge pain on Redux state update. We take an immutable approach to address such issue.
Database Module
Nexus Graph is storage agnostic.
Semantic layer: GraphClient
.
Our free version comes with an in-memory json-graphql-server. We can host our own on-premise production version with astraios.io, our official supported backend for storing graphs. Or we can implement our own graph API
json-graphql-server
cd nexusgraph
yarn start:graph-api
The server will be running at http://localhost:5000/.
There is a very useful debugging technique: if you click the axios request to the server from browser console, it will take you directly to the http://localhost:5000/ with the actual query printed on it, ready to be re-sent for debugging purposes.