# new-village/keibascraper architecture

> Architecture diagram of the GitHub repository new-village/keibascraper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/new-village/keibascraper
- Repository: https://github.com/new-village/keibascraper

## Overview

KeibaScraper is a Python library for fetching and parsing horse-racing data. Its main workflow is a caller invoking the public API, which dispatches to a data-specific loader; loaders fetch page content and pass it to configured HTML or JSON parsers, which return structured records. A separate calendar workflow retrieves race IDs, and helper utilities provide configurable transformations and SQLite query generation. The README documents the supported data types and capabilities; relationships below are limited to those visible in the excerpts or README.

Main entry points: [`keibascraper/parse.py`](https://github.com/new-village/keibascraper/blob/main/keibascraper/parse.py) (HTML parser), [`keibascraper/config`](https://github.com/new-village/keibascraper/tree/main/keibascraper/config) (Parse configuration), [`keibascraper/load.py`](https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py) (Load dispatcher), [`keibascraper/__init__.py`](https://github.com/new-village/keibascraper/blob/main/keibascraper/__init__.py) (Public API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_public_api["Public API<br/>[__init__.py]"]
end

subgraph group_loading["Data Loading"]
  node_load_dispatch["Load dispatcher<br/>[load.py]"]
  node_entry_loader["Entry loader<br/>[load.py]"]
  node_odds_loader["Odds loader<br/>[load.py]"]
  node_result_loader["Result loader<br/>[load.py]"]
  node_horse_loader["Horse loader<br/>[load.py]"]
  node_calendar_loader["Calendar loader<br/>[load.py]"]
end

subgraph group_parsing["Parsing"]
  node_html_parser["HTML parser<br/>[parse.py]"]
  node_json_parser["JSON parser<br/>[parse.py]"]
  node_parse_config["Parse configuration"]
end

subgraph group_utilities["Utilities"]
  node_parse_helpers["Parse transformations<br/>[helper.py]"]
  node_sql_helpers["SQLite query helpers<br/>[helper.py]"]
end

node_caller(("Library caller"))
node_netkeiba["Netkeiba"]
node_yahoo_schedule["Yahoo schedule"]

node_caller -->|"calls"| node_public_api
node_public_api -->|"exports"| node_load_dispatch
node_public_api -->|"exports"| node_sql_helpers
node_load_dispatch -->|"dispatches"| node_entry_loader
node_load_dispatch -->|"dispatches"| node_odds_loader
node_load_dispatch -->|"dispatches"| node_result_loader
node_load_dispatch -->|"dispatches"| node_horse_loader
node_public_api -->|"calls"| node_calendar_loader
node_entry_loader -->|"loads rules"| node_parse_config
node_odds_loader -->|"loads rules"| node_parse_config
node_result_loader -->|"loads rules"| node_parse_config
node_horse_loader -->|"loads rules"| node_parse_config
node_entry_loader -->|"fetches pages"| node_netkeiba
node_odds_loader -->|"fetches pages"| node_netkeiba
node_result_loader -->|"fetches pages"| node_netkeiba
node_horse_loader -->|"fetches pages"| node_netkeiba
node_entry_loader -->|"parses HTML"| node_html_parser
node_odds_loader -->|"parses JSON"| node_json_parser
node_result_loader -->|"parses HTML"| node_html_parser
node_horse_loader -->|"parses HTML"| node_html_parser
node_html_parser -->|"loads rules"| node_parse_config
node_json_parser -->|"loads rules"| node_parse_config
node_html_parser -->|"formats values"| node_parse_helpers
node_json_parser -->|"formats values"| node_parse_helpers
node_calendar_loader -->|"fetches schedule"| node_yahoo_schedule
node_calendar_loader -->|"parses schedule"| node_html_parser

click node_public_api "https://github.com/new-village/keibascraper/blob/main/keibascraper/__init__.py"
click node_load_dispatch "https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py"
click node_entry_loader "https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py"
click node_odds_loader "https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py"
click node_result_loader "https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py"
click node_horse_loader "https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py"
click node_calendar_loader "https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py"
click node_html_parser "https://github.com/new-village/keibascraper/blob/main/keibascraper/parse.py"
click node_json_parser "https://github.com/new-village/keibascraper/blob/main/keibascraper/parse.py"
click node_parse_config "https://github.com/new-village/keibascraper/tree/main/keibascraper/config"
click node_parse_helpers "https://github.com/new-village/keibascraper/blob/main/keibascraper/helper.py"
click node_sql_helpers "https://github.com/new-village/keibascraper/blob/main/keibascraper/helper.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api toneBlue
class node_load_dispatch,node_entry_loader,node_odds_loader,node_result_loader,node_horse_loader,node_calendar_loader toneAmber
class node_html_parser,node_json_parser,node_parse_config toneMint
class node_parse_helpers,node_sql_helpers toneRose
class node_caller,node_netkeiba,node_yahoo_schedule toneIndigo
```

## Components

### Public API

- [Public API](https://github.com/new-village/keibascraper/blob/main/keibascraper/__init__.py): `keibascraper/__init__.py`

### Data Loading

- [Load dispatcher](https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py): `keibascraper/load.py`
- [Entry loader](https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py): `keibascraper/load.py`
- [Odds loader](https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py): `keibascraper/load.py`
- [Result loader](https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py): `keibascraper/load.py`
- [Horse loader](https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py): `keibascraper/load.py`
- [Calendar loader](https://github.com/new-village/keibascraper/blob/main/keibascraper/load.py): `keibascraper/load.py`

### Parsing

- [HTML parser](https://github.com/new-village/keibascraper/blob/main/keibascraper/parse.py): `keibascraper/parse.py`
- [JSON parser](https://github.com/new-village/keibascraper/blob/main/keibascraper/parse.py): `keibascraper/parse.py`
- [Parse configuration](https://github.com/new-village/keibascraper/tree/main/keibascraper/config): `keibascraper/config`

### Utilities

- [Parse transformations](https://github.com/new-village/keibascraper/blob/main/keibascraper/helper.py): `keibascraper/helper.py`
- [SQLite query helpers](https://github.com/new-village/keibascraper/blob/main/keibascraper/helper.py): `keibascraper/helper.py`

### Other components

- **Library caller**
- **Netkeiba**
- **Yahoo schedule**

## Connections

- Library caller → Public API: calls (evidence: `README.md`)
- Public API → Load dispatcher: exports (evidence: `keibascraper/__init__.py`)
- Public API → SQLite query helpers: exports (evidence: `keibascraper/__init__.py`)
- Load dispatcher → Entry loader: dispatches (evidence: `keibascraper/load.py`)
- Load dispatcher → Odds loader: dispatches (evidence: `keibascraper/load.py`)
- Load dispatcher → Result loader: dispatches (evidence: `keibascraper/load.py`)
- Load dispatcher → Horse loader: dispatches (evidence: `keibascraper/load.py`)
- Public API → Calendar loader: calls (evidence: `keibascraper/load.py`)
- Entry loader → Parse configuration: loads rules (evidence: `keibascraper/load.py`)
- Odds loader → Parse configuration: loads rules (evidence: `keibascraper/load.py`)
- Result loader → Parse configuration: loads rules (evidence: `keibascraper/load.py`)
- Horse loader → Parse configuration: loads rules (evidence: `keibascraper/load.py`)
- Entry loader → Netkeiba: fetches pages (evidence: `keibascraper/load.py`)
- Odds loader → Netkeiba: fetches pages (evidence: `keibascraper/load.py`)
- Result loader → Netkeiba: fetches pages (evidence: `keibascraper/load.py`)
- Horse loader → Netkeiba: fetches pages (evidence: `keibascraper/load.py`)
- Entry loader → HTML parser: parses HTML (evidence: `keibascraper/load.py`)
- Odds loader → JSON parser: parses JSON (evidence: `keibascraper/load.py`)
- Result loader → HTML parser: parses HTML (evidence: `keibascraper/load.py`)
- Horse loader → HTML parser: parses HTML (evidence: `keibascraper/load.py`)
- HTML parser → Parse configuration: loads rules (evidence: `keibascraper/parse.py`)
- JSON parser → Parse configuration: loads rules (evidence: `keibascraper/parse.py`)
- HTML parser → Parse transformations: formats values (evidence: `keibascraper/parse.py`)
- JSON parser → Parse transformations: formats values (evidence: `keibascraper/parse.py`)
- Calendar loader → Yahoo schedule: fetches schedule (evidence: `keibascraper/load.py`)
- Calendar loader → HTML parser: parses schedule (evidence: `keibascraper/load.py`)
