For avid users of Twitter, meeting individuals that has common Twitter friends (people you follow), and that you actually haven’t met in person, can be good opportunity to spend quality time. We are working on an app that makes friend recommendations to app users, based on their current locations and common friends.
This app is being build by a team of three aspiring software engineers, as a part of their Hack Reactor short project curriculum. Team members are Aaron Rice (email:[email protected]), Marco Au (email:[email protected]), and Elcin Erkin (email:[email protected])
The data model consists of two domains:
-
Person (attributes: name, screen_name, description, etc..) e.g. ElcinErkin, 'Elcin Erkin', etc..
-
Location (attributes: name) e.g. San Francisco (The location property will be obtained by app user’s current gps coordinates).
The following facts can be observed:
-
Person FOLLOWS another Person, e.g. ElcinErkin FOLLOWS AaronRice
-
Person CURRENT_LOCATION is a Location, e.g. MarcoAu CURRENT_LOCATION SanFrancisco
This console allows you to play with the described model - you can ask Cypher queries to check it. It also desplays the result of last executed Cypher query from the list presented below.
Firstly, the test data is added to the database.
The initial database has been populated with the following sample information (The app will scrape the actual data from Twitter API):
People:
-
Elcin is friends with Aaron, Fred and Phillip. Elcin lives in San Francisco.
-
Marco is also friends with Aaron, Fred and Phillip. He also lives in San Francisco.
-
Joe is friends with Fred and Phillip. Joe lives in New York.
Location:
-
San Francisco.
-
New York.
//Person
CREATE (elcin:Person {screen_name:'ElcinErkin'}),
(aaron:Person {screen_name:'RICEaaron'}),
(marco:Person {screen_name:'MarcoAu'}),
(phillip:Person {screen_name:'epic_scene'}),
(fred:Person {screen_name:'FredZirdung'}),
(joe:Person {screen_name:'JoeDoe'})
//Location
CREATE (sanfrancisco:Location {name:'San Francisco'}),
(newyork:Location {name:'New York'})
//Friendship
CREATE (elcin)-[:FOLLOWS]->(aaron),
(elcin)-[:FOLLOWS]->(fred),
(elcin)-[:FOLLOWS]->(phillip),
(marco)-[:FOLLOWS]->(aaron),
(marco)-[:FOLLOWS]->(fred),
(marco)-[:FOLLOWS]->(phillip),
(joe)-[:FOLLOWS]->(fred),
(joe)-[:FOLLOWS]->(phillip)
//People's locations
CREATE (elcin)-[:CURRENT_LOCATION]->(sanfrancisco),
(aaron)-[:CURRENT_LOCATION]->(sanfrancisco),
(marco)-[:CURRENT_LOCATION]->(sanfrancisco),
(fred)-[:CURRENT_LOCATION]->(sanfrancisco),
(phillip)-[:CURRENT_LOCATION]->(sanfrancisco),
(joe)-[:CURRENT_LOCATION]->(newyork)
The basic application of the model is making friend recommendations based on the current location and common friends on Twitter (Cypher queries below):
-
Recommendations:
-
I want to go out and meet new people tonight. I would prefer to meet people I have common interests with. Who would be interested in a meet-up?
-
MERGE (p:Person {screen_name:'ElcinErkin'})
ON CREATE SET p.screen_name={screen_name}
RETURN p;
MATCH (p:Person {screen_name:'ElcinErkin'}),
(friend:Person {screen_name:'RICEaaron'})
CREATE UNIQUE (p)-[:FOLLOWS]->(friend)
The presented graph model can be enhanced by doing semantic analysis on user’s tweets.
The following properties can be added:
Keyword:
-
Elcin is tweeting about Neo4j, Angular and Javascript. Elcin lives in San Francisco. Elcin is friends with Aaron and Fred.
-
Marco is tweeting about Neo4j, Ionic and Angular. He also lives in San Francisco and friends with Aaron, Phillip and Fred.