Skip to main content

synesis-graph: Universal Graph Pipeline

Synesis Python Backends License

Transform your qualitative research into a living, navigable Knowledge Graph ready for AI (GraphRAG).

Language: English | Portugues

Documentation: Synesis Language Docs

This repository contains the official pipeline from the Synesis language to graph representations. It acts as a bridge between structured human analysis (.syn files) and computational intelligence, enabling MCP Agents and Data Science algorithms to interact with your research.

Two backends ship today — Neo4j (property graph, with GDS metrics) and HTML (self-contained interactive visualization). Both are built on the same BackendAdapter contract, so support for further graph databases can be added without touching the pipeline.


Highlights

  • Zero-IO / Direct Link: Uses the synesis.load() API to compile the project in memory and sync directly to the database. No intermediate JSON/CSV files.
  • Universal & Agnostic: Does not depend on fixed rules (like "Factors" or "Dimensions"). The script reads your Template (.synt) and creates the graph structure dynamically.
  • Automatic Metrics: Calculates network metrics at two levels:
    • Native Metrics: Always available via pure Cypher.
    • GDS Metrics: Advanced algorithms when the Graph Data Science plugin is installed.
  • Full Traceability: Every node and edge maintains origin metadata (source_file, line, column), ensuring scientific auditability.

Architecture

The pipeline follows the "Research as Code" flow:

  1. Input: Plain text files (.syn, .syno, .synt, .synp) defined by the Synesis language.
  2. Compilation: The compiler validates syntax and semantics in real-time.
  3. Dynamic Modeling: The script translates Template definitions into graph structures.
  4. Persistence: Data is injected into Neo4j via atomic transactions.
  5. Analytics: Graph metrics are calculated and stored in nodes.

Data Modeling: Template → Graph

The pipeline automatically translates field types defined in your Template (.synt) to structures in the Neo4j graph. This translation is dynamic and does not depend on specific field names.

Mapping Table

Template Type Graph Element Relationship Created Description
CODE Concept Node MENTIONS (Item → Concept) Central unit of analysis. Node name derived from field (e.g., ordem_2a → label Ordem_2a).
TOPIC Taxonomy Node GROUPED_BY Thematic grouping of concepts. Creates navigable hierarchy.
ASPECT Taxonomy Node QUALIFIED_BY Qualitative dimension. Enables multidimensional classification.
DIMENSION Taxonomy Node BELONGS_TO High-level aggregate dimension.
ENUMERATED Property Discrete values stored as node property.
CHAIN Explicit Relationship RELATES_TO Direct connection between concepts with type and description.
TEXT / MEMO Property Free text stored as property.
SCOPE SOURCE Source Property Fields with SCOPE SOURCE are dynamically transferred as properties of the Source node.

Base Nodes (Always Created)

Node Description Properties
Source Data source (interview, article, document) bibtex, title, author, year + all SCOPE SOURCE fields from Template
Item Citation unit extracted from source item_id, citation, description

Translation Example

Template:

FIELD category TYPE CODE
    SCOPE ITEM
END FIELD

FIELD theme TYPE TOPIC
    SCOPE ONTOLOGY
END FIELD

Resulting Graph:

(:Item)-[:MENTIONS]->(:Category)-[:GROUPED_BY]->(:Theme)

Graph Metrics

The pipeline automatically calculates network metrics that enrich the analysis. Metrics are divided into two levels:

Native Metrics (Always Available)

Calculated via pure Cypher, without external dependencies.

Concept Nodes (CODE)

Metric Description Analytical Use
degree Total degree (in + out) Overall concept connectivity
in_degree Incoming relationships Concepts referencing this one
out_degree Outgoing relationships Concepts referenced by this one
mention_count Citations mentioning the concept Frequency in primary data
source_count Distinct sources where it appears Concept dispersion/generalization

Taxonomy Nodes (TOPIC, ASPECT, DIMENSION)

Metric Description Analytical Use
concept_count Concepts classified in this category Category coverage
weighted_degree Sum of IS_LINKED_TO connection weights Inter-taxonomy relationship strength
aspect_diversity Distinct aspects of child concepts Qualitative diversity
dimension_diversity Distinct dimensions of child concepts Dimensional dispersion

Source Nodes

Metric Description Analytical Use
item_count Citations extracted from source Source data volume
concept_count Distinct concepts mentioned Source conceptual richness

GDS Metrics (Requires Plugin)

When the Neo4j Graph Data Science plugin is installed, the pipeline calculates advanced network metrics:

