Development
The following guide is intended to help developers who maintain or want to make changes to the Nexus Graph.
Prerequisites
- Node 18 (Install instruction can be found here)
- Yarn (
npm install --global yarn
)
-
Xcode CLI tools: We'll need to first install Xcode CLI tools. Run this command and follow the instructions
xcode-select --install
-
Homebrew: Install Homebrew, and then run the following command to install GPG as we will need it later
brew install gnupg
Getting the Source Codes
To get started, clone the repo:
git clone git@github.com:QubitPi/nexusgraph.git
cd nexusgraph
We're going to be working out of this repository for the remainder of the setup.
Configuring Environment Variables
Simply use the .env.dev:
cp .env.dev .env
We can now skip the rest of the section. In case one needs more details, however, the details below discusses each them
Create a .env
file which contains all Dev runtime variables Nexus Graph needs. The following table
summarizes all of the variables Nexus Graph possibily needs:
Config Name | Required in Dev | Required in Test | Required in Prod |
---|---|---|---|
NLP_CLIENT | ✅ | ✅ | ✅ |
NLP_API_URL | ❌ | ❌ | ✅ |
GRAPH_API_CLIENT | ✅ | ✅ | ✅ |
GRAPH_API_ENDPOINT | ❌ | ❌ | ✅ |
SKIP_SIGN_IN | ✅ | ✅ | ✅ |
LOGTO_APP_ID | ❌ | ✅ | ✅ |
LOGTO_ENDPOINT_URL | ❌ | ✅ | ✅ |
LOGTO_API_RESOURCE_IDENTIFIER | ❌ | ✅ | ✅ |
LOGTO_SIGN_IN_CALLBACK_URL | ❌ | ✅ | ✅ |
LOGTO_SIGN_OUT_REDIRECT_URL | ❌ | ✅ | ✅ |
TEST_USER_EMAIL | ❌ | ✅ | ❌ |
TEST_USER_PASSWORD | ❌ | ✅ | ❌ |
-
NLP_CLIENT is the type of AI client for AI Named Entity Extraction. Allowed values are
JsonServerClient
is for dev and testTheresaClient
is our paid AI service
-
NLP_API_URL is the URL of AI Named Entity Extraction service
-
GRAPH_API_CLIENT is the type of Graph API client for CRUD operations. Allowed values are
JsonGraphQLServerClient
is for dev and testAstraiosGraphClient
is our paid Graph API serivce
-
GRAPH_API_ENDPOINT is the URL of the Graph API service. Define the endpoint that sends GraphQL requests to Astraios in our paid service.
提示Astraios is a JSR 370 web service template that lets us spin up model driven GraphQL or JSON API web service with minimal effort.
-
Authentication: Logto offers a comprehensive identity solution covering both the front and backend, complete with pre-built infrastructure and enterprise-grade solutions. In the Nexus Graph we use Logto to verify that the user has logged in and automatically generate the user login page
-
SKIP_SIGN_IN is a flag variable which must be set to
true
in Dev andfalse
in Test & Prod environments -
LOGTO_APP_ID is the standard logto app ID
-
LOGTO_ENDPOINT_URL is the URL of our server that will receive the webhook POST requests when the event occurs.
-
LOGTO_API_RESOURCE_IDENTIFIER is the ID of Logto API resource associated with the access token
-
LOGTO_SIGN_IN_CALLBACK_URL is the redirect URL after authentication
提示Redirect URI is an OAuth 2.0 concept which implies the location should redirect after authentication
-
LOGTO_SIGN_OUT_REDIRECT_URL is, similarly, the redirect URL after logging out of Nexus Graph
-
TEST_USER_EMAIL defines a user name dedicated to local login in test. Email is used for sign-in with username and password.
-
TEST_USER_PASSWORD is used for sign-in with username and password. In Nexus Graph the TEST_USER_PASSWORD defines a password dedicated to local login
-
Installing Dependencies
Nexus Graph uses yarn workspace to manage different components.
The command below shall install all the dependencies and put them in node_modules
:
yarn
Once this command has finished we'll have Nexus Graph ready in development mode with all its required dependencies.
Starting Nexus Graph
Starting Dev AI Server
yarn start:ai
NER data source is backed by json-server mock. They can be viewed by the following 3 links:
Starting Graph API Services
The schema is designed so that creating a new graph/node/link will auto generate a database ID. This is very important because we want to make surrogate key a read-only field on client side.
yarn start:graph-api
Entering http://localhost:5000/ will open up the GraphiQL:
Starting Nexus Graph in Dev Mode
Finally we can run the development server at http://localhost:3000:
yarn start