# bsb-publishing/bsb2usfm architecture

> Architecture diagram of the GitHub repository bsb-publishing/bsb2usfm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bsb-publishing/bsb2usfm
- Repository: https://github.com/bsb-publishing/bsb2usfm

## Overview

This repository produces BSB and MSB Bible text datasets in USFM, USJ, and USX, with standard, interlinear, and Strong’s variants. The principal workflow converts source text into structured book files, cleans the shared USX representation, and packages outputs for download. Separate utilities adapt files for Paratext and DBL, while a Flask interface offers a conversion workflow. The README documents the format and release capabilities; some build wiring and conversion internals are unsampled, so those relationships are omitted where not evidenced.

Main entry points: [`bsb2usfm.py`](https://github.com/bsb-publishing/bsb2usfm/blob/main/bsb2usfm.py) (Book converter), [`create_zips.py`](https://github.com/bsb-publishing/bsb2usfm/blob/main/create_zips.py) (ZIP archive creation), [`web_service/webapp.py`](https://github.com/bsb-publishing/bsb2usfm/blob/main/web_service/webapp.py) (Conversion web interface), [`mirror_bsb_ot_to_msb.py`](https://github.com/bsb-publishing/bsb2usfm/blob/main/mirror_bsb_ot_to_msb.py) (Mirror BSB Old Testament)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversion["Conversion"]
  node_converter["Book converter<br/>[bsb2usfm.py]"]
  node_cleanup["USX tree cleanup<br/>[usx_cleanup.py]"]
end

subgraph group_editions["Edition handling"]
  node_edition["BSB and MSB editions"]
  node_ot_mirror["Mirror BSB Old Testament"]
  node_msb_fixes["MSB corrections and versification<br/>[fix_msb.py]"]
end

subgraph group_adaptation["Format adaptation"]
  node_paratext["Paratext USFM adaptation"]
  node_dbl["DBL USX adaptation"]
  node_irefs["Footnote reference extraction<br/>[getirefs.py]"]
end

subgraph group_delivery["Delivery"]
  node_zipper["ZIP archive creation<br/>[create_zips.py]"]
  node_webapp["Conversion web interface<br/>[webapp.py]"]
end

node_source(("Bible source text"))
node_web_user(("Web user"))
node_download_user(("Dataset user"))

node_source -->|"converts text"| node_converter
node_converter -->|"calls cleanup"| node_cleanup
node_converter -->|"generates editions"| node_edition
node_edition -.->|"adapts USFM"| node_paratext
node_edition -.->|"adapts USX"| node_dbl
node_edition -.->|"extracts references"| node_irefs
node_ot_mirror -->|"copies OT files"| node_edition
node_msb_fixes -->|"corrects MSB files"| node_edition
node_edition -.->|"packages outputs"| node_zipper
node_web_user -->|"requests conversion"| node_webapp
node_webapp -->|"launches conversion"| node_converter
node_zipper -.->|"provides archives"| node_download_user

click node_converter "https://github.com/bsb-publishing/bsb2usfm/blob/main/bsb2usfm.py"
click node_cleanup "https://github.com/bsb-publishing/bsb2usfm/blob/main/usx_cleanup.py"
click node_ot_mirror "https://github.com/bsb-publishing/bsb2usfm/blob/main/mirror_bsb_ot_to_msb.py"
click node_msb_fixes "https://github.com/bsb-publishing/bsb2usfm/blob/main/fix_msb.py"
click node_paratext "https://github.com/bsb-publishing/bsb2usfm/blob/main/adapt_usfm_for_paratext.py"
click node_dbl "https://github.com/bsb-publishing/bsb2usfm/blob/main/adapt_usx_for_DBL.py"
click node_irefs "https://github.com/bsb-publishing/bsb2usfm/blob/main/getirefs.py"
click node_zipper "https://github.com/bsb-publishing/bsb2usfm/blob/main/create_zips.py"
click node_webapp "https://github.com/bsb-publishing/bsb2usfm/blob/main/web_service/webapp.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_converter,node_cleanup,node_web_user,node_download_user toneBlue
class node_edition,node_ot_mirror,node_msb_fixes toneAmber
class node_paratext,node_dbl,node_irefs toneMint
class node_zipper,node_webapp toneRose
class node_source toneIndigo
```

## Components

### Conversion

- [Book converter](https://github.com/bsb-publishing/bsb2usfm/blob/main/bsb2usfm.py): `bsb2usfm.py`
- [USX tree cleanup](https://github.com/bsb-publishing/bsb2usfm/blob/main/usx_cleanup.py): `usx_cleanup.py`

### Edition handling

- **BSB and MSB editions**
- [Mirror BSB Old Testament](https://github.com/bsb-publishing/bsb2usfm/blob/main/mirror_bsb_ot_to_msb.py): `mirror_bsb_ot_to_msb.py`
- [MSB corrections and versification](https://github.com/bsb-publishing/bsb2usfm/blob/main/fix_msb.py): `fix_msb.py`

### Format adaptation

- [Paratext USFM adaptation](https://github.com/bsb-publishing/bsb2usfm/blob/main/adapt_usfm_for_paratext.py): `adapt_usfm_for_paratext.py`
- [DBL USX adaptation](https://github.com/bsb-publishing/bsb2usfm/blob/main/adapt_usx_for_DBL.py): `adapt_usx_for_DBL.py`
- [Footnote reference extraction](https://github.com/bsb-publishing/bsb2usfm/blob/main/getirefs.py): `getirefs.py`

### Delivery

- [ZIP archive creation](https://github.com/bsb-publishing/bsb2usfm/blob/main/create_zips.py): `create_zips.py`
- [Conversion web interface](https://github.com/bsb-publishing/bsb2usfm/blob/main/web_service/webapp.py): `web_service/webapp.py`

### Other components

- **Bible source text**
- **Web user**
- **Dataset user**

## Connections

- Bible source text → Book converter: converts text (evidence: `README.md`)
- Book converter → USX tree cleanup: calls cleanup (evidence: `bsb2usfm.py`)
- Book converter → BSB and MSB editions: generates editions (evidence: `README.md`)
- BSB and MSB editions → Paratext USFM adaptation: adapts USFM
- BSB and MSB editions → DBL USX adaptation: adapts USX
- BSB and MSB editions → Footnote reference extraction: extracts references
- Mirror BSB Old Testament → BSB and MSB editions: copies OT files (evidence: `mirror_bsb_ot_to_msb.py`)
- MSB corrections and versification → BSB and MSB editions: corrects MSB files (evidence: `fix_msb.py`)
- BSB and MSB editions → ZIP archive creation: packages outputs (evidence: `README.md`)
- Web user → Conversion web interface: requests conversion (evidence: `web_service/webapp.py`)
- Conversion web interface → Book converter: launches conversion (evidence: `web_service/webapp.py`)
- ZIP archive creation → Dataset user: provides archives (evidence: `README.md`)
