>

10/2024 ~ Present

NexTags・Self-Hosted Music Library Management System

Full-Stack Development
Database Design
Docker
AI Integration
Active

A self-hosted music library manager for importing tracks, editing audio tags, organizing files and playlists, and syncing favorites with Navidrome from a browser.

NexTags・Self-Hosted Music Library Management System

Project Overview

When I get a new track, I fill in the title, artists, and cover art before adding it to my music library. I built NexTags as a self-hosted tool for that workflow. I can upload files, edit tags, put tracks in the right folders, and manage playlists from the browser. I listen through Navidrome, so NexTags also asks it to rescan once the files are ready.

My Role

I built NexTags on my own, from the track list and tag editor to the import workflow. I decided what to store in the audio files, SQLite, and Redis, wired up Navidrome scan requests and favorites sync, and packaged the app for deployment with Docker Compose.

Features

Import a track into your library

In the add-song view, choose a music library and drop in the audio file. The import workflow guides you through checking the tags and previewing the filename and path before the move.

  1. Drop the audio file into the staging area. Large files upload in chunks, and a failed chunk is retried on its own.
  2. Convert M4A to FLAC with FFmpeg, carrying over supported tags and cover art.
  3. Read the existing tags with Mutagen so you can review them during import.
  4. Fill in the title, artist, or other missing details and adjust the final filename if needed.
  5. Check which artist folders still need to be created. For a track with multiple artists, you can set up each folder and upload a photo.
  6. Choose a destination folder, preview the final path, and move the file into the library. The path is sanitized for the filesystem and the tags keep their original text.
  7. Use FFmpeg to analyze loudness and write ReplayGain tags that compatible players can use.

If you close the page before adding cover art, find the unfinished import in the add-song view or on the cache page and choose Resume to pick up where you left off.

Find a track in your library

To find a track you added earlier, narrow the list by folder, filter by language or favorites, or search directly. The server loads one page of results at a time, and the list is sorted by date added. Replacing a track with a higher-quality file preserves its original date, so it stays in the same place.

The library supports MP3, FLAC, M4A, OGG, WAV, and other formats.

NexTags track list with search and folder filters

Add artists individually and reuse names from your library

Open a duet from the track list, add each singer as a separate chip, and drag the chips to change their order. Artist, Album Artist, Composer, and Performer all work the same way. The editor keeps an ordered list for each field, and Mutagen saves it as a multi-valued tag in the format the file uses.

I use the library index to collect names already used in those four fields. Search by name or pinyin and pick an existing entry to keep its spelling. The suggestions show a separate option to add a new name. Once selected, existing names appear in gray and new ones in green. If a familiar name shows up in green, you can catch a possible typo before saving.

The side panel also edits more than 20 fields, including title, album, cover art, genre, and language. It reuses sort names from the library when available and uses pypinyin to fill in missing ones. Tag edits are written directly to the source file, with ID3v2 for MP3, Vorbis Comments for FLAC and OGG, and MP4 tags for M4A.

NexTags side-panel tag editor with fields for multiple artists

Organize folders and filenames using audio tags

I group files by the first artist and then by album. I use “track number - title” for filenames so the songs are easy to find in album order when I open the folder. NexTags suggests a path from the audio tags. Navidrome reads those tags during a scan and uses them to display artists, albums, and tracks.

For a track already filed this way, NexTags updates only the affected part of its path. Changing track 2 to track 3 gives it a filename such as “03 - Song Title” and keeps the artist and album folders. Before saving, you can compare the old and new paths, adjust the filename, and decide whether to move the file.

When the old folder contains no audio files, NexTags moves remaining items such as cover art and artist photos, then removes empty folders. The track list marks queued moves as pending. You can cancel a move before it runs.

NexTags move confirmation dialog showing the proposed folder path and filename

Build a smart playlist from filters

To make a playlist of your favorite Japanese tracks, set the language to Japanese, enable the favorites filter, and add any tags to include or exclude. Sort by title or date added. The next time you generate the playlist, it picks up new tracks that match.

Export one playlist or a batch as M3U files for Navidrome or Jellyfin. You can also export and import the playlist rules as JSON to back them up or move them to another server.

NexTags smart playlist settings and export controls

Sync favorites with Navidrome or clean up lyrics with AI

Once you enable the Navidrome integration in Settings, importing tracks, changing cover art, generating M3U playlists, or moving files prompts a rescan. The first favorites sync shows the differences and asks how to merge them. After that, adding or removing a favorite on either side can sync the change to the other.

