MyRecordCollection

MyRecordCollection / Technical description

MyRecordCollection

Architecture, data model, import, scanning, MusicBrainz and Discogs lookups, backup and HTTP interface in MyRecordCollection, the register for LP and CD records.

Version 1.0.0Revised 2026-11-18Flask · SQLite · Docker

1. Purpose

MyRecordCollection is a personal register of LP and CD records. Each record has metadata, purchase details and a cover image stored locally. Records can be entered by hand, imported from a pasted purchase list, scanned from PDFs or images, or fetched from MusicBrainz and Discogs.

The app is made for a single user on their own computer. It has no login and only listens on localhost:5050 through Docker.

2. Architecture

  Browser    ──HTTP:5050──▶ Docker-container «myrecordcollection»
                            gunicorn (1 process, 8 threads ) + Flask
                              │                 │
                              ▼                 ▼
                       data/records.db    data/covers/
                       SQLite             cover images (JPG/PNG/WebP)
                              │
          one background thread per scan/lookup
              ├─▶ zxing-cpp           barcodes, locally
              ├─▶ MusicBrainz         releases, year, label (≤ 1 request/s)
              ├─▶ Cover Art Archive   covers
              ├─▶ Discogs             optional token
              └─▶ Claude              optional API key: fronts and spines

Long jobs (scanning many pages, MusicBrainz lookups) run in a background thread. The page polls the status every second and shows the progress. That is why gunicorn runs one process with several threads: the jobs live in the process memory.

3. Data model

The database is a single SQLite file, data/records.db, with two tables: records and settings (key/value for owner, keys and contact address). New columns are added automatically when a new version starts, so older databases are upgraded without loss.

Column in recordsContent

artist, title

Required

format

LP or CD (CHECK constraint)

year, label, catalog_number, genre, barcode

From MusicBrainz/Discogs or typed in

condition, notes

Condition (M, NM, VG+ …) and free text. Release and link are put in the notes

purchase_place, purchase_date, price

The purchase. Records with the same place and date make up one purchase

cover_file

File name in data/covers/

created_at, updated_at

Timestamps

There is no unique key on artist and title. The same record can appear several times, and the detail page gathers the copies.

4. Importing purchase lists

The import parses free text line by line. It is forgiving about dashes, spaces and price formats.

Platemesse 10.05.2025 (1.127,-)
Robbie Robertson - Robbie Robertson (1987) 100,-
Electric Light Orchestra - Time (1981) 100,-

Platemesse 30.08.2025 (1.300,-)
Peter Gabriel – So (1986) 200,-
Peter Gabriel – So (1986) 200,-
  • A line with a date (dd.mm.yyyy) starts a purchase. Text before the date becomes the place, and an amount in brackets becomes the total.

  • A record is Artist - Title (year) price. The separator can be -, – or — with spaces around. Year and price are optional.

  • Prices such as 100,-, 1.127,-, kr 150 and 99,50 are understood.

  • Duplicates are kept. The sum of the records is compared with the total for the purchase, and differences are shown in the preview.

  • If the same list is imported again, records with the same artist, title, purchase date and price are recognised and left unticked.

5. Scanning

  1. PDF pages are rendered to images with pypdfium2. iPhone images (HEIC) are read with pillow-heif.

  2. zxing-cpp finds every barcode on the page, several per page too. Only EAN-13, EAN-8 and UPC-A codes with a valid check digit are used.

  3. Each barcode is looked up in MusicBrainz. If MusicBrainz does not answer or does not know the code, Discogs is tried (with a token).

  4. With an API key the page is also sent to Claude, which reads artist and title from fronts and spines. The hits are enriched from MusicBrainz.

  5. The preview shows the page image next to the hits. The same record found several times is marked as a duplicate and left unticked.

Temporary files live in data/scan_tmp/ and are cleaned up automatically.

6. MusicBrainz and Discogs

The form accepts a link, an MBID, a barcode or a search. The result fills in the form fields, but nothing is saved until you press Save.

6.1. MusicBrainz

  • At most one request per second, and a User-Agent with the contact address from Settings, as MusicBrainz requires.

  • 503 responses are retried with an increasing pause. The error text from MusicBrainz is shown, and Test MusicBrainz under Settings checks the connection.

  • The original year comes from the release group. The cover comes from the Cover Art Archive.

6.2. Discogs

  • Links to /release/ and /master/ work without a token. Extra parameters in the link are ignored.

  • Vinyl is registered as LP. The original year comes from the master.

  • Covers and search require a free personal token from discogs.com (Settings → Developers).

7. Backup, moving and upgrading

A backup is a zip file with the database and all the covers. It can be downloaded, saved in data/backups/ or uploaded for restore. Before a restore an automatic safety copy of the current collection is made.

myrecordcollection-backup-2026-11-18_101500.zip
├── manifest.json     app, format, time, number of records and covers
├── records.db        consistent copy (SQLite backup API)
└── covers/           all the cover images

scripts/pakk.sh --med-data makes a zip with the program and such a backup in migrering/backup.zip. If the app is running, the backup is fetched from it. If it is stopped, the database is copied with sqlite3 .backup. scripts/installer.sh restores it on the new computer and renames the file afterwards, so it is not offered again.

8. Language and theme

The pages are written in Norwegian. The English version is translated in the browser from a catalogue (static/i18n-en.js) with fixed texts and patterns where numbers are replaced by {n}. Elements that appear later on the page are translated too. The choice is stored in a cookie, so server messages also come in the right language.

Light and dark mode use CSS variables. The first visit follows the operating system setting.

9. HTTP interface

RouteWhat it does

GET /

The collection. Parameters: view (board, grid, list), q, format, genre, kjopt, sort

GET/POST /plate/ny

New record

GET /plate/<id>

Detail page, with every copy

GET/POST /plate/<id>/rediger, POST …/slett

Edit and delete

GET/POST /import

Paste list → preview → import (step = preview / confirm)

POST /skann, GET /skann/<jobb>/status

Starts a background scan and reports progress as JSON

GET /api/musicbrainz/hent?ref=

Looks up a link, MBID or barcode (MusicBrainz or Discogs)

GET /api/musicbrainz/sok, …/test

Search by artist and title, and a connection test

GET/POST /innstillinger

Owner, keys and contact address

GET /oversikt, GET /eksport.csv

Printable overview and CSV export

GET /backup/last-ned, POST /backup/lagre, POST /backup/gjenopprett

Backup and restore

GET /omslag/<fil>

The cover images

10. Source code

FileContent

app.py

The Flask app: routes, database, settings, backup and MusicBrainz lookups

importer.py

Parses pasted lists

scanner.py

Scanning: PDF pages, barcodes, Claude and lookups

discogs.py

Discogs API: release, master, search and covers

templates/, static/

The pages, the stylesheet and the language files (i18n.js, i18n-en.js)

scripts/installer.sh, scripts/pakk.sh

Installation and packaging

Dockerfile, docker-compose.yml

python:3.12-slim, port 5050 → 5000, ./data → /data

Dependencies: Flask 3, gunicorn, Pillow, pypdfium2, zxing-cpp and pillow-heif.

Screenshots, installation and how it works: Back to the front page