https://github.com/samad0san/neo4j-scala
Neo4j is a native graph database designed to store and manage data as graphs using nodes, relationships, and properties. It uses the Cypher query language for efficient querying and supports ACID transactions, making it ideal for use cases like social networks, fraud detection, recommendation systems, and network analysis.
https://github.com/samad0san/neo4j-scala
cytoscapejs javascript json mock-data neo4j neovis scala
Last synced: about 1 month ago
JSON representation
Neo4j is a native graph database designed to store and manage data as graphs using nodes, relationships, and properties. It uses the Cypher query language for efficient querying and supports ACID transactions, making it ideal for use cases like social networks, fraud detection, recommendation systems, and network analysis.
- Host: GitHub
- URL: https://github.com/samad0san/neo4j-scala
- Owner: samAd0san
- Created: 2025-04-06T16:00:39.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-18T10:21:01.000Z (about 1 year ago)
- Last Synced: 2025-05-18T11:27:56.704Z (about 1 year ago)
- Topics: cytoscapejs, javascript, json, mock-data, neo4j, neovis, scala
- Language: Cypher
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Integrate Neo4j with Scala
### 1. Create/Run the Neo4j Docker Image on Docker Desktop/Instance
```bash
docker run \
--name neo4j-4.4 \
-p 7474:7474 -p 7687:7687 \
-e NEO4J_AUTH=neo4j/password \
-e NEO4JLABS_PLUGINS='["apoc"]' \
-e NEO4J_dbms_security_procedures_unrestricted=apoc.\\* \
neo4j:4.4.23
```
or
```bash
docker run --name=neo4j -p 7474:7474 -p 7687:7687 -e NEO4J_AUTH=neo4j/password neo4j:latest
```
### 2. Add Dependencies
build.sbt
```scala
// Neo4j Dependencies
lazy val commonDependencies = Seq(
"org.neo4j.driver" % "neo4j-java-driver" % "4.4.10",
)
```
### 3. Configure
application.conf
```scala
neo4j {
uri = "bolt://localhost:7687"
user = "neo4j"
password = "neo4j" # run neo4j docker image
connection {
timeout = 5s # Connection timeout
encryption = false # Disable for local testing
}
}
```
### 4. Test Neo4j Connection
Main.scala
```scala
import org.neo4j.driver.{AuthTokens, Driver, GraphDatabase}
// Testing Neo4j Connection
val testNeo4jConnection = () => {
Try {
val uri = config.getString("neo4j.uri")
val user = config.getString("neo4j.user")
val password = config.getString("neo4j.password")
val driver: Driver = GraphDatabase.driver(uri, AuthTokens.basic(user, password))
val session = driver.session()
val result = session.run("RETURN 'Hello, Neo4j!' AS message")
val message = result.single().get("message").asString()
println(s"Neo4j connection: $message")
session.close()
driver.close()
} match {
case Success(_) => println("Neo4j connection successful.")
case Failure(exception) =>
println(s"Neo4j connection failed: ${exception.getMessage}")
}
}
def main(args: Array[String]): Unit = {
println("Hello World!")
// Neo4j Connection
testNeo4jConnection()
}
```
### 5. Download and Install Neo4j Desktop
1. Create a new project
2. Click on 'Add' -> 'Remove Connection' (for docker container)
3. Give any 'name' and for connect url ```bolt://localhost:7687```
4. Give the username and password which you passed during creation/running the neo4j docker container
5. The Database will be added then connect -> open -> run queries
6. Sample cypher query ```$ MATCH (n) RETURN n``` to return all the data present, and ```$ MATCH (n) DETACH DELETE n``` to delete all the data.