graph

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package graph provides Neo4j graph database integration for Aha Studio. It enables relationship-aware queries and graph analytics on Aha.io data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeNode

func MergeNode(label NodeLabel, id string, props map[string]any) string

MergeNode creates or updates a node with the given label and properties.

func MergeRelationship

func MergeRelationship(fromLabel NodeLabel, toLabel NodeLabel, relType RelationType) string

MergeRelationship creates or updates a relationship between two nodes.

func SchemaConstraints

func SchemaConstraints() []string

SchemaConstraints returns Cypher statements to create schema constraints.

func SchemaIndexes

func SchemaIndexes() []string

SchemaIndexes returns Cypher statements to create indexes for query performance.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps a Neo4j driver connection.

func NewClient

func NewClient(cfg *Config) (*Client, error)

NewClient creates a new Neo4j client.

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close closes the Neo4j driver connection.

func (*Client) CreateRelationshipIfExists

func (c *Client) CreateRelationshipIfExists(ctx context.Context, fromLabel NodeLabel, fromID string, toLabel NodeLabel, toID string, relType RelationType) error

CreateRelationshipIfExists creates a relationship only if both nodes exist.

func (*Client) CreateSchema

func (c *Client) CreateSchema(ctx context.Context) error

CreateSchema creates all constraints and indexes in the database.

func (*Client) DropSchema

func (c *Client) DropSchema(ctx context.Context) error

DropSchema drops all constraints and indexes (use with caution).

func (*Client) ExecuteRead

func (c *Client) ExecuteRead(ctx context.Context, work func(tx neo4j.ManagedTransaction) (any, error)) (any, error)

ExecuteRead executes a read transaction.

func (*Client) ExecuteWrite

func (c *Client) ExecuteWrite(ctx context.Context, work func(tx neo4j.ManagedTransaction) (any, error)) (any, error)

ExecuteWrite executes a write transaction.

func (*Client) FindConnectedFeatures

func (c *Client) FindConnectedFeatures(ctx context.Context, entityType NodeLabel, entityID string, depth int) (*QueryResult, error)

FindConnectedFeatures finds features connected to a given entity.

func (*Client) FindPath

func (c *Client) FindPath(ctx context.Context, fromType NodeLabel, fromID string, toType NodeLabel, toID string) (*QueryResult, error)

FindPath finds the shortest path between two entities.

func (*Client) FullTextSearch

func (c *Client) FullTextSearch(ctx context.Context, searchTerm string, entityTypes []NodeLabel) (*QueryResult, error)

FullTextSearch performs full-text search across entities.

func (*Client) GetIdeaImplementations

func (c *Client) GetIdeaImplementations(ctx context.Context, minVotes int) (*QueryResult, error)

GetIdeaImplementations returns features that implement ideas.

func (*Client) GetInitiativeImpact

func (c *Client) GetInitiativeImpact(ctx context.Context, initiativeID string) (*QueryResult, error)

GetInitiativeImpact returns all entities connected to an initiative.

func (*Client) GetProductOverview

func (c *Client) GetProductOverview(ctx context.Context, productID string) (*QueryResult, error)

GetProductOverview returns a summary of all entities for a product.

func (*Client) GetReleaseDependencies

func (c *Client) GetReleaseDependencies(ctx context.Context, releaseID string) (*QueryResult, error)

GetReleaseDependencies returns all features in a release and their dependencies.

func (*Client) ReadSession

func (c *Client) ReadSession(ctx context.Context) neo4j.SessionWithContext

ReadSession returns a new Neo4j session for read-only operations.

func (*Client) Run

func (c *Client) Run(ctx context.Context, cypher string, params map[string]any) (neo4j.ResultWithContext, error)

Run executes a Cypher query with parameters.

func (*Client) RunCypher

func (c *Client) RunCypher(ctx context.Context, cypher string, params map[string]any) (*QueryResult, error)

RunCypher executes a raw Cypher query.

func (*Client) Session

func (c *Client) Session(ctx context.Context) neo4j.SessionWithContext

Session returns a new Neo4j session.

func (*Client) SetProduct

func (c *Client) SetProduct(product string)

SetProduct sets the current product context for queries.

func (*Client) Verify

