Skip to content

Instantly share code, notes, and snippets.

@kbastani
Created May 12, 2015 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbastani/ad47cea40145688dcc3b to your computer and use it in GitHub Desktop.
Save kbastani/ad47cea40145688dcc3b to your computer and use it in GitHub Desktop.
Monolithic Graph Data Model Example
// Teams
CREATE (accountsTeam:Team { name: "Accounts team" })
CREATE (inventoryTeam:Team { name: "Inventory team" })
// Services
CREATE (accountingService:Service { name: "Accounting Service"})
CREATE (inventoryService:Service { name: "Inventory Service"})
CREATE (shippingService:Service { name: "Shipping Service"})
// Resources
CREATE (customers:Resource { name: "Customers"})
CREATE (accounts:Resource { name: "Accounts"})
CREATE (addresses:Resource { name: "Addresses"})
CREATE (orders:Resource { name: "Orders"})
CREATE (products:Resource { name: "Products"})
CREATE (warehouses:Resource { name: "Warehouses"})
CREATE (creditCards:Resource { name: "Credit Cards"})
// Stories
CREATE (story1:Story { name: "Customer registration"})
CREATE (story2:Story { name: "Account details"})
CREATE (story3:Story { name: "Payment details"})
CREATE (story4:Story { name: "Order history"})
CREATE (story5:Story { name: "Product catalog"})
CREATE (story6:Story { name: "Warehouse information"})
CREATE (story7:Story { name: "Inventory management"})
CREATE (story8:Story { name: "Supply chain management"})
CREATE (story9:Story { name: "Shipping logistics"})
CREATE (story10:Story { name: "Shipping history"})
CREATE (story11:Story { name: "Shipping notifications"})
CREATE (story12:Story { name: "Backordering"})
CREATE (story13:Story { name: "Account management"})
CREATE (story14:Story { name: "Shopping cart"})
CREATE (story15:Story { name: "Product search"})
CREATE (story16:Story { name: "Checkout"})
// Connect customer registration story to resources
CREATE (story1)-[:DEPENDS_ON]->(customers)
CREATE (story1)-[:DEPENDS_ON]->(accounts)
// Connect account details story to resources
CREATE (story2)-[:DEPENDS_ON]->(accounts)
CREATE (story2)-[:DEPENDS_ON]->(customers)
CREATE (story2)-[:DEPENDS_ON]->(addresses)
CREATE (story2)-[:DEPENDS_ON]->(orders)
CREATE (story2)-[:DEPENDS_ON]->(creditCards)
// Connect payment details story to resources
CREATE (story3)-[:DEPENDS_ON]->(accounts)
CREATE (story3)-[:DEPENDS_ON]->(addresses)
CREATE (story3)-[:DEPENDS_ON]->(creditCards)
// Connect order history story to resources
CREATE (story4)-[:DEPENDS_ON]->(orders)
CREATE (story4)-[:DEPENDS_ON]->(products)
CREATE (story4)-[:DEPENDS_ON]->(addresses)
CREATE (story4)-[:DEPENDS_ON]->(creditCards)
CREATE (story4)-[:DEPENDS_ON]->(accounts)
CREATE (story4)-[:DEPENDS_ON]->(warehouses)
// Connect product catalog story to resources
CREATE (story5)-[:DEPENDS_ON]->(products)
// Connect warehousing information story to resources
CREATE (story6)-[:DEPENDS_ON]->(warehouses)
CREATE (story6)-[:DEPENDS_ON]->(orders)
CREATE (story6)-[:DEPENDS_ON]->(products)
CREATE (story6)-[:DEPENDS_ON]->(addresses)
// Connect inventory management information to resources
CREATE (story7)-[:DEPENDS_ON]->(products)
CREATE (story7)-[:DEPENDS_ON]->(warehouses)
// Connect supply chain management to resources
CREATE (story8)-[:DEPENDS_ON]->(warehouses)
CREATE (story8)-[:DEPENDS_ON]->(products)
CREATE (story8)-[:DEPENDS_ON]->(addresses)
// Connect shipping logistics story to resources
CREATE (story9)-[:DEPENDS_ON]->(addresses)
CREATE (story9)-[:DEPENDS_ON]->(orders)
CREATE (story9)-[:DEPENDS_ON]->(products)
CREATE (story9)-[:DEPENDS_ON]->(warehouses)
// Connect shipping history story to resources
CREATE (story10)-[:DEPENDS_ON]->(addresses)
CREATE (story10)-[:DEPENDS_ON]->(orders)
CREATE (story10)-[:DEPENDS_ON]->(accounts)
// Connect shipping notifications to resources
CREATE (story11)-[:DEPENDS_ON]->(orders)
CREATE (story11)-[:DEPENDS_ON]->(addresses)
// Connect backordering story to resources
CREATE (story12)-[:DEPENDS_ON]->(warehouses)
CREATE (story12)-[:DEPENDS_ON]->(products)
// Connect account management story to resources
CREATE (story13)-[:DEPENDS_ON]->(accounts)
CREATE (story13)-[:DEPENDS_ON]->(customers)
CREATE (story13)-[:DEPENDS_ON]->(addresses)
CREATE (story13)-[:DEPENDS_ON]->(creditCards)
// Connect shopping cart story to resources
CREATE (story14)-[:DEPENDS_ON]->(products)
CREATE (story14)-[:DEPENDS_ON]->(orders)
CREATE (story14)-[:DEPENDS_ON]->(accounts)
CREATE (story14)-[:DEPENDS_ON]->(customers)
CREATE (story14)-[:DEPENDS_ON]->(warehouses)
// Connect product search story to resources
CREATE (story15)-[:DEPENDS_ON]->(products)
// Connect checkout story to resources
CREATE (story16)-[:DEPENDS_ON]->(products)
CREATE (story16)-[:DEPENDS_ON]->(orders)
CREATE (story16)-[:DEPENDS_ON]->(warehouses)
CREATE (story16)-[:DEPENDS_ON]->(accounts)
CREATE (story16)-[:DEPENDS_ON]->(creditCards)
CREATE (story16)-[:DEPENDS_ON]->(addresses)
CREATE (story16)-[:DEPENDS_ON]->(customers)
// Connect teams to services
CREATE (accountsTeam)-[:OWNS]->(accountingService)
CREATE (inventoryTeam)-[:OWNS]->(shippingService)
CREATE (inventoryTeam)-[:OWNS]->(inventoryService)
// Connect services to resources
CREATE (customers)<-[:DEPENDS_ON]-(accountingService)
CREATE (accounts)<-[:DEPENDS_ON]-(accountingService)
CREATE (addresses)<-[:DEPENDS_ON]-(accountingService)
CREATE (addresses)<-[:DEPENDS_ON]-(inventoryService)
CREATE (addresses)<-[:DEPENDS_ON]-(shippingService)
CREATE (orders)<-[:DEPENDS_ON]-(accountingService)
CREATE (orders)<-[:DEPENDS_ON]-(inventoryService)
CREATE (orders)<-[:DEPENDS_ON]-(shippingService)
CREATE (products)<-[:DEPENDS_ON]-(inventoryService)
CREATE (products)<-[:DEPENDS_ON]-(shippingService)
CREATE (warehouses)<-[:DEPENDS_ON]-(inventoryService)
CREATE (warehouses)<-[:DEPENDS_ON]-(shippingService)
CREATE (creditCards)<-[:DEPENDS_ON]-(accountingService)
// What resources do teams depend on?
MATCH (teams:Team)-[:OWNS]->()-[:DEPENDS_ON]->(resources:Resource)
RETURN teams.name, collect(resources.name)
// Create direct connection between teams and resources
MATCH (teams:Team)-[:OWNS]->()-[:DEPENDS_ON]->(resources:Resource)
MERGE p=(teams)<-[:CONSUMED_BY]-(resources)
RETURN p
// Create connections between teams and resources by service
MATCH (teams:Team)-[:OWNS]->(service:Service)-[:DEPENDS_ON]->(resources:Resource)
CREATE p=(teams)-[:CONSUMES { using: service.name }]->(resources)
RETURN p
// Calculate change centrality
:GET /service/mazerunner/group/analysis/closeness_centrality/Resource/CONSUMED_BY/CONSUMES
// What is the centrality of domain resources?
MATCH (team:Team)<-[r:closeness_centrality]-(resource:Resource)
RETURN resource.name, SUM(r.value) as centrality
ORDER BY centrality DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment