# f2855631/pokemon-crawler architecture

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

- Interactive diagram: https://gitdiagram.com/f2855631/pokemon-crawler
- Repository: https://github.com/f2855631/pokemon-crawler

## Overview

##### Project type and purpose
- This is a small, open-source, data-pipeline/CLI tool whose primary functions are to (a) fetch and store Pokémon images locally, and (b) update local JSON data files with Pokémon metadata.
- It is not a web or mobile app, but a scheduled/background data-processing script that runs on a runtime (GitHub Actions or local Python interpreter).

##### File structure
- Top level:
- image_downloader.py – fetches images from an external Pokémon website and stores them under /images
- json_updater.py – reads and writes the local JSON data files (pokemon_data.json, pokemon_generations.json)
- images/ – target directory for downloaded images
- pokemon_data.json & pokemon_generations.json – local storage of Pokémon metadata
- .github/workflows/update-all.yml – CI workflow that schedules or triggers the scripts automatically
- No separate “frontend” or “backend” folders; it’s a single service with two main modules.

##### README for additional insights
- Contains only copyright information and usage disclaimer
- No architectural or usage instructions, confirming it’s a simple script-based tool

##### Main components & their relationships
a. Components
- Scheduler/Orchestrator (GitHub Actions or cron)
- image_downloader.py module
- json_updater.py module
- External HTTP source (Pokémon official website)
- Local file system storage (images/ folder + JSON files)
b. Interactions
- Scheduler → triggers both Python scripts
- image_downloader.py → sends HTTP GET requests → external website → receives image bytes → writes to images/ directory
- json_updater.py → reads/writes pokemon_data.json & pokemon_generations.json → persists updated metadata
c. Architectural patterns/ principles
- Modular design – two distinct scripts each handling one responsibility (Single Responsibility Principle)
- External dependency isolation – network I/O separated from file I/O
- Data pipeline pattern – scheduled ingestion (images + JSON) → local storage update
d. Key technologies/libraries
- Python 3.x runtime
- requests or urllib (for HTTP)
- JSON standard library
- GitHub Actions (YAML) for CI scheduling

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestration Layer
    Scheduler["Scheduler / Orchestrator"]:::scheduler
    Scheduler -.->|"triggers"| ImageDownloader
    Scheduler -.->|"triggers"| JSONUpdater

    %% Processing Modules
    ImageDownloader["image_downloader.py"]:::code
    JSONUpdater["json_updater.py"]:::code

    %% External Service
    ExternalAPI(("Pokémon Official API")):::external

    %% Local Storage Subgraph
    subgraph "Local Storage"
        direction TB
        Images["images/"]:::storage
        DataJSON["pokemon_data.json"]:::storage
        GenJSON["pokemon_generations.json"]:::storage
    end

    %% Data Flows
    ImageDownloader -->|"HTTP GET"| ExternalAPI
    ExternalAPI -->|"image bytes"| ImageDownloader
    ImageDownloader -->|"writes images"| Images

    JSONUpdater -->|"reads/writes metadata"| DataJSON
    JSONUpdater -->|"reads/writes metadata"| GenJSON

    %% Click Events
    click Scheduler "https://github.com/f2855631/pokemon-crawler/blob/main/.github/workflows/update-all.yml"
    click ImageDownloader "https://github.com/f2855631/pokemon-crawler/blob/main/image_downloader.py"
    click JSONUpdater "https://github.com/f2855631/pokemon-crawler/blob/main/json_updater.py"
    click Images "https://github.com/f2855631/pokemon-crawler/tree/main/images/"
    click DataJSON "https://github.com/f2855631/pokemon-crawler/blob/main/pokemon_data.json"
    click GenJSON "https://github.com/f2855631/pokemon-crawler/blob/main/pokemon_generations.json"

    %% Styles
    classDef code fill:#D6E9FF,stroke:#0366d6,color:#000;
    classDef storage fill:#E2F0CB,stroke:#6AA121,color:#000;
    classDef external fill:#F2F2F2,stroke:#999,color:#333;
    classDef scheduler fill:#FFE0B2,stroke:#E65100,color:#000;
```
