Dataflow Diagram

We imagine depending on programmers to maintain a diagram of how our system works and interacts with external services outside of our control. We source SERVICES with DATASTORES and QUEUES. data

Manually maintained diagrams owned and managed by the architecture team updated within weeks before or after actual deployments.

Extracted data format.

[] MAX 1000 {} REL Flow type CASE type store store from <= NODE Service name CASE type rest from <= NODE Service name to => NODE Service name CASE type queue queue read => NODE Service name write <= NODE Service name CASE type site site from => NODE Service name

create (s:EXPLAIN {props}) with s UNWIND {json} AS obj WITH *, CASE WHEN obj.type='store' THEN [1] ELSE [] END AS stores, CASE WHEN obj.type='rest' THEN [1] ELSE [] END AS rests, CASE WHEN obj.type='queue' and obj.read is not null THEN [1] ELSE [] END AS reads, CASE WHEN obj.type='queue' and obj.write is not null THEN [1] ELSE [] END AS writes, CASE WHEN obj.type='site' THEN [1] ELSE [] END AS sites FOREACH (_ IN stores | MERGE (d:DB {name: obj.store}) MERGE (g:PROGRAM {name: obj.from}) MERGE (g)-[:QUERIES {source: s.name}]->(d) ) FOREACH (_ IN rests | MERGE (f:PROGRAM {name: obj.from}) MERGE (t:PROGRAM {name: obj.to}) MERGE (f)-[:CALLS {source: s.name}]->(t) ) FOREACH (_ IN reads | MERGE (q:QUEUE {name: obj.queue}) MERGE (r:PROGRAM {name: obj.read}) MERGE (r)-[:READS {source: s.name}]->(q) ) FOREACH (_ IN writes | MERGE (q:QUEUE {name: obj.queue}) MERGE (w:PROGRAM {name: obj.write}) MERGE (w)-[:WRITES {source: s.name}]->(q) ) FOREACH (_ IN sites | MERGE (x:EXTERNAL {name: obj.site}) MERGE (f:PROGRAM {name: obj.from}) MERGE (f)-[:CALLS {source: s.name}]->(x) )

I'm stumped as to how to wrap merges in a case statement that understands the variety in my json. grammar

William Lyon suggested this alternative. neo4j