https://github.com/thoughtscript/java_spring_graph_2025
Java Spring Boot Graph DB
https://github.com/thoughtscript/java_spring_graph_2025
docker docker-compose java neo4j spring-boot
Last synced: 25 days ago
JSON representation
Java Spring Boot Graph DB
- Host: GitHub
- URL: https://github.com/thoughtscript/java_spring_graph_2025
- Owner: Thoughtscript
- Created: 2025-03-10T21:07:49.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-03-11T19:58:54.000Z (11 months ago)
- Last Synced: 2025-03-11T20:35:19.730Z (11 months ago)
- Topics: docker, docker-compose, java, neo4j, spring-boot
- Language: Java
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# java_spring_graph_2025
[](https://spring.io/projects/spring-boot)
[](https://neo4j.com)
[](https://maven.apache.org/download.cgi)
[](https://www.docker.com/)
Having some fun with [Spring Boot 3.4.3](https://spring.io/projects/spring-boot), [Neo4J](https://neo4j.com/product/cypher-graph-query-language/), and **Graph Databases**.
**AWS** [defines](https://aws.amazon.com/nosql/graph/) **Graph Databases** as follows:
"A graph database is a systematic collection of data that emphasizes the relationships
between the different data entities. The NoSQL database uses mathematical graph theory
to show data connections."
I've used **Graph-Theoretic** approaches in several ways:
1. **NoSQL** - relational aggregation (in leiu of **JOIN** statements, **JOIN** tables, **Map-Reduce** operations, and/or multiple **DBRef**s) - mostly a mix of **Mongo DB**, **Dynamo DB**.
2. **GraphQL**
3. A bit of **AWS Neptune** and **Neo4J** (but without standing up the DB's or configuring them).
**Neo4J Cypher** uses [ASCII Art Syntax](https://neo4j.com/docs/cypher-manual/5/introduction/cypher-overview/) for queries typified by the scheme:
* `(nodes)-[:CONNECT_TO]→(otherNodes)`
* `(MyNode)-[:VERB_OR_RELATION_TO]→(MyOtherNode)`
## Use
### Docker Compose
```bash
docker-compose up
# If using Docker Compose Engine V2:
docker compose up
```
### SSL
```bash
keytool -genkey \
-alias bootexample \
-keystore bootexample.p12 \
-storetype PKCS12 \
-keyalg RSA \
-storepass af3DF*34afefwefehu \
-validity 730 \
-keysize 4096
```
## Tests, Testing, and Queries
Exec into the `neo4j` instance:
```bash
cypher-shell -u neo4j -p examplepw
$ > Match (c:Course {name: "Art"}) - [r:HAS_STUDENT] -> (s:Student) RETURN c, collect(r), collect(s);
$ > MATCH (c:Course {name: "Art"}) RETURN c;
$ > MATCH (s:Student {firstname: "Class", lastname: "Dunce"}) RETURN s;
```
> Other **CQL** queries are available [here](./neo4j/init.cql).
> (Some) Acceptance and Live Integration Tests are available [here](./_acceptance/Java%20Spring%20Graph.postman_collection.json) through **Postman**. (Some example Unit Tests have also been [added](./bootgraph/src/test) and [configured](./bootgraph/pom.xml).)
## Neo4J
* Access to the built-in view [here](http://localhost:7474/db/data/) is now [deprecated](https://stackoverflow.com/questions/76221610/http-localhost7474-db-data-returns-a-404-after-login).
* Using the recommended `docker-compose.yml` [setting](https://neo4j.com/docs/operations-manual/current/docker/docker-compose-standalone/): `NEO4J_AUTH=neo4j/examplepw` doesn't appear to stick. One can still log in afterwards with `neo4j/neo4j` (the default, and it will request an immediate password change).
* As such, I've opted to use `neo4j-admin set-initial-password examplepw` in the [Dockerfile](./neo4j/dockerfile) instead.
## Resources and Links
1. https://docs.spring.io/spring-data/neo4j/reference/getting-started.html
2. https://neo4j.com/docs/cypher-manual/current/queries/concepts
3. https://aws.amazon.com/nosql/graph
4. https://www.liquidweb.com/blog/neo4j-graph-database-installing-neo4j-on-ubuntu-20-04/
5. https://github.com/neo4j-examples/movies-java-spring-data-neo4j/tree/main
6. https://www.baeldung.com/spring-data-neo4j-intro
7. https://neo4j.com/docs/operations-manual/current/docker/docker-compose-standalone/