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 ¶
- func MergeNode(label NodeLabel, id string, props map[string]any) string
- func MergeRelationship(fromLabel NodeLabel, toLabel NodeLabel, relType RelationType) string
- func SchemaConstraints() []string
- func SchemaIndexes() []string
- type Client
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) CreateRelationshipIfExists(ctx context.Context, fromLabel NodeLabel, fromID string, toLabel NodeLabel, ...) error
- func (c *Client) CreateSchema(ctx context.Context) error
- func (c *Client) DropSchema(ctx context.Context) error
- func (c *Client) ExecuteRead(ctx context.Context, work func(tx neo4j.ManagedTransaction) (any, error)) (any, error)
- func (c *Client) ExecuteWrite(ctx context.Context, work func(tx neo4j.ManagedTransaction) (any, error)) (any, error)
- func (c *Client) FindConnectedFeatures(ctx context.Context, entityType NodeLabel, entityID string, depth int) (*QueryResult, error)
- func (c *Client) FindPath(ctx context.Context, fromType NodeLabel, fromID string, toType NodeLabel, ...) (*QueryResult, error)
- func (c *Client) FullTextSearch(ctx context.Context, searchTerm string, entityTypes []NodeLabel) (*QueryResult, error)
- func (c *Client) GetIdeaImplementations(ctx context.Context, minVotes int) (*QueryResult, error)
- func (c *Client) GetInitiativeImpact(ctx context.Context, initiativeID string) (*QueryResult, error)
- func (c *Client) GetProductOverview(ctx context.Context, productID string) (*QueryResult, error)
- func (c *Client) GetReleaseDependencies(ctx context.Context, releaseID string) (*QueryResult, error)
- func (c *Client) ReadSession(ctx context.Context) neo4j.SessionWithContext
- func (c *Client) Run(ctx context.Context, cypher string, params map[string]any) (neo4j.ResultWithContext, error)
- func (c *Client) RunCypher(ctx context.Context, cypher string, params map[string]any) (*QueryResult, error)
- func (c *Client) Session(ctx context.Context) neo4j.SessionWithContext
- func (c *Client) SetProduct(product string)
- func (c *Client) Verify(ctx context.Context) error
- type Config
- type NodeLabel
- type QueryResult
- type RelationType
- type SyncOptions
- type SyncResult
- type Syncer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (*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 ¶
CreateSchema creates all constraints and indexes in the database.
func (*Client) DropSchema ¶
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 ¶
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 ¶
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 ¶
SetProduct sets the current product context for queries.
type Config ¶
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 (*Syncer) SyncAll ¶
func (s *Syncer) SyncAll(ctx context.Context, opts SyncOptions) ([]SyncResult, error)
SyncAll syncs all entities for a product.