From d2130d64f4e4b8847d0283159219d43e76ceed98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Fri, 31 May 2019 21:03:32 +0200 Subject: [PATCH] Write documentation for Neo4J @Tirokk FYI --- SUMMARY.md | 1 + backend/README.md | 47 ++++++++-------------------------- neo4j/README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 36 deletions(-) create mode 100644 neo4j/README.md diff --git a/SUMMARY.md b/SUMMARY.md index fdf3600b4..701eac2d0 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -3,6 +3,7 @@ * [Introduction](README.md) * [Edit this Documentation](edit-this-documentation.md) * [Installation](installation.md) +* [Neo4J](neo4j/README.md) * [Backend](backend/README.md) * [GraphQL](backend/graphql.md) * [Webapp](webapp/README.md) diff --git a/backend/README.md b/backend/README.md index 7c4d3a3e9..3cce123ac 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,8 +1,6 @@ # Backend -## Installation -{% tabs %} -{% tab title="Docker" %} +## Installation with Docker Run the following command to install everything through docker. @@ -14,28 +12,15 @@ $ docker-compose up # rebuild the containers for a cleanup $ docker-compose up --build ``` -Open another terminal and create unique indices with: -```bash -$ docker-compose exec neo4j migrate -``` +Wait a little until your backend is up and running at [http://localhost:4000/](http://localhost:4000/). -{% endtab %} - -{% tab title="Without Docker" %} +## Installation without Docker For the local installation you need a recent version of [node](https://nodejs.org/en/) -(>= `v10.12.0`) and [Neo4J](https://neo4j.com/) along with -[Apoc](https://github.com/neo4j-contrib/neo4j-apoc-procedures) plugin installed -on your system. +(>= `v10.12.0`). -Download [Neo4j Community Edition](https://neo4j.com/download-center/#releases) and unpack the files. - -Download [Neo4j Apoc](https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases) and drop the file into the `plugins` folder of the just extracted Neo4j-Server -Note that grand-stack-starter does not currently bundle a distribution of Neo4j. You can download [Neo4j Desktop](https://neo4j.com/download/) and run locally for development, spin up a [hosted Neo4j Sandbox instance](https://neo4j.com/download/), run Neo4j in one of the [many cloud options](https://neo4j.com/developer/guide-cloud-deployment/), [spin up Neo4j in a Docker container](https://neo4j.com/developer/docker/) or on Debian-based systems install [Neo4j from the Debian Repository](http://debian.neo4j.org/). Just be sure to update the Neo4j connection string and credentials accordingly in `.env`. -Start Neo4J and confirm the database is running at [http://localhost:7474](http://localhost:7474). - -Now install node dependencies with [yarn](https://yarnpkg.com/en/): +Install node dependencies with [yarn](https://yarnpkg.com/en/): ```bash $ cd backend $ yarn install @@ -46,14 +31,8 @@ Copy Environment Variables: # in backend/ $ cp .env.template .env ``` - -Configure the new files according to your needs and your local setup. - -Create unique indices with: - -```bash -$ ./neo4j/migrate.sh -``` +Configure the new file according to your needs and your local setup. Make sure +a [local Neo4J](http://localhost:7474) instance is up and running. Start the backend for development with: ```bash @@ -65,17 +44,12 @@ or start the backend in production environment with: yarn run start ``` -{% endtab %} -{% endtabs %} - Your backend is up and running at [http://localhost:4000/](http://localhost:4000/) -This will start the GraphQL service \(by default on localhost:4000\) where you can issue GraphQL requests or access GraphQL Playground in the browser. +This will start the GraphQL service \(by default on localhost:4000\) where you +can issue GraphQL requests or access GraphQL Playground in the browser. ![GraphQL Playground](../.gitbook/assets/graphql-playground.png) -You can access Neo4J through [http://localhost:7474/](http://localhost:7474/) -for an interactive `cypher` shell and a visualization of the graph. - #### Seed Database @@ -114,7 +88,8 @@ $ yarn run db:reset # Testing -**Beware**: We have no multiple database setup at the moment. We clean the database after each test, running the tests will wipe out all your data! +**Beware**: We have no multiple database setup at the moment. We clean the +database after each test, running the tests will wipe out all your data! {% tabs %} diff --git a/neo4j/README.md b/neo4j/README.md new file mode 100644 index 000000000..379a89eec --- /dev/null +++ b/neo4j/README.md @@ -0,0 +1,64 @@ +# Neo4J + +Human Connection is a social network. Using a graph based database which can +model nodes and edges natively - a network - feels like an obvious choice. We +decided to use [Neo4j](https://neo4j.com/), the currently most used graph +database available. The community edition of Neo4J is Free and Open Source and +we try our best to keep our application compatible with the community edition +only. + +## Installation with Docker + +Run: + +```bash +docker-compose up +``` + +You can access Neo4J through [http://localhost:7474/](http://localhost:7474/) +for an interactive cypher shell and a visualization of the graph. + +## Installation without Docker + +Install community edition of [Neo4J]() along with the plugin +[Apoc](https://github.com/neo4j-contrib/neo4j-apoc-procedures) on your system. + +To do so, go to [releases](https://neo4j.com/download-center/#releases), choose +"Community Server", download the installation files for you operation system +and unpack the files. + +Download [Neo4j Apoc](https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases) +and drop the file into the `plugins` folder of the just extracted Neo4j-Server. + +### Alternatives + +You can download [Neo4j Desktop](https://neo4j.com/download/) and run locally +for development, spin up a +[hosted Neo4j Sandbox instance](https://neo4j.com/download/), run Neo4j in one +of the [many cloud options](https://neo4j.com/developer/guide-cloud-deployment/), +[spin up Neo4j in a Docker container](https://neo4j.com/developer/docker/), +on Archlinux you can install [neo4j-community from AUR](https://aur.archlinux.org/packages/neo4j-community/) +or on Debian-based systems install [Neo4j from the Debian Repository](http://debian.neo4j.org/). +Just be sure to update the Neo4j connection string and credentials accordingly +in `backend/.env`. + +Start Neo4J and confirm the database is running at [http://localhost:7474](http://localhost:7474). + +## Database Indices and Constraints + +If you are not running our dedicated Neo4J [docker image](https://hub.docker.com/r/humanconnection/neo4j), +which is the case if you setup Neo4J locally without docker, then you have to +setup unique indices and database constraints manually. + +If you have `cypher-shell` available with your local installation of neo4j you +can run: + +```bash +# in folder neo4j/ +$ cp .env.template .env +$ ./db_setup.sh +``` + +Otherwise if you don't have `cypher-shell` available, simply copy the cypher +statements [from the script](./neo4j/db_setup.sh) and paste the scripts into your +database [browser frontend](http://localhost:7474).