Commerce Graph
The Commerce Graph is GullyPay's real-time graph of the commerce network. It records nodes (users, merchants, products) and edges (the relationships between them — purchases, referrals, and other connections) and powers recommendations, referral attribution, and network insights.
Every time a purchase is recorded, the graph links the buyer to the merchant and to the purchased product. Those connections accumulate into a network you can query for insights and recommendations.
A node has a nodeType (user, merchant, product), an entityId (the id of the underlying record), and a label. An edge connects a sourceId node to a targetId node with an edgeType (e.g. purchased, bought_from) and a weight.
Authentication
All /graph endpoints require a valid JWT access token.
Endpoints
/graph/merchants/:merchantId/insightsRead-only network summary for a merchant/graph/recommendationsGraph-powered recommendations for the authenticated user/graph/nodes/:typeList graph nodes of a given type/graph/nodes/:id/edgesList outbound edges from a node/graph/nodesCreate a graph node/graph/edgesCreate an edge between two nodes/graph/purchaseRecord a purchase (links user → product and user → merchant)GET /graph/merchants/:merchantId/insights
Returns an aggregated, read-only summary of the commerce graph for a merchant. All values are computed live from the graph tables — an empty graph returns real zeros and empty lists.
| Field | Type | Description |
|---|---|---|
merchantNodeId | string | null | The merchant's node id in the graph, or null if not yet present |
inGraph | boolean | Whether the merchant has appeared in the graph yet |
totalNodes | number | Total node count across the whole graph |
totalEdges | number | Total edge count across the whole graph |
nodesByType | array | Node counts grouped by type |
edgesByType | array | Edge counts grouped by type |
connectedCustomers | number | Distinct customers with a bought_from edge to this merchant |
purchaseEvents | number | Count of bought_from edges to this merchant |
recentActivity | array | Up to 10 most recent inbound edges, with the source node's label and type |
GET /graph/recommendations
Returns graph-powered recommendation nodes for the authenticated user, derived from the user's existing edges.
Recommendations are seeded from the user's own graph edges. Until an account has transacted across the network, this endpoint returns an empty array. As purchase activity accumulates, relevant merchants and products surface here.
GET /graph/nodes/:type
List all nodes of a given nodeType (user, merchant, or product).
POST /graph/purchase
Records a purchase in the graph. This ensures nodes exist for the user, merchant, and product, then creates a purchased edge (user → product) and a bought_from edge (user → merchant).
POST /graph/nodes
POST /graph/edges
Merchant Dashboard
The Commerce Network page in the merchant dashboard consumes GET /graph/merchants/:merchantId/insights and GET /graph/recommendations to display network stats (node/edge counts by type), connected customers, purchase events, recent network activity, and graph-powered recommendations — with real loading and empty states.
Next Steps
- x402 Protocol — monetize APIs the network can pay for
- AI Commerce — agents that transact across the graph
- API Reference — full REST API documentation