# xlcnd/isbnlib-bnf architecture

> Architecture diagram of the GitHub repository xlcnd/isbnlib-bnf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xlcnd/isbnlib-bnf
- Repository: https://github.com/xlcnd/isbnlib-bnf

## Overview

1. **Repository purpose**
   - This is a small Python package, `isbnlib-bnf`, whose job is to add a new metadata provider named `bnf` to the `isbnlib` ecosystem.
   - The external dependency boundary is the **BnF Catalogue Général** service from the Bibliothèque nationale de France, used to retrieve book metadata for French publications.

2. **Core runtime package**
   - The production code lives entirely in the `isbnlib_bnf/` package.
   - `__init__.py` is the package entry point and likely exposes the plugin in the form expected by `isbnlib`.
   - `_bnf.py` is the implementation module where the BnF-specific lookup and metadata mapping logic resides.

3. **Primary data flow**
   - An `isbnlib` consumer asks for metadata through the `bnf` provider.
   - The plugin translates an ISBN into a BnF lookup request.
   - BnF response data is parsed and normalized into the metadata shape `isbnlib` expects.
   - The normalized metadata is returned to the caller, making BnF an interchangeable provider behind the `isbnlib` plugin interface.

4. **Integration boundary**
   - The main architectural boundary is between:
     - the **local Python plugin code**, and
     - the **remote BnF catalogue service**.
   - Everything else in the repo supports packaging, testing, and release of that integration layer.

5. **Test subsystem**
   - Tests are isolated under `isbnlib_bnf/test/`.
   - `test_metadata.py` appears to be the main verification point, likely checking that metadata extraction and provider behavior work as expected.
   - The presence of a dedicated test package suggests the repository focuses on correctness of response parsing and provider output rather than on multiple application modules.

6. **Packaging and distribution**
   - The project is distributed as a standard Python package using `setup.py`, `setup.cfg`, and `MANIFEST.in`.
   - Dependency management is split into runtime and development requirements via `requirements.txt`, `requirements-dev.in`, and `requirements-dev.txt`.
   - This is a library-style repository, not an application server or CLI tool.

7. **Development and quality tooling**
   - `tox.ini` and `tox-dev.ini` indicate isolated test and lint environments.
   - `setup.cfg` likely centralizes formatting, linting, and test configuration.
   - `codeql-analysis.yml` suggests automated security scanning is part of the quality pipeline.

8. **CI/CD and release flow**
   - GitHub Actions workflows handle the main repo automation:
     - `basictests.yml` for test execution,
     - `codeql-analysis.yml` for code scanning,
     - `create-release.yaml` for release publication,
     - `wip.yml` and `stale.yml` for contribution hygiene.
   - This repository is maintained as a packaged open-source library with automated validation and release steps.

9. **Documentation and contributor surface**
   - `README.rst` explains installation and usage at the package level.
   - Standard project governance files are present: `LICENSE-LGPL.txt`, `CODE_OF_CONDUCT.md`, `CONTRIBUTING.md`, `SECURITY.md`, and issue/PR templates.
   - These files matter operationally because they define how the library is consumed and maintained, though they do not affect runtime behavior.

10. **What to draw in an architecture diagram**
   - The central node should be the `isbnlib_bnf` plugin package.
   - Draw one outbound dependency from that package to the **BnF Catalogue Général** service.
   - Draw one inbound dependency from **isbnlib** or any application using `isbnlib` into this plugin.
   - Surround it with supporting boxes for **tests**, **packaging/distribution**, and **GitHub Actions CI**.

11. **Architectural summary**
   - Overall, this is a thin integration plugin: minimal local state, no database, no internal service mesh, and no persistent infrastructure.
   - Its architecture is dominated by request/response translation between `isbnlib` and an external bibliographic catalog.

