vaticle / typedb-studio

TypeDB Studio (IDE)
https://typedb.com
Mozilla Public License 2.0
186 stars 43 forks source link

Run TypeDB Studio in a web browser #118

Open BFergerson opened 5 years ago

BFergerson commented 5 years ago

Problem to Solve

I would like to explore a Grakn knowledge graph via the browser.

Current Workaround

As of Grakn 1.5 it looks like this feature was taken away. The workaround would be to never upgrade to Grakn 1.5.

Proposed Solution

I'm not well versed in front-end UI technology but it looks like this project is mainly JavaScript/CSS so it shouldn't be too difficult to provide a browser-based version.

Additional Information

I'm looking to display a topology diagram in the browser which would be based off data in Grakn. It would be amazing if I could just write a Grakn query and expose the result as the diagram inside the browser. This would allow users to further explore the topology and give it a lot more interactivity.

marco-scoppetta commented 5 years ago

@BFergerson,

thank you for your request.

We have removed the REST endpoints from Grakn for the time being as we have decided to primarily maintain the gRPC protocol, given that generally speaking it's not good practice to query a db directly from the browser when in production.

We are aware of use-cases of discovery and research for which it would be very handy to have a browser visualiser. But sadly the http2 protocol is not fully supported by browsers (duplex streaming in particular) so we have to use nodejs rather than "vanilla" javascript (that runs in the browsers), that is why we cannot currently port Workbase code into the browser.

But we will definitely try to find a solution in the near future for browser support.

BFergerson commented 5 years ago

given that generally speaking it's not good practice to query a db directly from the browser when in production

I don't think this would apply if I wasn't giving them direct DB access. I would be running queries with dynamic parameters and just piping the result to a Grakn browser-based visualizer. This is pretty similar to how I would deal with a SQL database in production. I'm not giving them control of the database but just running queries on their behalf and then showing the results. Given that Grakn can create really complex result sets it would be beneficial to have a way to visualize that. I haven't used Neo4j but from the presentations I've seen they seem to be able to do this type of thing in the browser.

The duplex streaming is what allows the main visualization part of the Grakn Workbase to function? Ideally, there would be a way to extract everything else away from the Workbase and just have that single panel which shows the graph.

marco-scoppetta commented 5 years ago

I'm not giving them control of the database but just running queries on their behalf and then showing the results

Right, so if you don't want to give them direct access you usually have a backend webserver that talks to Grakn/DB directly and reports back the result to the dashboard, more specifically:

In production you probably want to have a webserver for your app/dashboard that talks to Grakn using Python, Node or Java and builds a response for the dashboard (probably a JSON object). You probably want to expose REST or GraphQL endpoints for you Dashboard that breaks the direct link to the db. In Neo4J is possible because they're probably sticking to REST APIs to query the db.

We might indeed provide a webserver solution with visualisation dashboard in the future if there is enough demand for it. For now we had to prioritise the most common usecases.

If you, by any chance, want to give it a try at building a visual tool let us know and we will provide all the possible help

marco-scoppetta commented 5 years ago

BTW, also Neo4J is moving towards an NodeJS Electron (I guess) app (Neo4J Bloom)

BFergerson commented 5 years ago

@marco-scoppetta, I don't want to commit myself to doing the work but I would like to continue to discuss the feasibility of an embeddable Grakn graph. It sounds like the alternative to embedding a Grakn graph would be to use a JavaScript library like https://github.com/anvaka/VivaGraphJS and extract the result set from Grakn and build the equivalent graph in VivaGraphJS in order to display it. Does that sound correct to you? Again, front-end technology isn't my strong suite.

If that's the case, I would like to avoid going that route and have a way for Grakn to display the graph itself. I don't think this will be the first and last time I'll run into a situation where I want to show an interactive graph of something as opposed to a screenshot I took of it or the equivalent structure represented in another library.

I can understand though if your view is that Grakn doesn't provide graph visualization technology but knowledge graph database technology. I'm just curious of the various ways in which to display a graph that I want to be interative. Grakn has the nicest visualizations and if I could stick to Grakn-powered technology then all the better.

I suppose what I'm having trouble understanding is what is the true difficulty in getting the Grakn Workbase to display on the browser. Isn't it a Vue.js application? Vue.js' slogan is Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.. That sounds pretty browser-compatible to me. Are we just talking IE users missing out?

marco-scoppetta commented 5 years ago

Hey @BFergerson,

I understand in general your point, but what could you do with previous dashboard that you cannot to with Workbase? Previous dashboard was running in the browser but it was not natively embeddable in other web pages, so that' the same of having Workbase on your machine.

You are indeed correct, Vue.Js is for the web, the issue is that in our "web" application we use grpc package to communicate with Grakn (https://www.npmjs.com/package/grpc).

Grpc is for nodejs only, not pure javascript (that runs in the browsers), there is a "web" version of grpc but as you can see in the Bidi paragraph https://github.com/grpc/grpc-web/blob/master/ROADMAP.md is still not complete, that is the reason why.

So probably in the future we will be able to port it easily to the browsers once the http2 support improves.

BFergerson commented 5 years ago

You're correct in that the previous dashboard wasn't natively embeddable either. The difference with the previous version was that if necessary I could hack together an IFRAME with the graph inside it. I know that's not a pretty or safe solution but that's along the lines I was thinking. I'm trying to save as much work as I can and lean on Grakn as much as I can. I like how it looks when I'm exploring Grakn graphs and I want this same kind of experience for those who explore graph type structures in the applications I'm working on.

Thanks for explaining what the main issue is. If I'm understanding you correctly though, this doesn't stop the Grakn Workbase from being able to embed a graph in the browser (I understand I've somewhat shifted from browser-accessible to browser-embeddable). What I'm primarily interested in is the visualization engine for Grakn graphs. If I could handle the communication via a back-end webserver, couldn't I just use the part of Grakn Workbase that produces the visual aspects of the graph? I could use native gRPC communication via the Java libraries and then pipe that resultset to the portion of Grakn Workbase which produces the visualization. Would that be more feasible? I'm thinking it might just entail making that portion of the code a bit more modular?

marco-scoppetta commented 5 years ago

Yes, our visualisation tool works with JSON objects so it would be enough for you to write a webserver that queries grakn and sends JSON objects back to the workbase canvas.

If you're interested in this we can chat in Slack and we can make the graph visualisation as a detachable module from Workbase.

The meat of the work would be to build the webserver and the necessary REST or GraphQL endpoints to handle all the calls from the frontend (Visualisation Canvas)

mingfang commented 4 years ago

are there any plans to make the workable work on the browser and not as a desktop app?

alexjpwalker commented 2 years ago

This is not currently on our priorities due to the issues raised previously in this thread:

We have removed the REST endpoints from Grakn for the time being as we have decided to primarily maintain the gRPC protocol, given that generally speaking it's not good practice to query a db directly from the browser when in production.

We are aware of use-cases of discovery and research for which it would be very handy to have a browser visualiser. But sadly the http2 protocol is not fully supported by browsers (duplex streaming in particular) so we have to use nodejs rather than "vanilla" javascript (that runs in the browsers), that is why we cannot currently port Workbase code into the browser.

Additionally, we have recently rewritten Workbase as Studio, and it is no longer an Electron app - this makes it a little harder to port to the web. However we are aware that there are good use cases for a browser visualiser. If anyone wants to pick this up as a project, we're all ears.