This is a Java implementation of a backend service that computes the shortest path (in relation to movies) between any given actor and Hollywood actor Kevin Bacon. This concept is based on the Six Degrees of Kevin Bacon.
![neo4j DB example](https://private-user-images.githubusercontent.com/66337024/260211833-97c5d265-647c-434c-a463-ee58345b0d9f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxNjI3NzQsIm5iZiI6MTcyMjE2MjQ3NCwicGF0aCI6Ii82NjMzNzAyNC8yNjAyMTE4MzMtOTdjNWQyNjUtNjQ3Yy00MzRjLWE0NjMtZWU1ODM0NWIwZDlmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI4VDEwMjc1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI0YjFiNTQ5ZmVmMzRkMDk4NjYzMjNkMjJhZjlmMDJhMzYwOTBiMWVmOWZjNWZkYjA4ZWMzNTE5MjYwODBiOTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.M_8gVgmenN1yI6Dw_NSdCatS2otnn8Kh_GrfzGRjY7s)
- Consider the actor
Tom Cruise
:- Tom Cruise acted in “A Few Men” Kevin Bacon
- Tom Cruise acted in “A Few Men” Kevin Bacon
So we would say that Tom Cruise has a “Bacon number” of 1.
- Consider the actor
Emil Eifrem
:- Emil Eifrem acted in “The Matrix” with Keanu Reeves
- Keanu Reeves acted in “The Devil's Advocate” with Christopher Evans
- Christopher Evans acted in “A Few Men” with Kevin Bacon
So we would say that Emil Eifrem has a “Bacon number” of 3.
The application is essentially a RESTful API that uses HTTP requests to create actor and movie nodes, relationships between the nodes, and compute information based on the nodes in the database. The backend is stored in a Neo4j database using the Java Neo4j driver. Neo4j Specifications:
- Version: 4.4.23 or lower
- Database Port:
bolt://localhost:7687
- Username: neo4j
- Password: 12345678
-
Actors:
- Node label: Actor
- Node properties: actorId, name
-
Movies:
- Node label: Movie
- Node properties: movieId, name
-
Relationships:
- Relationship label: ACTED_IN
-
Request/Response Body:
- JSON format
-
Response Status:
- 200 OK for a successful add
- 400 BAD REQUEST if the request body is improperly formatted or missing required information
- 404 NOT FOUND if the actors or movies do not exist when adding a relationship
- 500 INTERNAL SERVER ERROR if save or add was unsuccessful (Java Exception is thrown)
-
Existing endpoints:
- (PUT) http://localhost:8080/api/v1/addActor
- parameters:
- name: string
- actorId: string
- parameters:
- (PUT) http://localhost:8080/api/v1/addMovie
- parameters:
- name: string
- movieId: string
- parameters:
- (PUT) http://localhost:8080/api/v1/addRelationship
- parameters:
- actorId: string
- movieId: string
- parameters:
- (GET) http://localhost:8080/api/v1/getActor
- parameter:
- actorId: string
- parameter:
- (GET) http://localhost:8080/api/v1/getMovie
- parameter:
- actorId: string
- parameter:
- (GET) http://localhost:8080/api/v1/hasRelationship
- parameters:
- actorId: string
- movieId: string
- parameters:
- (GET) http://localhost:8080/api/v1/computeBaconNumber
- parameter:
- actorId: string
- parameter:
- (GET) http://localhost:8080/api/v1/computeBaconPath
- parameter:
- actorId: string
- parameter:
- (GET) http://localhost:8080/api/v1/getCommonMovies
- parameters:
- actor1Id: string
- actor2Id: string
- parameters:
- (PUT) http://localhost:8080/api/v1/addActor
To test the application, you can either:
For information on how to install and use the Robot Framework for testing, click here.