A mobile-first, offline-first digital library for data-constrained environments. Built with React, Vite, Supabase, and TanStack Query.
- 📚 Browse and search books with minimal data usage
- 📴 Offline-first architecture with IndexedDB caching
- 🔄 Automatic sync with background service workers
- 📱 Mobile-optimized with virtual scrolling
- ⚡ Battery-aware data sync and rendering
- 🔍 Full-text search with Supabase PostgreSQL
- 💾 Resumable PDF downloads with chunking
- Frontend: React 18 + Vite
- State Management: TanStack Query (React Query)
- Database: Supabase PostgreSQL
- Local Storage: IndexedDB (via idb library)
- Styling: Tailwind CSS
- Offline: Service Workers
- Virtualization: react-window
- Icons: lucide-react
- Node.js 16+
- npm or yarn
- Supabase account
-
Clone the repository:
cd Digital-Library -
Install dependencies:
npm install
-
Create a
.env.localfile in the root directory:VITE_SUPABASE_URL=https://your-project.supabase.co VITE_SUPABASE_ANON_KEY=your-anon-key -
Start the development server:
npm run dev
-
Open http://localhost:5173 in your browser
src/
├── components/ # React components
│ ├── BookCard.jsx # Individual book display
│ ├── LibraryHeader.jsx # Header with filters
│ └── VirtualLibraryList.jsx # Virtualized list
├── hooks/ # Custom React hooks
│ ├── useUserLibrary.js # Fetch user's library
│ └── useOnlineStatus.js # Network status detection
├── lib/ # Utilities and config
│ ├── supabase.js # Supabase client
│ ├── indexedDB.js # IndexedDB operations
│ └── queryClient.js # TanStack Query config
├── styles/ # CSS files
├── App.jsx # Main app component
└── main.jsx # Entry point
public/
├── sw.js # Service Worker
└── manifest.json # PWA manifest
npm run buildnpm run previewnpm run lint- Create a new Supabase project
- Create the following tables:
-- Books table
CREATE TABLE books (
id UUID PRIMARY KEY,
title TEXT NOT NULL,
author TEXT,
cover_url TEXT,
file_size INTEGER,
updated_at TIMESTAMP
);
-- User library
CREATE TABLE user_library (
id UUID PRIMARY KEY,
user_id UUID NOT NULL,
book_id UUID NOT NULL REFERENCES books(id),
downloaded BOOLEAN DEFAULT FALSE,
sync_status TEXT DEFAULT 'pending',
updated_at TIMESTAMP
);- Update your
.env.localwith Supabase credentials
- Virtual Scrolling: Only renders visible items to reduce memory usage
- Image Lazy Loading: Images load when visible via Intersection Observer
- IndexedDB Caching: Local cache prevents redundant network requests
- Service Worker: Offline support and background sync
- Debounced Search: Reduces API calls during typing
- Battery Awareness: Reduces animations and sync frequency on low power mode
Contributions are welcome! Please read our contributing guidelines first.
MIT