AI lyrics is a separate integration. With a Claude API key, you can clean up LRC timestamps, convert Simplified Chinese lyrics to Traditional Chinese, or add a Chinese translation below the original line at the same timestamp. This works when editing or importing a track. You can test a custom prompt on a short excerpt before saving it.

NexTags settings for the Navidrome and AI lyrics integrations

Key Decisions

Save import progress on the server so it can resume

After uploading a track, I might need to wait for conversion to finish or come back later to add cover art or verify the artists. If the page alone held the progress, closing the tab would discard those choices and I’d have to process the uploaded file from the beginning.

I keep the audio in a staging directory on the server and use Redis to track each file’s progress, staging path, and saved choices. When the page reopens, the backend uses the last saved state to decide where to resume. As long as the Redis record and staged audio still exist, the import can resume from the same file after a backend restart. Tags already written to the file are preserved.

Trade-off

The app needs to keep both the progress record and the staged file, and handle cases where the file goes missing. If only the staged file remains, NexTags can restart the workflow with that file. You’ll need to confirm any choices that haven’t been saved. Import recovery starts once the upload is complete. Failed chunks can be retried during the current upload attempt.

Let Navidrome scan the updated tags before moving the file

If the title and path change together, Navidrome may identify the file as a new track on its next scan. The tags still travel with the file, while play count, favorite status, and rating in Navidrome can stay attached to the previous track record.

I separated the tag update from the file move. NexTags writes the new tags at the original path, then waits for Navidrome to finish scanning. The backend checks that the scan succeeded and that its request was made after the move was queued. NexTags then moves the file, regenerates the M3U playlists, and requests a second scan. On that scan, only the path has changed, which helps Navidrome match the file to the existing track record.

Trade-off

The file stays at its original path after the tags are saved. If Navidrome hasn’t reported a successful scan, the move stays queued. You can check its status or cancel it from the track list. Installations that leave scan waiting disabled can move files directly.

Technical Architecture

Where requests go and where data lives

In production, Nginx serves the React app. During development, Vite provides hot reload. Both proxy /api requests to FastAPI, which reads and writes files in the music library mounted from the host.

Browser ──► frontend (:4000)
              ├─ prod: Nginx serves the built SPA and proxies /api ──► backend
              └─ dev:  Vite dev server proxies /api ─────────────────► backend
            backend (:6000 → 8000, FastAPI, all routes under /api)
              ├─ SQLite  /app/data/musicmanager.db   (app-data volume)
              ├─ Redis   tag cache, catalog, tasks   (redis-data volume)
              └─ /Music  host music library (read/write)
Deployment architecture from the NexTags repository README
  • Audio files live on the host and are mounted at /Music. NexTags edits metadata and cover art there, using Mutagen to read and write tags such as titles and artist names. The tags can be read again when rebuilding the cache.
  • SQLite stores smart playlist rules, system settings, and encrypted integration credentials. I use Python’s built-in sqlite3 module with write-ahead logging (WAL) and foreign keys enabled. The backend opens the database file from the persistent Docker app-data volume.
  • Redis caches the audio tags and library index and keeps track of imports, queued moves, and background jobs. Docker Compose enables AOF persistence and stores the data in redis-data. If a restart interrupts a batch M3U export, ReplayGain job, or cache rebuild, the job is marked as failed and can be run again manually.

Frontend and integrations

The interface uses React 19, shadcn/ui, and Tailwind CSS. dnd-kit handles reordering artist chips and lists in Settings, and Sonner displays feedback after actions. Dialogs and dropdowns use the browser’s native dialog and select elements.

The Navidrome and AI lyrics integrations can be enabled independently. Integration passwords and API keys are encrypted in SQLite. The server gets the master key from an environment variable. Credentials can be updated in Settings, and API responses and settings exports leave them out.

Tech Stack

FastAPI

Python async API framework handling backend logic and audio file operations

React 19

Frontend UI framework built with Vite

SQLite

Lightweight embedded database storing smart playlists and system settings

Redis

Caches audio tags and the library index and tracks import progress, pending file moves, and background jobs

Docker Compose

Containerized deployment with one-command full stack startup

Mutagen

Python library for reading and writing ID3v2, Vorbis Comment, and MP4 tags

Claude API

AI lyrics processing that normalizes the format, converts Simplified to Traditional Chinese, and adds bilingual translations

Navidrome

Self-hosted streaming server; NexTags asks it to rescan and keeps favorites in sync between the two

shadcn/ui

Component library based on Radix UI with Tailwind CSS

dnd-kit

Drag-and-drop reordering for artist chips and settings, with keyboard support