Code Monkey home page Code Monkey logo

cdk-neptune-knowledge-graph's Introduction

CDK Neptune Knowledge Graph

This CDK sample application deploys a Neptune cluster and a static web site to provide a convenient user interface for building a knowledge graph. It uses Cognito to provide authentication to the web site.

Note that this is sample code, and is not meant to be used in production!

What can I learn from this sample?

- How to structure a CDK application that includes multiple stacks
- How to provision a Neptune cluster with CDK
- How to connect to Neptune using JavaScript and Gremlin from a Lambda function
- How to configure API Gateway to use Cognito as the authorizer
- How to organize and deploy Lambda functions with CDK as part of a REST API
- How to use CDK to deploy a static website using S3 and CloudFront
- How to use webpack to reduce the size of Lambda assets
- How to upload and download S3 files using signed URLs

Screen shot

Graph UI

Data Model

You can store any simple graph data with this general layout:

Node (vertex) - label (immutable after creation) - id (auto generated) - properties: A map of key value pairs

Edge - label (immutable after creation) - properties: A map of key value pairs

The "name" property is special. This is the property used on the canvas as the text in the middle of each node. For edges, the text is the label.

Usage

Searching

The search bar can be used to view a subset of the graph or to focus on a particular node. Type in the name of a node and the node will be centered in the view. Hit the Enter key and the graph will reload with only that node and it's immediate relationships. Empty out the search bar and hit Enter again to reload the entire graph. You can also double click on white space somewhere on the canvas and the graph will reload.

Labels can also be searched, for example, type label:Person to see just nodes with that label, and all of their direct relationships. You can also combine terms with and. For example, you could search for label:Company and name:John to see all nodes labeled as Company and also view the node named John, which can be helpful when adding edges between nodes that are scattered in far corners of your knowledge graph.

Partitions

TODO

Deployment

Create your own domain and certificate for the website manually before deploying.

Create bin/config.js based on bin/config-sample.js . Populate DOMAIN, CERTIFICATE_ARN, and HOSTED_ZONE_ID.

Also create web/js/config.js based on web/js/config-sample.js. You have to deploy once before you can complete the configuration in that file.

Deploy the CDK application. Note that Neptune will consume 2 Elastic IPs in your configured region. Also note that these resources will cost money each month!

npm i
cd web
npm i
cd ../lambda
npm i
cd ..
npm run build
cdk deploy --profile your-profile --all

There is a bit of chicken-and-egg here with configuration for Cognito, the REST API, and the static site, so you need to create web/js/config.js and populate it with outputs from the first deployment, and then you need to redeploy.

Once the second deployment is done, log in to the AWS console and manually create a Cognito user for yourself to log in to the application. You should be automatically redirected to Cognito when you go to the web app.

If you are doing local web development, you can put jwt.refresh from your cookies on the deployed instance into web/js/config.js LOCAL_JWT to allow your local browser to use the deployed REST API.

cdk-neptune-knowledge-graph's People

Contributors

amazon-auto avatar dependabot[bot] avatar ericzbeard avatar ezbeard-github-test avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.