Skip to content

ChanMeng666/library-os

Repository files navigation

Project Banner

📚 LibraryOS

The Operating System for Modern Libraries

LibraryOS is a comprehensive multi-tenant library management system that enables organizations to manage their book collections, track loans, handle reservations, and manage team members with role-based access control.
Built with Next.js 16, React 19, TypeScript, Supabase, TailwindCSS 4, and Stripe for subscription billing.
One-click FREE deployment for your digital library transformation.

Live Demo · Documentation · Report Bug · Request Feature


🚀 Visit Live Site 🚀


Image Image Image Image Image Image

Share Repository

Image Image Image

🌟 LibraryOS: The operating system for modern libraries. Built for organizations, librarians, and book enthusiasts.

Image

📸 Project Screenshots

[!TIP] Experience the modern, intuitive interface designed for both librarians and library users.

Main Dashboard

User Dashboard - Complete overview of borrowed books and library statistics

Book Catalog Book Details

Book Catalog and Detailed Book Information

📱 More Screenshots
Authentication

Secure Authentication System

Search and Filter

Advanced Search and Filtering

Tech Stack Showcase:

Image Image Image Image Image Image Image

Important

This is a multi-tenant SaaS platform where organizations can create isolated library environments. Features include Stripe subscription billing (Free/Basic/Pro/Enterprise plans), role-based access control (Owner/Admin/Librarian/Member), team invitations, and comprehensive book management.

📑 Table of Contents

TOC


🌟 Introduction

This comprehensive library management system is designed for organizations that need to manage their book collections with team collaboration. Each organization operates in an isolated environment with its own books, members, and settings.

Key Differentiators:

  • Multi-tenancy: Each organization has isolated data and settings
  • Subscription Plans: Tiered pricing with different quotas and features
  • Team Management: Invite members with different roles and permissions
  • Modern Stack: Built with the latest versions of Next.js, React, and TailwindCSS

Note

  • Node.js >= 18.0 required
  • Supabase account required for database and authentication
  • Stripe account required for subscription billing
  • Modern web browser with JavaScript enabled
Image Experience the system firsthand with our live demo - no installation required!
Image Join our community of developers and library professionals.

Tip

⭐ Star us to receive notifications about new features and updates!

Image

⭐ Star History Image

✨ Key Features

1 Multi-tenant Organizations

Create and manage multiple library organizations, each with isolated data and customizable settings.

Organization Features:

  • 🏢 Create Organizations: Set up new library environments with custom branding
  • 👥 Team Management: Invite members via email with role assignment
  • 🔄 Organization Switching: Users can belong to multiple organizations
  • ⚙️ Custom Settings: Configure loan duration, max loans per user, and more
  • 📊 Organization Stats: Track books, members, loans, and usage
graph LR
    A[User] --> B[Organization 1]
    A --> C[Organization 2]
    B --> D[Books]
    B --> E[Members]
    B --> F[Loans]
    C --> G[Books]
    C --> H[Members]
    C --> I[Loans]
Loading

Image

2 Smart Book Management

Experience next-generation library catalog management with intelligent search, real-time availability tracking, and automated inventory management.

Book Catalog

Advanced Book Catalog with Search and Filtering

Key Capabilities:

  • 🔍 Smart Search: Advanced search by title, author, ISBN, and categories
  • 📚 Real-time Inventory: Live tracking of book availability and stock levels
  • 🏷️ Category Management: Organized book classification system (global + org-specific)
  • 📱 Responsive Design: Seamless experience across all devices
  • 🖼️ Cover Management: Support for book cover images and placeholders
  • Reviews & Ratings: Members can rate and review books

Image

3 Subscription & Billing

Integrated Stripe subscription system with tiered plans and automatic billing.

Plan Max Books Max Users Max Loans/User Price Features
Free 100 5 3 $0 Reservations, Reviews
Basic 1,000 20 5 $29/mo + Reports
Pro 10,000 100 10 $99/mo + Custom Branding
Enterprise Unlimited Unlimited Unlimited Custom + API, SSO, Priority Support

