# borestad/blocklist-abuseipdb architecture

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

- Interactive diagram: https://gitdiagram.com/borestad/blocklist-abuseipdb
- Repository: https://github.com/borestad/blocklist-abuseipdb

## Overview

This project is a data aggregation and processing tool that creates and maintains blocklists of offenders (IPv4 and IPv6) using data from AbuseIPDB. The repository is built around scheduled (cron) tasks, file‐based storage of lists (grouped by time windows and confidence levels), and additional statistical “hall of shame” reports. The whole process is orchestrated with Deno scripts and a simple CI/CD integration via GitHub Actions.

##### Components Identification
a. Cron Scheduler Component:
- .cron folder as the scheduler layer.
- Jobs (e.g. abuseipdb jobs with subfolders for different update tasks) and corresponding scripts (in .cron/scripts such as “ip2ipinfo.ts”) that run on a schedule.
b. Data Processing and Aggregation Module:
- Deno environment (deno.json, deno.lock) and associated scripts that fetch data from AbuseIPDB and enrich it with metadata from ipinfo.io (using the ASN database).
- Transformation process that results in daily or time-based blocklist files (such as abuseipdb-s100-1d, 3d, etc.).
c. Data Storage and Aggregated Outputs:
- “db” directory which stores raw or processed IP list files segmented by date.
- “stats” directory that contains additional aggregated statistics (e.g. stats/blocks, stats/hallofshame, and stats/ips).
d. CI/CD Pipeline:
- GitHub workflows (from .github/workflows) that run automated tests or validations and possibly trigger the cron jobs.
e. Configuration/Utility Components:
- Utility build/deploy configurations such as the Justfile (in .cron/Justfile) and package.json which manage dependencies.

##### Relationships and Data-Flow
b. Data Processing module to the Data Storage “db” and “stats” directories to indicate that processed results are saved as file lists.
d. CI/CD pipeline (GitHub workflows) as an orchestrator that monitors code and, when changes occur, triggers the build and possibly testing of scheduled scripts.

##### Architectural Patterns and Design Principles
a. Batch processing pattern: scheduled scripts executing periodic fetch, process, and store tasks.
b. Use of file‐based data storage where each day’s data is stored in its own dated folder under “db.”
c. Separation of concerns: scheduling, processing/enrichment, and storage/aggregation are handled in distinct sets of files and directories.

##### Technologies and Frameworks
a. Deno is the runtime (as indicated by deno.json, deno.lock, and TypeScript files such as ip2ipinfo.ts).
b. GitHub Actions (configured in .github/workflows) provides the CI/CD framework.
c. External APIs from AbuseIPDB and ipinfo.io are an integral part of the data enrichment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        CI_CD["GitHub Actions"]
    end

    %% Cron Scheduler and Job Scripts
    subgraph "Scheduled Tasks"
        CronScheduler["Cron Scheduler"]
        CronJobScripts["Cron Job Scripts"]
    end

    %% Data Processing & Enrichment Module
    subgraph "Data Processing & Enrichment"
        DenoEnv["Deno Environment"]
        IPEngScript["IP Enrichment Script"]
        BlocklistFiles["Blocklist Files"]
    end

    %% External APIs
    subgraph "External Services"
        AbuseIPDB["AbuseIPDB API"]
        ipinfoAPI["ipinfo.io API"]
    end

    %% Data Storage
    subgraph "Data Storage"
        RawDB["Raw/Daily Blocklists"]
        AggregatedStats["Aggregated Statistics"]
    end

    %% Configuration & Utilities
    subgraph "Configurations & Utilities"
        Justfile["Justfile"]
        PackageJSON["package.json"]
    end

    %% Relationships
    CI_CD -->|"TriggerBuildTest"| CronScheduler
    CI_CD -->|"TriggerBuildTest"| DenoEnv

    CronScheduler -->|"TriggerCron"| DenoEnv
    CronJobScripts -->|"ScheduleJob"| DenoEnv

    DenoEnv -->|"FetchEnrichData"| AbuseIPDB
    DenoEnv -->|"FetchEnrichData"| ipinfoAPI

    IPEngScript -->|"Execute"| DenoEnv
    BlocklistFiles -->|"GenerateFiles"| DenoEnv

    DenoEnv -->|"StoreDailyResults"| RawDB
    DenoEnv -->|"StoreDailyResults"| AggregatedStats

    Justfile -->|"ManageConfig"| DenoEnv
    PackageJSON -->|"ManageConfig"| DenoEnv

    %% Click Events
    click CronScheduler "https://github.com/borestad/blocklist-abuseipdb/blob/main/.cron"
    click CronJobScripts "https://github.com/borestad/blocklist-abuseipdb/tree/main/.cron/jobs"
    click IPEngScript "https://github.com/borestad/blocklist-abuseipdb/blob/main/.cron/scripts/ip2ipinfo.ts"
    click DenoEnv "https://github.com/borestad/blocklist-abuseipdb/blob/main/deno.json"
    click BlocklistFiles "https://github.com/borestad/blocklist-abuseipdb/tree/main/abuseipdb-s100-*"
    click RawDB "https://github.com/borestad/blocklist-abuseipdb/tree/main/db"
    click AggregatedStats "https://github.com/borestad/blocklist-abuseipdb/tree/main/stats"
    click CI_CD "https://github.com/borestad/blocklist-abuseipdb/blob/main/.github/workflows/ci.yml"
    click Justfile "https://github.com/borestad/blocklist-abuseipdb/tree/main/.cron/Justfile"
    click PackageJSON "https://github.com/borestad/blocklist-abuseipdb/blob/main/package.json"

    %% Styles
    classDef scheduler fill:#f4cccc,stroke:#333,stroke-width:2px;
    classDef processing fill:#c9daf8,stroke:#333,stroke-width:2px;
    classDef storage fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef cicd fill:#ead1dc,stroke:#333,stroke-width:2px;
    classDef external fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef config fill:#d0e0e3,stroke:#333,stroke-width:2px;

    class CronScheduler,CronJobScripts cicd;
    class DenoEnv,IPEngScript,BlocklistFiles processing;
    class RawDB,AggregatedStats storage;
    class CI_CD cicd;
    class AbuseIPDB,ipinfoAPI external;
    class Justfile,PackageJSON config;
```
