Skip to content

Development

  • Docker and Docker Compose v2+
  • Node.js 22+
  • pnpm (or enable via corepack enable)

Librariarr uses Docker Compose for development to provide a PostgreSQL database and hot-reloading.

  1. Clone the repository

    Terminal window
    git clone https://github.com/ahembree/librariarr.git
    cd librariarr
  2. Create a .env file

    Copy the example and fill in the required values:

    Terminal window
    cp .env.example .env
  3. Start the dev environment

    Terminal window
    pnpm docker:dev

    This builds the dev container, starts PostgreSQL, runs migrations, and starts the Next.js dev server with Turbopack hot-reloading.

  4. Open the app

    Navigate to http://localhost:3000

CommandDescription
pnpm docker:devStart dev environment (foreground)
pnpm docker:dev:detachStart dev environment (background)
pnpm docker:dev:downStop dev environment
pnpm docker:dev:rebuildRebuild containers from scratch
pnpm docker:dev:cleanStop containers and delete DB volume
pnpm docker:dev:logsTail dev container logs
CommandDescription
pnpm docker:dev:db:pushPush schema changes (fast iteration, no migration files)
pnpm docker:dev:db:migrateRun Prisma migrations
pnpm docker:dev:db:studioOpen Prisma Studio (DB browser)
pnpm docker:dev:db:resetReset DB completely

Populate the database with fictional media data for testing or taking screenshots without exposing personal data.

CommandDescription
pnpm docker:dev:seedSeed the dev database with mock data
CommandDescription
pnpm buildNext.js production build
pnpm lintESLint
pnpm exec prisma generateRegenerate Prisma client (needed after schema changes when DB isn’t available)

Tests use Vitest with a real PostgreSQL test database (librariarr_test), auto-created by the global setup.

CommandDescription
pnpm testRun full test suite
pnpm test:watchWatch mode
pnpm test:unitUnit tests only (no DB needed)
pnpm test:integrationIntegration tests only (requires DB)
pnpm test:coverageRun with coverage report
pnpm exec vitest run tests/path/to/file.test.tsRun a single test file
  • tests/unit/ — Pure logic tests (rules engine, filters, sync detection, formatting, caching, validation schemas)
  • tests/integration/ — API route handler tests against a real database with mocked external services
TechnologyVersionPurpose
Next.js16App Router framework
React19UI library
TypeScript5Type safety
PostgreSQL18Database
Prisma7ORM
Tailwind CSSv4Styling (OKLCH color model)
shadcn/uiComponent library (new-york style)
Vitest4Testing framework
  • Pre-commit hook: Runs pnpm exec eslint --quiet via Husky
  • Commit format: Conventional Commits enforced by commitlint
    • feat: add new feature
    • fix(auth): handle expired tokens
    • docs: update installation guide
    • refactor: simplify rule evaluation
src/
├── app/ # Next.js App Router
│ ├── (authenticated)/ # Protected pages (auth enforced by layout)
│ ├── api/ # API routes
│ ├── login/ # Login page
│ └── onboarding/ # First-time setup
├── components/
│ └── ui/ # shadcn/ui primitives
├── hooks/ # Custom React hooks
└── lib/
├── auth/ # Session management
├── arr/ # Sonarr/Radarr/Lidarr clients
├── backup/ # Backup & restore service
├── cache/ # In-memory cache
├── dedup/ # Multi-server deduplication
├── filters/ # Media filter utilities
├── plex/ # Plex OAuth and API client
├── rules/ # Lifecycle rule engine
├── scheduler/ # Cron scheduler
├── sync/ # Media sync engine
└── validation.ts # Zod schemas for API validation