Main entry points: [`isbnlib_bnf/_bnf.py`](https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/_bnf.py) (BnF lookup), [`isbnlib_bnf/__init__.py`](https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/__init__.py) (bnf entry), [`.github/workflows/basictests.yml`](https://github.com/xlcnd/isbnlib-bnf/blob/dev/.github/workflows/basictests.yml) (GitHub Actions), [`isbnlib_bnf/test/test_metadata.py`](https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/test/test_metadata.py) (Metadata tests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_isbnlib_consumer(("isbnlib app<br/>caller"))
  node_package_entry["bnf entry<br/>plugin entrypoint<br/>[__init__.py]"]
  node_bnf_impl["BnF lookup<br/>provider logic<br/>[_bnf.py]"]
  node_bnf_service[("BnF catalogue<br/>remote service")]
  node_runtime_package["Plugin package<br/>python package"]
end

subgraph group_support["Support"]
  node_test_suite["Tests<br/>test subsystem<br/>[test_metadata.py]"]
  node_test_metadata["Metadata tests<br/>unit tests<br/>[test_metadata.py]"]
  node_package_cfg["Packaging<br/>dist config<br/>[setup.py]"]
  node_build_cfg["Build config<br/>project config<br/>[setup.cfg]"]
  node_deps["Requirements<br/>deps files<br/>[requirements.txt]"]
  node_tox_cfg["Tox envs<br/>test config<br/>[tox.ini]"]
  node_docs["Docs & policy<br/>project docs<br/>[README.rst]"]
end

subgraph group_automation["Automation"]
  node_ci_workflows["GitHub Actions<br/>ci workflows<br/>[basictests.yml]"]
  node_tests_ci["Test workflow<br/>ci job<br/>[basictests.yml]"]
  node_scan_ci["CodeQL<br/>security scan"]
  node_release_ci["Release flow<br/>release workflow"]
end

node_isbnlib_consumer -->|"requests metadata"| node_package_entry
node_package_entry -->|"delegates"| node_bnf_impl
node_bnf_impl -->|"queries"| node_bnf_service
node_bnf_service -->|"returns data"| node_bnf_impl
node_bnf_impl -->|"metadata"| node_isbnlib_consumer
node_runtime_package -.->|"contains"| node_package_entry
node_runtime_package -.->|"contains"| node_bnf_impl
node_test_suite -.->|"includes"| node_test_metadata
node_test_metadata -->|"verifies"| node_bnf_impl
node_test_metadata -->|"verifies"| node_package_entry
node_package_cfg -->|"builds"| node_runtime_package
node_build_cfg -.->|"configures"| node_package_cfg
node_deps -.->|"supports install"| node_runtime_package
node_tox_cfg -->|"runs"| node_test_suite
node_docs -.->|"explains use"| node_package_entry
node_ci_workflows -.->|"includes"| node_tests_ci
node_ci_workflows -.->|"includes"| node_scan_ci
node_ci_workflows -.->|"includes"| node_release_ci
node_tests_ci -->|"runs"| node_test_suite
node_scan_ci -->|"scans"| node_runtime_package
node_release_ci -->|"publishes"| node_package_cfg

click node_package_entry "https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/__init__.py"
click node_bnf_impl "https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/_bnf.py"
click node_test_suite "https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/test/test_metadata.py"
click node_test_metadata "https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/test/test_metadata.py"
click node_package_cfg "https://github.com/xlcnd/isbnlib-bnf/blob/dev/setup.py"
click node_build_cfg "https://github.com/xlcnd/isbnlib-bnf/blob/dev/setup.cfg"
click node_deps "https://github.com/xlcnd/isbnlib-bnf/blob/dev/requirements.txt"
click node_tox_cfg "https://github.com/xlcnd/isbnlib-bnf/blob/dev/tox.ini"
click node_docs "https://github.com/xlcnd/isbnlib-bnf/blob/dev/README.rst"
click node_ci_workflows "https://github.com/xlcnd/isbnlib-bnf/blob/dev/.github/workflows/basictests.yml"
click node_tests_ci "https://github.com/xlcnd/isbnlib-bnf/blob/dev/.github/workflows/basictests.yml"
click node_scan_ci "https://github.com/xlcnd/isbnlib-bnf/blob/dev/.github/workflows/codeql-analysis.yml"
click node_release_ci "https://github.com/xlcnd/isbnlib-bnf/blob/dev/.github/workflows/create-release.yaml"

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_isbnlib_consumer,node_package_entry,node_bnf_impl,node_bnf_service,node_runtime_package toneBlue
class node_test_suite,node_test_metadata,node_package_cfg,node_build_cfg,node_deps,node_tox_cfg,node_docs toneAmber
class node_ci_workflows,node_tests_ci,node_scan_ci,node_release_ci toneMint
```

## Components

### Runtime

Core plugin code and external service boundary

- **isbnlib app**: caller · Any application or library asking isbnlib for BnF metadata
- [bnf entry](https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/__init__.py): plugin entrypoint · Package entry point exposing the BnF provider to isbnlib · `isbnlib_bnf/__init__.py`
- [BnF lookup](https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/_bnf.py): provider logic · ISBN lookup, request translation, and metadata normalization against the BnF catalogue · `isbnlib_bnf/_bnf.py`
- **BnF catalogue**: remote service · Bibliothèque nationale de France Catalogue Général used as the metadata source
- **Plugin package**: python package · The installable isbnlib-bnf distribution containing the runtime provider

### Support

Tests, packaging, and project documentation

- [Tests](https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/test/test_metadata.py): test subsystem · Automated verification for provider behavior and metadata parsing · `isbnlib_bnf/test/test_metadata.py`
- [Metadata tests](https://github.com/xlcnd/isbnlib-bnf/blob/dev/isbnlib_bnf/test/test_metadata.py): unit tests · Primary checks for returned metadata shape and lookup behavior · `isbnlib_bnf/test/test_metadata.py`
- [Packaging](https://github.com/xlcnd/isbnlib-bnf/blob/dev/setup.py): dist config · Setuptools and release metadata for building and publishing the library · `setup.py`
- [Build config](https://github.com/xlcnd/isbnlib-bnf/blob/dev/setup.cfg): project config · Shared package, lint, and test configuration · `setup.cfg`
- [Requirements](https://github.com/xlcnd/isbnlib-bnf/blob/dev/requirements.txt): deps files · Runtime and development dependency pinning · `requirements.txt`
- [Tox envs](https://github.com/xlcnd/isbnlib-bnf/blob/dev/tox.ini): test config · Isolated test and development environments · `tox.ini`
- [Docs & policy](https://github.com/xlcnd/isbnlib-bnf/blob/dev/README.rst): project docs · README, contribution guidance, license, and security policy · `README.rst`

### Automation

CI and release workflows

- [GitHub Actions](https://github.com/xlcnd/isbnlib-bnf/blob/dev/.github/workflows/basictests.yml): ci workflows · Automated tests, scanning, release, and repository hygiene · `.github/workflows/basictests.yml`
- [Test workflow](https://github.com/xlcnd/isbnlib-bnf/blob/dev/.github/workflows/basictests.yml): ci job · Workflow that runs the package test suite · `.github/workflows/basictests.yml`
- [CodeQL](https://github.com/xlcnd/isbnlib-bnf/blob/dev/.github/workflows/codeql-analysis.yml): security scan · Automated code scanning workflow · `.github/workflows/codeql-analysis.yml`
- [Release flow](https://github.com/xlcnd/isbnlib-bnf/blob/dev/.github/workflows/create-release.yaml): release workflow · Workflow that publishes releases · `.github/workflows/create-release.yaml`

## Connections

- isbnlib app → bnf entry: requests metadata · An isbnlib consumer invokes the provider through the plugin entry point
- bnf entry → BnF lookup: delegates · The entry module hands provider work to the BnF implementation
- BnF lookup → BnF catalogue: queries · ISBN lookups are translated into requests to the remote BnF catalogue
- BnF catalogue → BnF lookup: returns data · Catalogue responses are parsed and normalized by the provider
- BnF lookup → isbnlib app: metadata · Normalized isbnlib-shaped metadata is returned to the caller
- Plugin package → bnf entry: contains · The installable package exposes the plugin entry module
- Plugin package → BnF lookup: contains · The package includes the BnF provider implementation
- Tests → Metadata tests: includes · The test package contains the main metadata verification module
- Metadata tests → BnF lookup: verifies · Tests exercise the lookup and mapping logic
- Metadata tests → bnf entry: verifies · Tests confirm provider behavior through the public package surface
- Packaging → Plugin package: builds · Packaging configuration assembles the library distribution
- Build config → Packaging: configures · Shared project settings feed packaging and tooling behavior
- Requirements → Plugin package: supports install · Dependency files define runtime and development requirements
- Tox envs → Tests: runs · Tox definitions drive isolated test environments
- Docs & policy → bnf entry: explains use · Project documentation describes installation and provider usage
- GitHub Actions → Test workflow: includes · GitHub Actions workflows contain the main test pipeline
- GitHub Actions → CodeQL: includes · GitHub Actions workflows contain security scanning
- GitHub Actions → Release flow: includes · GitHub Actions workflows contain release publication
- Test workflow → Tests: runs · The test workflow executes the repository test suite
- CodeQL → Plugin package: scans · CodeQL targets the library code for security analysis
- Release flow → Packaging: publishes · Release automation uses package metadata to cut releases
