Skip to content

Development Guide ​

This guide covers how to set up a local development environment for TuneCamp and start contributing to the project.

Prerequisites ​

  • Node.js: v18 or higher
  • FFmpeg: Required for audio processing and waveform generation
  • SQLite3: Optional β€” useful for manual database inspection

Initial Setup ​

  1. Clone the repository:

    bash
    git clone https://github.com/scobru/tunecamp.git
    cd tunecamp
  2. Install dependencies:

    bash
    # Root + backend
    npm install
    
    # Frontend
    cd webapp && npm install && cd ..
  3. Configure environment variables: Copy .env.example to .env and fill in the required values (port, JWT secret, music directory path). See the Configuration section in the README for the full variable reference.

Running in Development ​

You need two terminals running in parallel.

Terminal 1 β€” backend (TypeScript watch + CSS rebuild):

bash
npm run dev

Terminal 2 β€” backend server:

bash
npm start

npm run dev only runs tsc --watch and the CSS watcher β€” it does not start the server. You need npm start (or node dist/index.js) to serve requests.

The server is available at http://localhost:1970 by default (configurable via TUNECAMP_PORT).

Terminal 3 β€” frontend (Vite dev server with HMR):

bash
cd webapp && npm run dev

The frontend dev server runs at http://localhost:5173 and proxies API requests to the backend.

Running Tests ​

The project uses Jest for the existing test suite. New modules should use Vitest.

bash
# Run all tests
npm test

# Run a specific test file
npm test src/server/auth.test.ts

Verify no TypeScript errors before opening a PR:

bash
npm run build
cd webapp && npm run build

CLI Tools (src/tools/) ​

Several maintenance scripts are available under src/tools/:

ScriptCommandPurpose
backup.tsnode dist/tools/backup.js ./backupsCreates a timestamped database backup
restore.tsnode dist/tools/restore.js ./backups/tunecamp-<date>.db --forceRestores from a backup
generate-codes.tsβ€”Generates unlock codes for releases
relink-tracks.tsβ€”Updates audio file paths after moving the library
migrate-dedupe.jsnpm run migrate:dedupeRemoves duplicate tracks from the database
migrate-visibility.jsnpm run migrate:visibilityBulk-updates visibility for albums and tracks

See backup-migration.md for more detail on data maintenance.

Code Conventions ​

  • Use TypeScript for all new backend code.
  • Follow the existing functional component style in React.
  • Document new API endpoints in api-contracts.md.
  • Every new database table must be added to src/server/core/database.ts with appropriate indexes.

Contributing ​

See CONTRIBUTING.md for the full contribution process.

Released under the MIT License.