Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ jobs:
fi
DATABASE_URL="${db_url}" pnpm --dir "${DEPLOY_ROOT}" --filter @t19/server db:migrate
# #63 ships the reproducible real-album snapshot. Import it on deploy
# so the application catalog is present on the VM as well as locally.
# The importer is idempotent and preserves album IDs and user data.
echo
echo "Importing the MusicBrainz catalog snapshot"
DATABASE_URL="${db_url}" pnpm --dir "${DEPLOY_ROOT}" --filter @t19/server db:import:musicbrainz
sudo /usr/bin/systemctl restart crate-api
printf 'Waiting for the API'
Expand Down
63 changes: 49 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Apply the database migrations and start the backend:

```bash
pnpm --filter @t19/server db:migrate
pnpm --filter @t19/server db:seed # optional: reset to sample albums
pnpm --filter @t19/server db:import:musicbrainz # import the committed real-album catalog
pnpm --filter @t19/server dev
```

Expand All @@ -56,7 +56,7 @@ Open http://localhost:5173/project2/. The backend runs at http://localhost:3001/

The default frontend GraphQL endpoint is `/graphql`. To use a different endpoint, set `VITE_GRAPHQL_URL` in `client/.env.local` and restart Vite.

**Note:** `db:seed` replaces the catalog and deletes associated tracks, reviews and crate items. Do not use it on a database containing data you want to keep. See [VM setup](docs/VM-setup.md) for deployment instructions.
**Note:** `db:import:musicbrainz` adds or updates the real catalog without deleting albums, reviews or crate items. `db:seed` and `db:seed:large` are reset commands: they replace the catalog and delete associated tracks, reviews and crate items. Do not use either seed command on a database containing data you want to keep. See [VM setup](docs/VM-setup.md) for deployment instructions.

### Checks and useful commands

Expand All @@ -68,18 +68,20 @@ pnpm format:check && pnpm lint && pnpm typecheck && pnpm test

CI also builds the project and checks the client bundle size.

| Command | Purpose |
| -------------------------------------- | ---------------------------------- |
| `pnpm dev` | Start the frontend |
| `pnpm build` | Build the project |
| `pnpm lint` | Run ESLint |
| `pnpm format` / `pnpm format:check` | Format or check formatting |
| `pnpm typecheck` | Run TypeScript checks |
| `pnpm test` | Run unit tests |
| `pnpm --filter @t19/server dev` | Start the GraphQL API |
| `pnpm --filter @t19/server db:migrate` | Apply database migrations |
| `pnpm --filter @t19/server db:seed` | Reset to the sample catalog |
| `pnpm db:seed:large` | Reset to a large synthetic catalog |
| Command | Purpose |
| -------------------------------------- | --------------------------------------------------------- |
| `pnpm dev` | Start the frontend |
| `pnpm build` | Build the project |
| `pnpm lint` | Run ESLint |
| `pnpm format` / `pnpm format:check` | Format or check formatting |
| `pnpm typecheck` | Run TypeScript checks |
| `pnpm test` | Run unit tests |
| `pnpm --filter @t19/server dev` | Start the GraphQL API |
| `pnpm --filter @t19/server db:migrate` | Apply database migrations |
| `pnpm --filter @t19/server db:seed` | Reset to the sample catalog |
| `pnpm db:import:musicbrainz` | Add or update the committed real-album catalog |
| `pnpm db:fetch:musicbrainz` | Rebuild the local MusicBrainz snapshot (network required) |
| `pnpm db:seed:large` | Reset to a large synthetic catalog |

Unit tests cover frontend components and backend logic, but do not test a running PostgreSQL database. The [VM setup guide](docs/VM-setup.md) includes API smoke tests.

Expand All @@ -99,6 +101,39 @@ $env:ALBUM_COUNT=100000; pnpm db:seed:large

**Both commands reset the catalog and remove associated tracks, reviews and crate items.** If a large seed is interrupted, rerun it to reset and regenerate the catalog.

### Real album catalog (#63)

The committed snapshot at `server/data/musicbrainz-albums.json` contains 500
MusicBrainz release groups, selected across nine normalized genres and release
decades from the 1960s through the 2020s. A release group represents an album
across its editions, so the snapshot does not add every reissue as a separate
album. The import runs locally from this file; the app does not call MusicBrainz
at runtime. Reimporting is safe and keeps existing album IDs and user-generated
reviews and crate items. Matching hand-seeded albums are reused by title and
primary artist.

To import it after applying migrations:

```bash
pnpm db:import:musicbrainz
```

To refresh the snapshot from the MusicBrainz API:

```bash
pnpm db:fetch:musicbrainz
pnpm db:import:musicbrainz
```