Billing Features:

  • 💳 Stripe Checkout: Secure payment processing with 14-day trial
  • 📊 Billing Portal: Self-service subscription management
  • 🔄 Auto-renewal: Monthly or yearly billing cycles
  • 📧 Payment Notifications: Email alerts for successful/failed payments
  • 📜 Billing History: Complete audit trail of all transactions

Image

4 Role-based Access Control

Granular permission system with four distinct roles.

Permission Owner Admin Librarian Member
Browse books
Borrow/return books
Write reviews
Add/edit books
Delete books
Manage members
Access billing
Delete organization

Image

* Additional Features

Beyond the core functionality, this system includes:

  • 🔐 Secure Authentication: Email-based authentication with Supabase Auth
  • 📧 Email Invitations: Send team invitations via Resend
  • 📊 Analytics Dashboard: Comprehensive statistics and reporting
  • 🔄 Real-time Updates: Live synchronization across all connected devices
  • 📱 Mobile Responsive: Perfect experience on smartphones and tablets
  • 🌙 Dark Mode: Eye-friendly dark theme with brand colors
  • 🔔 Smart Notifications: Toast notifications for all user actions
  • 📈 Progress Tracking: Visual progress indicators for all operations
  • 🛡️ Row Level Security: Secure data isolation at database level
  • 💚 Brand Design: Custom gradient theme with #02FF73 and #09ADAA

✨ More features are continuously being added based on user feedback and library needs.

Image

🛠️ Tech Stack

Next.js
Next.js 16
React
React 19
TypeScript
TypeScript 5
Supabase
Supabase
Stripe
Stripe
TailwindCSS
TailwindCSS 4
Layer Technologies
Frontend Next.js 16 (App Router), React 19, TypeScript, TailwindCSS 4, shadcn/ui (Radix UI)
Backend Supabase (PostgreSQL, Auth, RLS policies, Stored Procedures)
Payment Stripe (Subscriptions, Checkout, Billing Portal, Webhooks)
Email Resend (Transactional emails for invitations)
State React Context (AuthContext, OrganizationContext)
Forms React Hook Form + Zod validation

Tip

Each technology was selected for production readiness, developer experience, and seamless integration with the overall architecture.

🏗️ Architecture

System Architecture

graph TB
    subgraph "Frontend Layer"
        A[Next.js 16 App] --> B[React 19 Components]
        B --> C[AuthContext]
        B --> D[OrganizationContext]
        C --> E[Supabase Client]
        D --> E
    end

    subgraph "API Layer"
        F["/api/auth/register"]
        G["/api/stripe/checkout"]
        H["/api/stripe/portal"]
        I["/api/stripe/webhook"]
        J["/api/email/invite"]
    end

    subgraph "Backend Layer"
        K[Supabase API] --> L[PostgreSQL]
        L --> M[RLS Policies]
        L --> N[Stored Procedures]
    end

    subgraph "External Services"
        O[Stripe]
        P[Resend Email]
    end

    E --> K
    A --> F
    A --> G
    A --> H
    G --> O
    H --> O
    I --> O
    J --> P
Loading

Database Schema

erDiagram
    organizations ||--o{ organization_members : has
    organizations ||--o{ books : owns
    organizations ||--o{ loans : tracks
    organizations }o--|| subscription_plans : subscribes

    users ||--o{ organization_members : belongs
    users ||--o{ loans : borrows
    users ||--o{ reviews : writes

    books ||--o{ loans : borrowed
    books ||--o{ reviews : reviewed
    books }o--|| categories : categorized

    organizations {
        uuid organization_id PK
        varchar name
        varchar slug UK
        varchar subscription_plan FK
        varchar subscription_status
        varchar stripe_customer_id
        integer max_books
        integer max_users
    }

    organization_members {
        uuid membership_id PK
        uuid organization_id FK
        uuid user_id FK
        varchar role
        varchar status
    }

    books {
        uuid book_id PK
        varchar title
        varchar author
        varchar isbn
        integer available_copies
        uuid organization_id FK
    }

    loans {
        uuid loan_id PK
        uuid user_id FK
        uuid book_id FK
        date due_date
        varchar status
    }
Loading

Core Workflows

🔐 Authentication Flow
sequenceDiagram
    participant U as User
    participant F as Frontend
    participant API as /api/auth/register
    participant SA as Supabase Auth
    participant DB as Database

    U->>F: Submit registration form
    F->>API: POST {email, password, username, fullName}
    API->>SA: createUser (auto-confirm email)
    SA-->>API: Auth user created
    API->>DB: INSERT into users table
    DB-->>API: User profile created
    API-->>F: {success: true, user}
    F->>SA: signInWithPassword
    SA-->>F: Session established
    F->>U: Redirect to /dashboard
Loading
📚 Book Borrowing Flow
sequenceDiagram
    participant U as User
    participant F as Frontend
    participant RPC as Supabase RPC
    participant DB as Database

    U->>F: Click "Borrow" on book
    F->>RPC: borrow_book(org_id, book_id, user_id, due_date)
    RPC->>RPC: Check membership status
    RPC->>RPC: Check subscription active
    RPC->>RPC: Check user loan quota
    RPC->>RPC: Check book availability
    alt All checks pass
        RPC->>DB: INSERT loan record
        RPC->>DB: DECREMENT available_copies
        RPC-->>F: {success: true, loan_id}
        F->>U: Show success message
    else Quota exceeded
        RPC-->>F: {success: false, error}
        F->>U: Show error message
    end
Loading
💳 Subscription Payment Flow
sequenceDiagram
    participant A as Admin
    participant F as Frontend
    participant API as /api/stripe/checkout
    participant S as Stripe
    participant WH as /api/stripe/webhook
    participant DB as Database

    A->>F: Select plan on /org/billing
    F->>API: POST {organizationId, planId, billingPeriod}
    API->>S: Create checkout session (14-day trial)
    S-->>API: {sessionId, url}
    F->>S: Redirect to Stripe Checkout
    A->>S: Complete payment
    S->>WH: checkout.session.completed webhook
    WH->>DB: UPDATE organization subscription
    WH->>DB: INSERT subscription_history
    S-->>F: Redirect to /org/billing?success=true
Loading

⚡️ Performance

Note

Performance optimizations ensure fast loading times and smooth user experience across all devices.

Key Performance Indicators:

  • Lightning Fast: < 2s initial page load
  • 🚀 Instant Navigation: Client-side routing with prefetching
  • 📱 Mobile Optimized: Perfect scores on mobile devices
  • 🔄 Real-time Updates: < 100ms database synchronization
  • 📊 Efficient Rendering: Optimized React 19 components

Optimization Techniques:

  • 🎯 Image Optimization: Next.js Image component with lazy loading
  • 📦 Code Splitting: Automatic route-based code splitting
  • 🗄️ Database Optimization: Efficient PostgreSQL queries with indexes
  • 🔄 Caching Strategy: Static generation where possible

🚀 Getting Started

Prerequisites

Important

Ensure you have the following installed and configured:

Quick Installation

1. Clone Repository

git clone https://github.com/ChanMeng666/library-management-system.git
cd library-management-system

2. Install Dependencies

# Using npm
npm install

# Using pnpm (recommended)
pnpm install

3. Environment Setup

# Copy environment template
cp .env.example .env.local

# Edit environment variables
nano .env.local

4. Start Development

npm run dev

🎉 Success! Open http://localhost:3000 to view the application.

Environment Setup

Create .env.local file with the following variables:

# Supabase (Required)
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

# Stripe (Required for billing)
STRIPE_SECRET_KEY=sk_test_or_live_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret

# Application
NEXT_PUBLIC_APP_URL=http://localhost:3000

# Email (Optional - for invitations)
RESEND_API_KEY=re_your_api_key

Warning

Never commit sensitive environment variables to version control. Use Vercel's environment variables settings for production.

Database Setup

Using Supabase CLI:

# Start local Supabase
npx supabase start

# Apply migrations
npx supabase db reset

# Stop local Supabase
npx supabase stop

Manual Setup:

  1. Create a new project on Supabase
  2. Run the migration files in supabase/migrations/ in order
  3. Configure RLS policies as defined in the migrations

🛳 Deployment

Important

The application is optimized for deployment on Vercel, but can be deployed on any platform that supports Next.js.

Vercel Deployment

One-Click Deploy:

Deploy with Vercel

Manual Deployment:

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel --prod

Environment Variables for Production

Variable Description Required
NEXT_PUBLIC_SUPABASE_URL Supabase project URL
NEXT_PUBLIC_SUPABASE_ANON_KEY Supabase anonymous key
SUPABASE_SERVICE_ROLE_KEY Supabase service role key
STRIPE_SECRET_KEY Stripe secret key
STRIPE_WEBHOOK_SECRET Stripe webhook secret
NEXT_PUBLIC_APP_URL Application URL
RESEND_API_KEY Resend API key 🔶

Note

✅ Required, 🔶 Optional

📖 Usage Guide

For Organization Owners

  1. Create Organization - Set up your library environment
  2. Configure Settings - Set loan duration, max loans per user
  3. Invite Team - Add librarians and members via email
  4. Subscribe - Choose a plan that fits your needs

For Librarians

  1. Manage Books - Add, edit, and delete books
  2. Process Loans - Handle borrowing and returns
  3. Track Inventory - Monitor book availability

For Members

  1. Browse Catalog - Search and filter books
  2. Borrow Books - Check out available books
  3. Write Reviews - Rate and review books
  4. Track Loans - View due dates in dashboard

🔌 Integrations

Service Purpose Status
Supabase Database, Auth, RLS ✅ Active
Stripe Subscriptions, Billing ✅ Active
Resend Email Invitations ✅ Active
Vercel Hosting & Deployment ✅ Active
shadcn/ui UI Components ✅ Active

⌨️ Development

Development Commands

# Development
npm run dev          # Start dev server
npm run build        # Build for production
npm run start        # Start production server
npm run lint         # Run ESLint

# Database
npx supabase start   # Start local Supabase
npx supabase stop    # Stop local Supabase
npx supabase db reset # Reset database

Project Structure

src/
├── app/                    # Next.js App Router
│   ├── api/               # API routes
│   │   ├── auth/         # Authentication
│   │   ├── stripe/       # Stripe webhooks
│   │   └── email/        # Email sending
│   ├── books/            # Book pages
│   ├── dashboard/        # User dashboard
│   └── org/              # Organization pages
├── components/
│   ├── books/            # Book components
│   ├── layout/           # Layout components
│   ├── organization/     # Org components
│   └── ui/               # shadcn/ui components
├── contexts/             # React contexts
├── lib/                  # Utilities
└── types/                # TypeScript types

🤝 Contributing

We welcome contributions to improve the Library Management System!

Development Process:

  1. Fork the Repository
  2. Create Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit Changes (git commit -m 'Add some AmazingFeature')
  4. Push to Branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

Contribution Guidelines:

  • Follow TypeScript best practices
  • Maintain consistent code style
  • Add comments for complex logic
  • Test your changes thoroughly
  • Update documentation as needed

Image


Image

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👥 Author

Chan Meng
Chan Meng

Creator & Lead Developer

Chan Meng


🚀 LibraryOS: The Operating System for Modern Libraries 🌟
Empowering organizations and readers worldwide

Star us on GitHub • 📖 Read the Documentation • 🐛 Report Issues • 💡 Request Features • 🤝 Contribute



Made with ❤️ for the library community

GitHub stars GitHub forks GitHub watchers

About

【Making code with love - show some love back with a star! 💝⭐️】A modern, full-featured library management system built with Next.js 15 and Supabase. Features real-time book tracking, user authentication, borrowing management, and a responsive UI powered by shadcn/ui components.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors