# kevinwu23/sourcecheckup architecture

> Architecture diagram of the GitHub repository kevinwu23/sourcecheckup, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kevinwu23/sourcecheckup
- Repository: https://github.com/kevinwu23/sourcecheckup

## Overview

##### Project type and purpose
- Type: A command-line, open-source data-processing tool.
- Purpose: Given a citation URL or a direct question, it extracts content, queries an LLM to generate and verify medically relevant statements, and outputs a CSV summarizing which statements are supported by citations.

##### File structure
- Top-level files
– run.py: main orchestration of input, processing, and output
– utils.py: helper functions (URL extraction and GPT API wrapper)
– prompts.json: predefined prompt templates for the LLM
– requirements.txt: Python dependencies (pandas, argparse, json, etc.)
– README.md: documentation and project overview
- No nested directories—this is a single-module tool
- No front-end or database folders, but there is an external data directory referenced in the README (Google Drive)

##### Key insights from README
- Inputs: --citation_url or --question via CLI
- Workflow:
1. Fetch URL content (if citation_url)
2. Feed content or question to GPTWrapper with specific prompts
3. Parse LLM response into statements + citations
4. Evaluate support for each statement
5. Write results to a CSV and compute summary metrics
- External dependencies: LLM API (OpenAI or similar), remote document sources, Google Drive for bulk data

##### Essential elements without over-splitting
- Every function in utils.py and major step in run.py is represented by a component or sub-component
- Do not add fictitious layers; stick to what the file tree and README describe

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Internal Modules
    subgraph "Core Processing" 
        direction TB
        CLI["CLI Interface"]:::internal
        URLFetcher["URL Fetcher\n(extract_contents_from_url)"]:::internal
        Parser["Response Parser"]:::internal
        Verifier["Verifier/Decision Engine"]:::internal
        CSVWriter["CSV Writer & Summary Calculator"]:::internal
    end

    subgraph "LLM Integration"
        direction TB
        PromptMgr["Prompt Manager"]:::internal
        GPTWrapper["GPTWrapper\n(LLM API Abstraction)"]:::internal
    end

    %% External Services
    subgraph "External Services"
        direction TB
        LLMService["LLM Service\n(OpenAI API)"]:::external
        CitationSources["Citation Source URLs"]:::external
        GoogleDrive["Google Drive Bulk Data"]:::external
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        LocalFS["Local File System\n(Output CSV)"]:::datastore
    end

    %% Connections
    CLI -->|"--citation_url or --question"| CLI
    CLI -->|"invoke if citation_url"| URLFetcher
    URLFetcher -->|"HTML content"| PromptMgr
    CLI -->|"select prompt"| PromptMgr
    PromptMgr -->|"LLM prompt"| GPTWrapper
    GPTWrapper -->|"API request"| LLMService
    LLMService -->|"API response"| GPTWrapper
    GPTWrapper -->|"raw LLM output"| Parser
    Parser -->|"parsed statements"| Verifier
    Verifier -->|"verification results"| CSVWriter
    CSVWriter -->|"write CSV rows"| LocalFS
    CSVWriter -->|"compute summary metrics"| CLI

    %% External data integrations
    CLI -->|"bulk data access"| GoogleDrive
    URLFetcher -->|"fetch from URL"| CitationSources

    %% Click Events
    click CLI "https://github.com/kevinwu23/sourcecheckup/blob/main/run.py"
    click URLFetcher "https://github.com/kevinwu23/sourcecheckup/blob/main/utils.py"
    click PromptMgr "https://github.com/kevinwu23/sourcecheckup/blob/main/prompts.json"
    click GPTWrapper "https://github.com/kevinwu23/sourcecheckup/blob/main/utils.py"
    click Parser "https://github.com/kevinwu23/sourcecheckup/blob/main/utils.py"
    click Verifier "https://github.com/kevinwu23/sourcecheckup/blob/main/utils.py"
    click CSVWriter "https://github.com/kevinwu23/sourcecheckup/blob/main/run.py"

    %% Styles
    classDef internal fill:#E8F1FF,stroke:#0366d6,stroke-width:2px
    classDef external fill:#FFF5E6,stroke:#d97706,stroke-width:2px
    classDef datastore fill:#E6FFED,stroke:#22863a,stroke-width:2px
```