func (c *Client) Verify(ctx context.Context) error

Verify verifies connectivity to Neo4j.

type Config

type Config struct {
	URI      string
	Username string
	Password string
	Database string
}

Config holds Neo4j connection configuration.

func ConfigFromEnv

func ConfigFromEnv() *Config

ConfigFromEnv creates a Config from environment variables.

type NodeLabel

type NodeLabel string

NodeLabel represents a Neo4j node label.

const (
	NodeProduct     NodeLabel = "Product"
	NodeRelease     NodeLabel = "Release"
	NodeFeature     NodeLabel = "Feature"
	NodeRequirement NodeLabel = "Requirement"
	NodeEpic        NodeLabel = "Epic"
	NodeInitiative  NodeLabel = "Initiative"
	NodeGoal        NodeLabel = "Goal"
	NodeIdea        NodeLabel = "Idea"
	NodeUser        NodeLabel = "User"
	NodeComment     NodeLabel = "Comment"
	NodeTag         NodeLabel = "Tag"
)

type QueryResult

type QueryResult struct {
	Nodes         []map[string]any   `json:"nodes,omitempty"`
	Relationships []map[string]any   `json:"relationships,omitempty"`
	Paths         [][]map[string]any `json:"paths,omitempty"`
	Records       []map[string]any   `json:"records,omitempty"`
}

QueryResult holds the result of a graph query.

type RelationType

type RelationType string

RelationType represents a Neo4j relationship type.

const (
	// Containment relationships
	RelContains         RelationType = "CONTAINS"           // Product → Release, Feature, Epic, etc.
	RelBelongsTo        RelationType = "BELONGS_TO"         // Feature → Product
	RelInRelease        RelationType = "IN_RELEASE"         // Feature, Epic → Release
	RelHasRequirement   RelationType = "HAS_REQUIREMENT"    // Feature → Requirement
	RelPartOfInitiative RelationType = "PART_OF_INITIATIVE" // Feature, Epic → Initiative
	RelSupportsGoal     RelationType = "SUPPORTS_GOAL"      // Initiative, Feature → Goal

	// People relationships
	RelAssignedTo RelationType = "ASSIGNED_TO" // Feature, Requirement → User
	RelCreatedBy  RelationType = "CREATED_BY"  // Idea, Comment → User
	RelOwnedBy    RelationType = "OWNED_BY"    // Product, Initiative → User

	// Dependency/linking relationships
	RelDependsOn  RelationType = "DEPENDS_ON" // Feature → Feature
	RelBlocks     RelationType = "BLOCKS"     // Feature → Feature
	RelImplements RelationType = "IMPLEMENTS" // Feature → Idea
	RelRelatedTo  RelationType = "RELATED_TO" // Generic relationship
	RelParentOf   RelationType = "PARENT_OF"  // Epic → Feature, Initiative → Epic
	RelChildOf    RelationType = "CHILD_OF"   // Feature → Epic

	// Tagging
	RelTaggedWith RelationType = "TAGGED_WITH" // Feature, Epic → Tag

	// Comments
	RelCommentOn RelationType = "COMMENT_ON" // Comment → Feature, Idea, etc.

	// Time-based
	RelPrecedes RelationType = "PRECEDES" // Release → Release
	RelFollows  RelationType = "FOLLOWS"  // Release → Release
)

type SyncOptions

type SyncOptions struct {
	Product     string   // Product ID to sync
	Entities    []string // Specific entities to sync (nil = all)
	Incremental bool     // Only sync changes since last sync
}

SyncOptions configures a sync operation.

type SyncResult

type SyncResult struct {
	Entity       string
	NodesCreated int
	RelsCreated  int
	Duration     time.Duration
	Error        error
}

SyncResult contains the result of a sync operation.

type Syncer

type Syncer struct {
	// contains filtered or unexported fields
}

Syncer synchronizes Aha data to Neo4j graph database.

func NewSyncer

func NewSyncer(client *Client, ahaClient *aha.Client) *Syncer

NewSyncer creates a new graph syncer.

func (*Syncer) SyncAll

func (s *Syncer) SyncAll(ctx context.Context, opts SyncOptions) ([]SyncResult, error)

SyncAll syncs all entities for a product.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL