Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rapter1990/springbootneo4jshortestpath

Spring Boot Neo4j Shortest Path
https://github.com/rapter1990/springbootneo4jshortestpath

dijkstra-shortest-path docker docker-compose java neo4j shortest-paths spring-boot testcontainer

Last synced: about 9 hours ago
JSON representation

Spring Boot Neo4j Shortest Path

Awesome Lists containing this project

README

        

# Calculating Shortest Path through Neo4j in Spring Boot

Main Information

### 📖 Information


  • Its aims to calculate the shortest path in terms of total connection and duration between two nodes

  • Here is the explanation of the project

    • Implement the process of CRUD for both City and its Route

    • Use Dijkstra Single-Source Shortest Path algorithm supported by Neo4j to calculate the path



### 🔨 Run the App

Maven>

1 ) Download Neo4j Desktop 1.4.15

2 ) Create a new Project and then create a new local dmbs with its version 4.2.1

3 ) Click Start Button

4 ) Download your project from this link `https://github.com/Rapter1990/SpringBootNeo4jShortestPath`

5 ) Go to the project's home directory : `cd SpringBootNeo4jShortestPath`

6 ) Create a jar file though this command `mvn clean install`

7 ) Run the project though this command `mvn spring-boot:run`

Docker

1 ) Install Docker Desktop. Here is the installation link : https://docs.docker.com/docker-for-windows/install/

2 ) Open Terminal under resources folder to run Neo4j on Docker Container
```
docker-compose up -d
```
3 ) Open Neo4j Browser in the brower
```
http://localhost:7474/browser/
```
4 ) Rebuild image app if necessary
```
docker build -t springbootneo4jshortestpath .
```

Explore Rest APIs


Method
Url
Description
Valid Request Body
Valid Request Params
Valid Request Params and Body
No Request or Params


GET
getCityById
Get City By Id

Info




GET
getAllCities
Get All Cities



Info


GET
getCityByName
Get City By Name

Info




POST
createCity
Create City

Info




PUT
updateCity
Update City


Info



DELETE
deleteCity
Delete City

Info




GET
getByRouteId
Get Route By Id

Info




GET
getAllRoutes
Get All Routes By City Id

Info




POST
createRoute
Create Route by City Id and Destination City Id


Info



PUT
updateRoute
Update Route by City Id and Destination City Id


Info



DELETE
deleteRoute
Delete Route By City Id and Route City

Info




GET
getShortestPath
Get Shortest Path by Total Connection
Info





GET
getShortestPathInTime
Get Shortest Path by Total Hours
Info



### Used Dependencies
* Spring Boot Web
* Spring Boot Test
* Neo4j
* Docker
* Mapper

## Valid Request Body

##### Create City
```
http://localhost:8077/api/v1/city

{
"name" : "Ä°stanbul"
}
```

##### Get Shortest Path by Total Connection
```
http://localhost:8077/api/v1/shortestpath/shortest-path

{
"from" : "Ä°stanbul",
"destination" : "Ankara"
}
```

##### Get Shortest Path by Total Hours
```
http://localhost:8077/api/v1/shortestpath/shortest-path-in-time

{
"from" : "Ä°stanbul",
"destination" : "Ankara"
}
```

## Valid Request Params

##### Get City By Id
```
http://localhost:8077/api/v1/city/id/{cityId}
```

##### Get City By Name
```
http://localhost:8077/api/v1/city/name/{cityName}
```

##### Delete City By Id
```
http://localhost:8077/api/v1/city/{cityId}
```

##### Get Route By Id
```
http://localhost:8077/api/v1/route/{routeId}
```

##### Get All Routes By City Id
```
http://localhost:8077/api/v1/route/{cityId}/routes
```

##### Delete Route By City Id and Route City
```
http://localhost:8077/api/v1/route/{cityId}/routes
```

## Valid Request Params and Body

##### Update City
```
http://localhost:8077/api/v1/city/{cityId}

{
"name" : "Ankara"
}
```

##### Create Route by City Id and Destination City Id
```
http://localhost:8077/api/v1/route/{cityId}/{destinationCityId}/create-route

{
"from" : "Ä°stanbul",
"destination" : "Ankara",
"departureTime" : "9:00",
"arriveTime" : "11:30"
}
```

##### Update Route by City Id and Destination City Id
```
http://localhost:8077/api/v1/route/{cityId}/update-route/{routeId}

{
"from" : "Ankara",
"destination" : "Antalya",
"departureTime" : "9:00",
"arriveTime" : "11:00"
}
```

## No Request or Params

##### Get All Cities
```
http://localhost:8077/api/v1/city/cities
```

### Screenshots

Click here to show the screenshots of project

Figure 1



Figure 2