# Data model

> Built from commit 3effc4a043e0 on 2026-11-24. The current build: https://abdess.github.io/retrobios/version.json

Source: https://abdess.github.io/retrobios/wiki/data-model/

Three kinds of file hold everything this project knows. `database.json` lists every file the collection holds, keyed by its SHA1. A platform YAML copies the BIOS list a setup publishes. An emulator profile records what one emulator opens, read from its code. The sections below show the fields of each, with a real entry, to read the data or build on it.

Example: `scph5501.bin` is one entry of `database.json` (key `0555c6fa...`), one entry of `platforms/batocera.yml` (its MD5) and one entry of `emulators/duckstation.yml` (its MD5, region and priority).

## database.json

Primary key: SHA1. **22235** file entries.

The entry of `scph5501.bin`:

```
{
  "path": "bios/Sony/PlayStation/scph5501.bin",
  "name": "scph5501.bin",
  "size": 524288,
  "sha1": "0555c6fae8906f3f09baf5988f00e55f88e9f30b",
  "md5": "490f666e1afb15b7362b406ed1cea246",
  "sha256": "11052b6499e466bbf0a709b1f9cb6834a9418e66680387912451e971cf8a1fef",
  "crc32": "8d8cb7e4",
  "adler32": "24e21a0e",
  "provenance": {
    "redump": {
      "dat": "Sony - PlayStation - BIOS Images",
      "name": "ps-30a.bin",
      "description": "SCPH-5501/SCPH-5503/SCPH-7003 (Version 3.0 11/18/96 A)"
    },
    "tosec": {
      "dat": "Sony PlayStation - Firmware",
      "name": "Sony PlayStation SCPH-5501, SCPH-5503 & SCPH-7003 BIOS v3.0 (1996-11-18)(Sony)(AS-US).bin",
      "description": "Sony PlayStation SCPH-5501, SCPH-5503 & SCPH-7003 BIOS v3.0 (1996-11-18)(Sony)(AS-US)"
    }
  }
}
```

`provenance` maps each catalog that lists the file to the DAT and entry it was matched against. It is present only when the file matches a snapshot under `provenance/`. The join runs by SHA1 first, then by MD5 + size. See [dump provenance](https://abdess.github.io/retrobios/provenance/).

### Indexes

| Index | Entries | Purpose |
|---|---|---|
| `by_md5` | 22235 | MD5 to SHA1 lookup (Batocera, Recalbox verification) |
| `by_name` | 18745 | filename to SHA1 list (name-based resolution) |
| `by_crc32` | 22234 | CRC32 to SHA1 lookup |
| `by_path_suffix` | 104762 | relative path to SHA1 (regional variant disambiguation) |
| `by_sha256` | 22235 | SHA256 to SHA1 lookup (emulator profile validation) |

### File resolution order

`resolve_local_file` finds the file an entry describes by its hashes first, then by its path, then by its name, and a filename or destination never overrides a declared hash. The steps and their return codes are written once, in [the file resolution chain](https://abdess.github.io/retrobios/wiki/verification-modes/#file-resolution-chain).

## Platform YAML

Scraped from upstream sources. Structure:

```
platform: Batocera
verification_mode: md5        # how the platform checks files
hash_type: md5                # hash type in file entries
base_destination: bios        # root directory for BIOS files
systems:
  system-id:
    files:
      - name: filename
        destination: path/in/bios/dir
        md5: expected_hash
        sha1: expected_hash
        required: true
```

Supports inheritance (`inherits: retroarch`) and shared groups (`includes: [group_name]` referencing `_shared.yml`).

`base_destination` is the prefix the pack applies to every entry. It is empty when the upstream destinations already carry their own root, which is why the RetroDECK pack ships `bios/` and `roms/` at its top level. Core files then go under `core_destination` when the platform states one (`bios` for AmberELEC and EmuELEC, whose lists also name `neogeo/` and `ports/`), else under the root nearly every destination shares.

## Emulator YAML

**679** profile files, **653** distinct emulators once aliases are folded in. Source-verified from emulator code.

See the [profiling guide](https://abdess.github.io/retrobios/wiki/profiling/) for the full field reference.

## Static API and bulk exports

The website publishes versioned JSON, CSV and SQLite metadata generated from these same structures. Start with the [Data and API](https://abdess.github.io/retrobios/data/) catalog. Each downloadable artifact carries a SHA256 in `api/v1/catalog.json`.
