How afspies/ai-safety-papers works
Project Type and Purpose
• The project is a full-stack research paper tracking and summarization system.
• Its core purpose is to automatically fetch AI safety papers, run AI-powered summarizations and figure extraction routines, and then distribute the content via a static website (currently with a Next.js–like frontend and/or a Hugo-based static site) and planned channels like Telegram and Twitter.
Analyzing the File Structure
• The top-level directories are “backend” and “frontend”, which indicates a clear separation between the processing backend and the client-side (or website) frontend.
– The backend directory contains a variety of modules: APIs (in backend/src/api), figure extraction (backend/src/figure_extraction), models (backend/src/models), summarizer functionality (backend/src/summarizer), and utility functions. There’s also a rich set of test cases and archived scripts.
– The frontend directory contains components, pages, hooks, and configuration files (with Next.js–styled file names like layout.tsx, page.tsx and next.config files), suggesting an interactive website for viewing the curated paper archive.
• Additionally, configuration files, deployment scripts, and environment templates are present, indicating careful separation of concerns and external dependencies, such as Cloudflare R2 integration, Google Sheets, Semantic Scholar, and the Anthropic Claude API.
Key Components
a. External Services / APIs:
– Semantic Scholar API (for paper discovery)
– Anthropic Claude API (for AI summarization)
– Google Sheets API (for tracking and managing papers)
– Cloudflare R2 (as seen in backend/src/utils/cloudflare_r2.py) for asset storage
– Future/planned integrations: Telegram bot and Twitter bot
b. Backend System:
– API Subsystem: API endpoints, routers, and schemas (backend/src/api)
– Processing and Pipeline Subsystem: Includes paper fetching (from Semantic Scholar), Claude-based summarization (backend/src/summarizer), and figure extraction and processing routines (backend/src/figure_extraction)
– Models: Data representation for articles, figures, posts, and superseded storage integration (backend/src/models)
– Utility Modules: Configuration loader, PDF utilities, cloud integrations
– Data Storage: Processed papers stored as Markdown files under backend/processed_papers and scripts to regenerate or sync these files
– Testing & Scripting: Various tests and helper scripts to validate API integration and processing scripts
c. Frontend / Static Website:
– The frontend directory encompasses the presentation layer, with components (UI components, paper cards, navigation bars, etc.), pages, and layouts.
– There is also a deployment configuration (e.g., Netlify-related badges in README) and integration with static site generation (the README references Hugo, while the file tree shows a Next.js structure – it might be that both approaches are supported or that the system evolved over time).
Relationships and Data Flow
• Data originates from external services:
– Semantic Scholar is queried to discover or update research papers.
– Paper data is sent to the backend where it is processed; summaries are generated via Claude and figures are extracted from PDFs.
– Google Sheets is used to track and manage paper metadata.
• The processed paper content (stored as markdown files) is then fed into the static website generator or served by the web frontend.
• There is a feedback loop from deployment (via Netlify or equivalent) back to the source control and pipeline automation.
Architectural Patterns / Design Principles
• Separation of Concerns: Clear splitting between backend processing and frontend presentation.
• Modular Design: Distinct directories for APIs, processing (summarization, figure extraction), and models.
• Integration of External Services: Use of dedicated modules for interacting with external APIs (Semantic Scholar, Google Sheets, Claude).
• Testing and Maintenance: Presence of comprehensive test suites, archived scripts, and configuration management indicates robust design and ease of maintenance.