The fetch script identifies itself with a User-Agent and spaces requests to
respect MusicBrainz's rate limit. Review the generated snapshot before
committing it. MusicBrainz core data is CC0 1.0; genre associations are
user-contributed tag data under CC BY-NC-SA 3.0. The snapshot retains that
distinction and the MusicBrainz release-group IDs for attribution and
reproducibility. See [MusicBrainz Data License](https://musicbrainz.org/doc/About/Data_License)
and [MusicBrainz API](https://musicbrainz.org/doc/MusicBrainz_API). Album covers
remain out of scope for this issue.

### Scalability check

Use a separate test database, not the shared catalog. Apply migrations, run the large seed and start the API. The SQL checks and GraphQL request are committed in the repository.
Expand Down
1 change: 1 addition & 0 deletions docs/AI-USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ the part that matters most.
| 2026-10-24 | rachelks | Codex (ChatGPT) | Assisted with implementing and testing cursor pagination, infinite scroll, Load more, Apollo cache handling, and accessibility improvements (#14). |
| 2026-10-25 | rachelks | ChatGPT | Assisted with researching real album datasets, evaluating which data source best fit the project, and planning issues #63 and #64 to implement real data. |
| 2026-10-26 | robertky | Codex (ChatGPT) | Assisted me when I implemented #16: idempotent add/remove mutations, per-request crate-state loading, and accessible list/detail toggles. I reviewed the implementation and test results before using it. |
| 2026-10-27 | robertky | Codex (ChatGPT) | Assisted me with #63's MusicBrainz snapshot fetcher, non-destructive catalog import and documentation. |

## Notes

Expand Down
4 changes: 3 additions & 1 deletion docs/VM-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ runs on port 3001 and needs the repository's `schema.graphql` file at startup.
Pushes to `main` trigger `.github/workflows/ci.yml`. After formatting, linting,
type-checking, tests and builds pass, CI deploys the frontend to
`/var/www/html/project2`, updates the API in `~/T19-Project-2`, applies pending
migrations and restarts `crate-api.service`. Deployment does not seed the database.
migrations, imports the committed MusicBrainz catalog snapshot and restarts
`crate-api.service`. The import is repeatable and does not reset the database or
delete user data. Deployment does not run either destructive seed command.

Apache serves the frontend at `/project2/` and forwards `/graphql` requests to
the API on port 3001:
Expand Down
21 changes: 17 additions & 4 deletions docs/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ This document describes the model behind `schema.graphql`. The M2 database migra

## Core catalog

- An **album** has a title, an optional release year, one or more artists, zero
or more genres and an ordered list of tracks.
- An **album** has a title, an optional release year, an optional MusicBrainz
release-group ID, one or more artists, zero or more genres and an ordered
list of tracks.
- An **artist** can belong to many albums, and an **album** can have many
artists.
- A **genre** can belong to many albums, and an **album** can have many genres.
Expand All @@ -14,8 +15,20 @@ This document describes the model behind `schema.graphql`. The M2 database migra

The two many-to-many relationships use `album_artist` and `album_genre`, with
composite primary keys. Tracks have a unique `(album_id, track_number)`.
Foreign keys cascade on deletion. The seeds populate only the album, artist,
genre and join tables.
Foreign keys cascade on deletion. The sample and synthetic reset seeds populate
catalog data. The separate MusicBrainz importer adds real catalog records from
the committed snapshot without deleting albums, tracks, reviews or crate items.
It matches an existing hand-seeded album by title and primary artist before
assigning its MusicBrainz ID, preserving its database ID and user data. The
unique MusicBrainz release-group ID makes repeat imports idempotent.

The local snapshot keeps one record per release group, not per pressing or
reissue. It stores normalized genre names and any available track data. The
MusicBrainz fetch script is only used when preparing a new snapshot; the
application does not call the MusicBrainz API at runtime. Core metadata is
licensed CC0 1.0; user-contributed genre associations are CC BY-NC-SA 3.0. See
the [README](../README.md#real-album-catalog-63) for source, import and license
details.

`album.search_vector` has a GIN index. SQL triggers refresh weighted title and
artist terms when titles, artist names or artist links change. Migration
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"test:watch": "pnpm --filter @t19/client test:watch",
"db:migrate": "pnpm --filter @t19/server db:migrate",
"db:seed": "pnpm --filter @t19/server db:seed",
"db:seed:large": "pnpm --filter @t19/server db:seed:large"
"db:seed:large": "pnpm --filter @t19/server db:seed:large",
"db:import:musicbrainz": "pnpm --filter @t19/server db:import:musicbrainz",
"db:fetch:musicbrainz": "pnpm --filter @t19/server db:fetch:musicbrainz"
},
"devDependencies": {
"@eslint/js": "^9.39.5",
Expand Down
Loading