Library Stats & Details
Relevant source files
The following files were used as context for generating this wiki page:
- server.js
- scripts/generate_knowledge_base.py
- knowledge/papers/graph-visualization-efficiency-of-popular-web-based-libraries.json
- knowledge/papers/a-data-driven-methodology-for-quality-aware-code-fixing.json
- knowledge/papers/impact-of-co-occurrences-of-code-smells-and-design-patterns-on-internal-code-qua.json
Introduction
The Library Stats & Details system within CodeScholar provides a comprehensive framework for quantifying, analyzing, and reporting on the academic paper repository. Its primary purpose is to offer AI agents and developers a structured overview of the library's composition, including coverage metrics, citation distributions, and metadata completeness. This system enables the Model Context Protocol (MCP) server to provide context-aware insights into the research foundations available for code linking and concept extraction.
The system operates through a multi-pass pipeline that transforms raw paper metadata into a tiered knowledge architecture consisting of problems, techniques, and evidence (papers). By maintaining detailed statistics, CodeScholar ensures that the information served to users is backed by measurable metrics such as citation counts, year distributions, and relevance scores.
Sources: server.js:284-332, scripts/generate_knowledge_base.py:22-30
Architecture and Data Flow
The library statistics are generated by aggregating data from the unified_library.json file and in-memory indexes maintained by the MCP server. The logic is divided between a generation pipeline that builds the knowledge base and a server-side analytics module that reports real-time library health.
Statistics Generation Flow
The following diagram illustrates how paper data is processed to generate library statistics and structured knowledge components.
The pipeline clusters research into three layers: Problems (decision matrices), Techniques (algorithms/pseudocode), and Papers (DOI/benchmarks/evidence).
Sources: scripts/generate_knowledge_base.py:22-31, server.js:284-290
Key Metrics and Data Structure
The library tracks several categories of data to determine the "health" and "reach" of the academic repository. These metrics are exposed via the get_library_stats tool.
Library Coverage Metrics
Coverage metrics evaluate the richness of the metadata available for each paper, which directly impacts the effectiveness of hybrid search (combining text matching and vector similarity).
| Metric | Description | Source Field |
|---|---|---|
| Total Papers | Count of all unique paper entries in the library. | papers.length |
| With Abstract | Papers containing textual summaries for keyword indexing. | paper.abstract |
| With DOI | Papers with Digital Object Identifiers for external verification. | paper.identifiers.doi |
| With Citations | Papers with recorded citation counts from scholarly databases. | paper.metadata.citation_count |
| With Embedding | Papers that have been processed for vector-based semantic search. | paper.analysis.embedding |
Sources: server.js:285-291, scripts/generate_knowledge_base.py:192-205
Citation and Temporal Distribution
The system analyzes the impact and age of the research papers to prioritize "high-value" connections (techniques proven in one domain that may solve problems in another).
- Average Citations: Calculated across all papers with a non-zero citation count.
- Max Citations: Identifies the most influential paper in the current library.
- Year Distribution: A mapping of publication years to the frequency of papers, allowing agents to filter for "emerging" vs. "established" research.
Sources: server.js:294-308, scripts/generate_knowledge_base.py:535-542
API and Implementation
Statistics Retrieval (get_library_stats)
The MCP server provides a dedicated tool for fetching library details. This is used by AI agents to understand the scope of the search space before executing complex queries.
The server implementation uses an in-memory paperIndex (ID to Paper mapping) and a titleIndex for rapid aggregation.
Sources: server.js:284-332, server.js:46-51
Data-Driven Knowledge Cards
Individual paper details are structured into JSON/Markdown cards that include performance metrics and implementation guides. For example, the Quality Aware Code Fixing module tracks functional and syntactic similarity metrics (e.g., 85% and 90% respectively) to validate recommendations.
{
"benchmarks": {
"metrics": [
"functional similarity: 85%",
"syntactic similarity: 90%"
],
"improvement": "20% improvement over existing tools"
}
}
Sources: knowledge/papers/a-data-driven-methodology-for-quality-aware-code-fixing.json:44-54, knowledge/papers/graph-visualization-efficiency-of-popular-web-based-libraries.json:37-46
Summary
The Library Stats & Details system is a critical component of the CodeScholar architecture. It provides the empirical foundation required for the "Link Papers to Code" flagship tool, ensuring that research recommendations are not only semantically relevant but also statistically significant based on citation counts and benchmarked improvements. By maintaining a 3-layer knowledge architecture (Problems, Techniques, Papers), the system facilitates emergent discovery across different research domains.
Sources: scripts/generate_knowledge_base.py:920-945, server.js:636-645