Metric Algorithm Description
pagerank PageRank Connection-based relevance/centrality
betweenness Betweenness Centrality "Bridge" role between clusters
community Louvain Thematic community detection

Graph Projection Strategies

GDS metrics calculation automatically adapts to template type:

Strategy When Used Description
RELATES_TO Templates with CHAIN Uses explicit relationships between concepts
CO_TAXONOMY Templates with CODE + TOPIC Connects concepts sharing taxonomy
CO_CITATION Fallback Connects concepts co-occurring in same sources

Note: If GDS is not installed, the pipeline displays a warning and continues normally with native metrics.


Installation

Requires Python 3.10+ and synesis ≥ 0.10.0.

# Clone the repository
git clone https://github.com/synesis-lang/synesis-graph.git
cd synesis-graph

# Install (editable) with the graph backends you need
pip install -e ".[neo4j]"

Compatibility matrix

Package This version Requires synesis Python
synesis 0.11.0 ≥3.10
synesis-coder 0.8.0 ≥0.10.0 ≥3.10
synesis-lsp 0.22.0 ≥0.10.0 ≥3.10
synesis-graph 0.5.0 ≥0.10.0 ≥3.10

GDS Plugin (Optional)

For advanced metrics, install the Neo4j Graph Data Science:

# Neo4j Desktop: Plugins → Install Graph Data Science Library
# Neo4j Server: Download JAR and add to plugins/ directory

Configuration

Create a config.toml file in the root with your Neo4j credentials:

[neo4j]
uri = "bolt://localhost:7687"  # Or your Neo4j Aura URI
user = "neo4j"
password = "your_secret_password"
database = "neo4j"             # Optional, default is 'neo4j'

Usage

Pick a backend and point it at the Synesis project file (.synp):

# Sync to Neo4j
synesis-graph neo4j --project ./my-project/analysis.synp

# Render a self-contained interactive HTML graph
synesis-graph html --project ./my-project/analysis.synp --output graph.html

# See every backend and its options
synesis-graph --help

What happens during execution?

  1. Compilation: The Synesis compiler validates your code. Syntax errors are displayed and the process stops (the destination is not touched).
  2. Connection: If compilation succeeds, the pipeline connects to the selected backend.
  3. Constraints: Uniqueness rules are applied based on the Template.
  4. Synchronization: Data is injected (Concepts, Citations, Sources, Relationships).
  5. Native Metrics: Calculated via pure Cypher.
  6. GDS Metrics: Calculated if plugin is available (with warning if not).

Resulting Graph Structure

Main Relationships

Relationship Source Target Description
FROM_SOURCE Item Source Citation traceability
MENTIONS Item Concept Citation mentions concept
GROUPED_BY Concept Topic Thematic classification
QUALIFIED_BY Concept Aspect Dimensional qualification
BELONGS_TO Concept Dimension High-level aggregation
RELATES_TO Concept Concept Explicit relationship (CHAIN)
IS_LINKED_TO Topic Topic Weighted co-taxonomy

Cypher Query Example

// Find the 10 most central concepts
MATCH (c:Concept)
WHERE c.pagerank IS NOT NULL
RETURN c.name, c.pagerank, c.mention_count, c.community
ORDER BY c.pagerank DESC
LIMIT 10

// Explore thematic communities
MATCH (c:Concept)
WHERE c.community = 42
RETURN c.name, c.pagerank
ORDER BY c.pagerank DESC

MCP Agent Integration (AI)

Once your data is in Neo4j, you can use the Neo4j MCP Server to allow LLMs (like Claude Desktop or Cursor) to converse with your research.

Quick Installation

# Install uv (if needed)
pip install uv

Claude Desktop Configuration

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "synesis-neo4j": {
      "command": "uvx",
      "args": ["mcp-neo4j-cypher@0.5.2", "--read-only"],
      "env": {
        "NEO4J_URI": "bolt://localhost:7687",
        "NEO4J_USERNAME": "neo4j",
        "NEO4J_PASSWORD": "your_password",
        "NEO4J_DATABASE": "database_name"
      }
    }
  }
}

File location:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Question Examples

Question Returns
"Which concepts have the highest PageRank?" Top concepts by relevance
"Show sources mentioning 'Acceptance'" Item → Source traceability
"Which concepts belong to community 1?" Cluster analysis
"Compare metrics of main concepts" Comparative table

Complete Documentation

See the mcp/ folder for:


Flow Diagram

