MrSloth Labs

PVD Library

A complete, production-ready library management system for Cambodian libraries.

Quick Start

Prerequisites

  • Node.js 20+
  • PostgreSQL 15+

Installation

git clone https://github.com/vandet91/pvd-library.git
cd pvd-library
npm install --legacy-peer-deps

Setup Database

sudo -u postgres psql <<'SQL'
CREATE USER library WITH PASSWORD 'your_password';
CREATE DATABASE library OWNER library;
GRANT ALL PRIVILEGES ON DATABASE library TO library;
SQL

Configure Environment

cp .env.example .env
# Edit .env with your DATABASE_URL, NEXTAUTH_SECRET, NEXTAUTH_URL

Initialize

npx prisma generate
npx prisma db push
npm run db:seed
npm run build
npm start

Default Admin Credentials

Change these immediately before production!

Features

Staff Features

  • Dashboard with stats and activity
  • Circulation (issue, return, renew books)
  • Book catalog management with barcode scanning
  • E-book upload and management
  • Member management
  • Reservations and holds
  • Fine calculation and tracking
  • 9 reporting modules
  • Inventory stock-take
  • Batch baskets for circulation
  • Serial/magazine tracking
  • Customizable circulation rules
  • Library calendar and hours
  • Barcode generation and printing
  • Taxonomy management (authors, categories, etc.)
  • Purchase order management
  • Staff task board
  • AI assistant for queries
  • Notifications (email/Telegram)
  • Database tools (backup, cleanup, health check)
  • System settings (themes, policy, language)

Member Portal

  • Browse public book catalog
  • View loans and renewal options
  • Access e-books
  • Submit book requests
  • View assigned basket
  • Track fines

Roles

  • Admin - Full system access
  • Librarian - Books, members, circulation, reports
  • Staff - Circulation only
  • Member - Member portal

Tech Stack

  • Next.js 16
  • TypeScript
  • PostgreSQL + Prisma 6
  • NextAuth v5
  • Tailwind CSS v4
  • next-intl (bilingual EN/KM)
  • Recharts
  • Barcode scanning (@zxing)

Deployment

PM2 (Linux Production)

Create ecosystem.config.js:

module.exports = {
  apps: [{
    name: "pvd-library",
    script: "node_modules/.bin/next",
    args: "start",
    cwd: "/home/library/pvd-library",
    instances: 1,
    autorestart: true,
    env: {
      NODE_ENV: "production",
      PORT: 3000,
    },
  }],
};
pm2 start ecosystem.config.js
pm2 save
pm2 startup

Nginx Proxy

server {
    listen 80;
    server_name yourdomain.com;
    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
    }
}

Updating

git pull origin new-feature2
npm install --legacy-peer-deps
npx prisma generate
npx prisma db push
npm run build
pm2 restart pvd-library

PVD Library Screenshots

alt text

alt text

alt text

alt text

alt text

alt text

alt text

alt text

alt text

alt text

alt text

Links