Related to Issue #833
PurlDB aggregates metadata for software packages identified by PURLs (Package URLs).
However, not all packages have equal importance within an ecosystem.
A structured popularity metric could help:
- Prioritize indexing and mining operations
- Identify critical and widely used packages
- Improve API filtering and ranking
- Focus computational resources on highly connected packages
This RFC proposes a graph-based popularity metric derived from dependency relationships.
After setting up PurlDB locally and reviewing packagedb/models.py, I observed:
- Dependencies are represented by the
DependentPackagemodel. - Each
DependentPackagelinks to a sourcePackagevia a ForeignKey. - The dependency target is stored as a PURL string (
purlfield), not as a ForeignKey to anotherPackage.
This effectively forms a directed dependency graph:
Package A ---> Package B
where B must be resolved from its PURL.
- Nodes: Canonical package identities (ignoring version initially)
- Edges: Dependency relationships
- Direction: A → B if A depends on B
For the initial proof of concept:
- Resolve dependency PURLs to canonical package identities.
- Ignore version to avoid graph fragmentation.
- Restrict computation to a single ecosystem (e.g., PyPI).
- In-degree (number of reverse dependencies)
- PageRank-style centrality over the dependency graph
This allows packages depended upon by important packages to receive higher scores.
- Freshness factor (based on
release_date) - Mining depth (
mining_level) - Optional decay for inactive packages
Two possible strategies:
- Compute popularity periodically via scheduled task
- Store result in database (e.g.,
popularity_scorefield) - Expose score via REST API
- Compute dynamically during API requests
- Likely too expensive for large graphs
Batch computation appears more scalable.
- Large ecosystems may contain millions of nodes.
- Version-level graphs may introduce excessive fragmentation.
- Initial implementation should:
- Operate at package identity level
- Be ecosystem-scoped
- Store precomputed scores
Future improvements may include:
- Strongly connected component analysis
- Weighted edges
- Version-aware ranking
- Should popularity be computed per ecosystem or globally?
- Should dependency resolution be materialized in a normalized table?
- Is ignoring version acceptable for the initial PoC?
- Should optional dependencies be weighted differently?
If this direction aligns with project goals:
- Implement a minimal PoC for one ecosystem
- Validate ranking quality
- Iterate on scoring methodology
- Integrate into PurlDB API
Feedback before implementation would be greatly appreciated.