graph TD
    %% Styles
    classDef files fill:#e1f5fe,stroke:#01579b,stroke-width:2px;
    classDef engine fill:#fff3e0,stroke:#ff6f00,stroke-width:2px;
    classDef data fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
    classDef graphDb fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px;
    classDef agent fill:#212121,stroke:#000,stroke-width:2px,color:#fff;

    subgraph "1. Input: Research as Code"
        SYN[Annotated Corpus<br/>.syn]:::files
        SYNO[Ontology<br/>.syno]:::files
        SYNP[Project<br/>.synp]:::files
        SYNT[Template<br/>.synt]:::files
    end

    subgraph "2. Synesis Engine"
        COMPILER{{synesis.load}}:::engine
        VALIDATOR(Semantic Validation):::engine

        SYNP --> COMPILER
        SYN --> COMPILER
        SYNO --> COMPILER
        SYNT --> COMPILER
        COMPILER --> VALIDATOR
    end

    subgraph "3. Structured Data"
        JSON[Canonical Object<br/>Traceable]:::data
        SCHEMA[Dynamic Schema<br/>from Template]:::data

        VALIDATOR -->|Success| JSON
        SYNT -.->|Defines| SCHEMA
    end

    subgraph "4. Knowledge Graph"
        NEO4J[(Neo4j)]:::graphDb
        NATIVE[Native Metrics<br/>Cypher]:::graphDb
        GDS[GDS Metrics<br/>Optional]:::graphDb

        JSON & SCHEMA -->|Sync| NEO4J
        NEO4J --> NATIVE
        NATIVE --> GDS

        subgraph "Metrics"
            DEG[Degree<br/>Centrality]
            PR[PageRank<br/>Relevance]
            BC[Betweenness<br/>Bridges]
            COM[Louvain<br/>Communities]
        end
        NATIVE -.-> DEG
        GDS -.-> PR & BC & COM
    end

    subgraph "5. Intelligent Consumption"
        MCP[MCP Agent]:::agent
        LLM[LLMs / Claude]:::agent

        NEO4J <-->|GraphRAG| MCP
        MCP <-->|Queries| LLM
    end

License

This program is distributed under the GNU Affero General Public License, version 3 only (AGPL-3.0-only), with the Synesis Data-Output Exception — see LICENSE and LICENSE.exception.

SPDX identifier: AGPL-3.0-only AND LicenseRef-Synesis-data-output-exception

The graphs you generate are yours. Exported artifacts — Cypher scripts, Neo4j databases, and the standalone HTML visualization — are not covered by the AGPL and carry no copyleft obligation toward Synesis.

This matters especially here: the generated HTML embeds Synesis's own JavaScript and CSS so the visualization can render standalone. That embedded material is Synesis Runtime Material under the Exception, and it does not place the generated file under the AGPL. You may publish, sell, or license the HTML you generate under any terms you choose.

The AGPL applies to synesis-graph itself: if you modify it and distribute it, or run it as a network service, you must share your changes under the AGPL.

Releases published before this change remain available under the MIT license they were issued under.

This license grants no rights to the "Synesis" name or logo.


Part of the Synesis Language ecosystem.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synesis_graph-0.5.0.tar.gz (110.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synesis_graph-0.5.0-py3-none-any.whl (83.9 kB view details)

Uploaded Python 3

File details

Details for the file synesis_graph-0.5.0.tar.gz.

File metadata

  • Download URL: synesis_graph-0.5.0.tar.gz
  • Upload date:
  • Size: 110.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for synesis_graph-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1b500d7f840652eafc5a7933136c839cce9ddd0a5f8496c45ee0cfb9b95a87fc
MD5 710d595d34afe58d47de5e84f2bf286a
BLAKE2b-256 076236ed3d94fccf2eea011fd540239ea8bc486aa0377e57bb15b452ee622475

See more details on using hashes here.

Provenance

The following attestation bundles were made for synesis_graph-0.5.0.tar.gz:

Publisher: ci.yml on synesis-lang/synesis-graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file synesis_graph-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: synesis_graph-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 83.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for synesis_graph-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04c3ecba1f19436ce11d79faf4bdbd1cb3740c9a2504899c9819da93ba0e007b
MD5 a3dce6044f8b8c6b2b5a2ce0613bf916
BLAKE2b-256 bc4a726b6e2b883bf5eaea5dfb87903229d2152700d608fb00686238bc176d3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for synesis_graph-0.5.0-py3-none-any.whl:

Publisher: ci.yml on synesis-lang/synesis-graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page