Bolt-On your Web App to Neo4j Who are we? Michael Opitz Christian - - PowerPoint PPT Presentation
Bolt-On your Web App to Neo4j Who are we? Michael Opitz Christian - - PowerPoint PPT Presentation
Bolt-On your Web App to Neo4j Who are we? Michael Opitz Christian Ranz Codastic A FULL STACK WEB SOFTWARE AND SERVICES APPLICATION DEVELOPMENT FOR KNOWLEDGE GRAPHS. FREELANCER NETWORK. Services: Services: data & ontology
Who are we?
SOFTWARE AND SERVICES FOR KNOWLEDGE GRAPHS. A FULL STACK WEB APPLICATION DEVELOPMENT FREELANCER NETWORK. Services:
- Web applications and websites in React,
Gatsby, …
- APIs with node.js, rest, GraphQL
Services:
- data & ontology modeling
- reasoning services
- visual data analytics
Products:
- GraphScale
- SemSpect
Codastic
Christian Ranz Michael Opitz
What is SemSpect? A Brief Demo
Graph Apps – Reach More People
SemSpect Architecture
Java REST API Neo4j GraphScale
HTTP Rest
SemSpect Client
Backend (GraphScale):
- Restlet JAVA API
- Embedded Neo4j
Client:
- Ext JS components
- Redux like Flux architecture
- Modular HTTP API layer
Neo4j Desktop
How to Transform SemSpect into a Graph App?
Graph
Neo4j Graph App
SemSpect Client Graph Java REST API Neo4j GraphScale
HTTP Rest
?
Neo4j Desktop
SemSpect as Neo4j Graph App
Graph
Neo4j Graph App
SemSpect Client
Bolt Protocol
exchangeable request layer SemSpect Graph Plugin Graph SemSpect Graph Plugin
Neo4j Desktop
Graph SemSpect Graph Plugin Graph SemSpect Graph Plugin
Exchangeable API Request Layer
Neo4j Graph App
SemSpect Client
Bolt Protocol
Our exchangeable request layer is able to perform Rest like api requests over the Bolt protocol. exchangeable request layer
Exchangeable API Request Layer
API layer
tree.remove('someTreeId')
Request layer
request.delete('/tree/:id') Graph or Web App
HTTP Layer
fetch('http://…', {method: 'DELETE'})
Bolt Layer
session.run('CALL deleteTree(…)')
JAVA Restlet API Neo4j Graph Plugin
Web App Graph App
Client business logic
HTTP Rest Bolt Protocol
Details
Neo4j Desktop
SemSpect Graph Plugin
Graph SemSpect Graph Plugin
Neo4j Graph App
SemSpect Client Graph SemSpect Graph Plugin
Bolt Protocol
Graph Plugin answering Rest like api requests over the Bolt protocol. exchangeable request layer
JAVA Restlet API Neo4j Graph Plugin
SemSpect Graph Plugin
Backend Business Logic
Pojo deleteTree(String)
Rest Layer
void handle(Request,Response)
Bolt Layer
Record deleteTree(String)
Cypher/ Java-Api
Neo4j Embedded (looks the same in both scenarios)
Bolt Layer- Challenges
JSON-Objects (data):
- Can’t send back json objects directly through bolt
○ Solution: Use Jackson to map pojos to maps
- Neo4j supports only certain types
○ Solution: Use Jackson’s custom serializer
HTTP Status Codes:
- Can’t signal http status codes/statusText through Exceptions
○ Solution: Add statusCode/statusText Field to Record
Persisting User Data
- We don’t want to modify the database
○ Solution: Write to File System
Challenges / Conclusion
- Persisting user data
○ Electron local storage and file system
- Missing or inconsistent documentation
- deprecation policy
Questions?
Thank you!
Hunger Games Questions for “Bolt-On Your Web App to Neo4j”
1. What is SemSpect? a. A database performance monitoring application b. A graph exploration and visualization tool c. A data import tool 2. Graph Apps interact with Neo4j Desktop by which standardized client-server protocol? a. HTTP b. Bolt Protocol c. RPC (Remote Procedure Call) 3. What are the 3 fields in a record to mimic a http response over bolt? a. statusCode / statusText / data b. contentType / statusText / data c. statusCode / contentType / body
Answer here: r.neo4j.com/hunger-games
Links
- Neo4j Procedures: https://neo4j.com/docs/java-reference/current/extending-neo4j/
- Neo4j Datatypes: https://neo4j.com/docs/java-reference/current/extending-neo4j/procedures-and-functions/values-and-types/
- Jackson: https://github.com/FasterXML/jackson
- Semspect: http://semspect.de/
- Semspect Panama Demo: http://panama.semspect.de/
- Bitbucket Snippet of the Bold request layer: https://bitbucket.org/snippets/derivo/Argdq7
- Bitbucket Snippet of an example Backend: https://bitbucket.org/snippets/derivo/8nMr98
- Neo4j Developer Graph Apps Gallery: https://install.graphapp.io/
How does a request look like?
How does a request look like?
Remove a tree by Id
Bolt request layer
call the request layer with a route Map route to procedure and map parameters Run the procedure on the bolt session Find the response in the results and return
function async remove(id) { const result = await api.tree.remove(id); dispatcher.dispatch( createAction( 'ACTION_TREE_REMOVED', { result } ) ); }
Dispatch an action with the result
How does a request look like?
function remove(id) { return request.remove( '/tree/:id', { id } ); }
Remove a tree by Id
Bolt request layer
call the request layer with a route Map route to procedure and map parameters Run the procedure on the bolt session Find the response in the results and return Dispatch an action with the result
How does a request look like?
function mapPathToProcedure( method, procedures, path, params ) { // … return procedures[method][path]; } const procedures = { POST: { '/tree': { name: 'saveTree', params: { label: mapString, description: mapString, state: a => a }, responseDataMapper: data => ({ data }) } } }, GET: { /* … */ }, PUT: { /* … */ }, DELETE: { /* … */ } }
Remove a tree by Id
Bolt request layer
call the request layer with a route Map route to procedure and map parameters Run the procedure on the bolt session Find the response in the results and return Dispatch an action with the result
How does a request look like?
session.run( `CALL ${procedureName}`, requestParams ).then(results => { return getResponseFromNeo4jResults( results, responseDataMapper ); })
Remove a tree by Id
Bolt request layer
call the request layer with a route Map route to procedure and map parameters Run the procedure on the bolt session Find the response in the results and return Dispatch an action with the result
How does a request look like?
function getResponseFromNeo4jResults( result ) { const record = result.records[0]; return { data: record.get('data'), status: record.get('status'), statusText: record.get('statusText'), }; }
Remove a tree by Id
Bolt request layer
call the request layer with a route Map route to procedure and map parameters Run the procedure on the bolt session Find the response in the results and return Dispatch an action with the result
How does a request look like?
Remove a tree by Id
Bolt request layer
call the request layer with a route Map route to procedure and map parameters Run the procedure on the bolt session Find the response in the results and return Dispatch an action with the result
function async remove(id) { const result = await api.tree.remove(id); dispatcher.dispatch( createAction( 'ACTION_TREE_REMOVED', { result } ) ); }
Back