How doyindev1/proof-of-contribution works
Project type and purpose
• Proof of Contribution is an open-source Node.js backend service (a RESTful API) that computes a TEA Rank for open-source packages by building dependency graphs across multiple ecosystems. It is not a full-stack app (no UI), but rather a backend analytics tool with pluggable integrations to external package registries.
File structure
• Root files:
• index.js (entry point / server startup)
• example.js (usage demonstration)
• tea.yaml (algorithm/config parameters: kappa, delta)
• models/Project.js: in-memory representation of a project + its dependency graph
• services/
• PackageManagerService.js: abstracts calls to npm, PyPI, Crates.io, RubyGems registries
• ProofOfContribution.js: contains the TEA Rank algorithm & spam-detection logic
• package.json / package-lock.json: defines runtime dependencies (Express, HTTP clients, etc.)
Key interactions and external systems
• HTTP Client (curl or other services) → Express HTTP Server (index.js routes)
• Server → PackageManagerService → External Package Registries (npm, PyPI, Crates, RubyGems)
• PackageManagerService → models/Project → ProofOfContribution → results
• HTTP Server → JSON response (teaRank, flags, stats)
Main components
a. Client Layer
• REST client (curl, CLI, other services)
b. API Layer
• index.js / Express app (HTTP route handling)
c. Business Logic Layer
• ProofOfContribution service (TEA Rank algorithm, spam detection)
• Configuration loader (tea.yaml)
d. Integration Layer
• PackageManagerService with connectors/adapters for each ecosystem
e. Data Model
• Project model (in-memory graph structure)
f. External Dependencies
• npm registry
• PyPI registry
• Crates.io registry
• RubyGems registry
Relationships and data flows
1. Client → HTTP Server (“POST /analyze”)
2. Server → PackageManagerService (“fetch dependencies”)
3. PackageManagerService → External Registry (“registry API calls”)
4. Registry → PackageManagerService (dependency lists)
5. PackageManagerService → Project Model (build graph)
6. Project Model → ProofOfContribution (“run TEA algorithm”)
7. ProofOfContribution → Server (“computed TEA Rank & flags”)
8. Server → Client (“JSON response”)
Architectural patterns and design principles
• Layered architecture: Presentation (API), Service (business logic), Integration (external connectors), Model
• Strategy/Adapter pattern for supporting multiple package manager ecosystems
• Configuration-driven parameters (tea.yaml) to tune kappa, delta, depth/width thresholds
• Separation of concerns: routing vs. algorithm vs. data‐fetching vs. config