Skip to content

Musyonchez/codex-librarium

Repository files navigation

Codex Librarium

A comprehensive web application for tracking your progress through the vast Warhammer 40,000 Black Library collection. Built with Next.js 15, TypeScript, and Supabase.

Features

πŸ“š Extensive Book Collection

  • 76+ complete series with 440 books total
  • 85 standalone novels
  • 101 novellas
  • 137 anthologies and collections
  • 763 unique books across all categories
  • Major series including:
    • The Horus Heresy (54 books)
    • Siege of Terra (8 books)
    • Dawn of Fire (9 books, ongoing)
    • Gaunt's Ghosts (16 books)
    • Eisenhorn, Ravenor, and Bequin trilogies
    • Ultramarines, Night Lords, Space Wolves, and more
    • Xenos-focused series: Path of the Eldar, Twice-Dead King, Phoenix Lords

🎯 Smart Organization

  • Four Book Categories - Separate navigation for Series, Singles, Novellas, and Anthologies
  • Multiple Sorting Options per Category - Each category supports browsing:
    • By Series (Series only) - Follow Black Library publication order
    • By Name - Alphabetically sorted complete catalog
    • By Tags - Find books by themes (e.g., "Primarchs", "Siege", "Investigation")
    • By Factions - Filter by your favorite armies and factions
  • Pagination - 20 items per page for easy browsing
  • Search Functionality - Quick filtering within tags and factions views

πŸ“Š Progress Tracking

  • Three reading states: Unread, Reading, Completed
  • Tabbed Dashboard - Separate dashboards for Series, Singles, Novellas, and Anthologies
  • Visual progress indicators and completion rates
  • Statistics for each category (Total, Completed, Reading, Unread)
  • Collapsible Sections - Currently Reading and Completed Books sections with expand/collapse functionality
  • Rating and Notes - Add ratings (1-5 stars) and personal notes for Singles, Novellas, and Anthologies
  • Real-time sync across all your devices

🎨 Premium UI/UX

  • Warhammer-themed dark interface with Imperial Gold accents
  • Detailed book modals with all metadata
  • Responsive design for desktop and mobile
  • Smooth animations and transitions

πŸ” Authentication & Security

  • Google OAuth via Supabase Auth
  • Row-level security for user data
  • Admin-only import functionality
  • Secure API endpoints

πŸ“ Book Requests

  • User Requests - Any authenticated user can request books to be added to the library
  • Request Management - Four status categories:
    • Requests (Pending) - New requests awaiting admin review
    • Approved - Requests accepted and fulfilled
    • Waitlist - Requests acknowledged but not yet ready to add
    • Refused - Requests rejected with admin-provided reasons
  • Filtering - Sort requests by newest or oldest
  • Admin-Only Status Changes - Only admins can move requests between statuses
  • Refusal Comments - Required explanations when refusing requests, with edit tracking

βš™οΈ Admin Features

  • JSON-based book import system with file selection
  • Support for importing Series, Singles, Novellas, and Anthologies
  • Automatic tag and faction normalization
  • Folder-based organization (_meta folders) for easy management
  • Real-time updates to canonical tag/faction lists across all categories
  • Selective import (choose specific files to import)
  • Book request management with status updates and refusal comments

Tech Stack

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript
  • Database: Supabase (PostgreSQL)
  • Authentication: Supabase Auth (Google OAuth)
  • Styling: Tailwind CSS
  • UI Components: Custom design system
  • Deployment Ready: Vercel-optimized

Getting Started

Prerequisites

  • Node.js 18+
  • npm/yarn/pnpm/bun
  • Supabase account

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/codex-librarium.git
cd codex-librarium
  1. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env.local

Edit .env.local and add your Supabase credentials:

NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
ADMIN_EMAILS=your-admin-email@example.com
  1. Run the development server:
npm run dev
  1. Open http://localhost:3000

Project Structure

β”œβ”€β”€ app/                    # Next.js app directory
β”‚   β”œβ”€β”€ api/               # API routes
β”‚   β”‚   β”œβ”€β”€ books/         # Series books API
β”‚   β”‚   β”œβ”€β”€ singles/       # Singles API
β”‚   β”‚   β”œβ”€β”€ novellas/      # Novellas API
β”‚   β”‚   β”œβ”€β”€ anthologies/   # Anthologies API
β”‚   β”‚   β”œβ”€β”€ reading/       # Reading progress APIs
β”‚   β”‚   β”‚   β”œβ”€β”€ route.ts   # Series progress (GET/POST)
β”‚   β”‚   β”‚   β”œβ”€β”€ singles/   # Singles progress (GET/POST)
β”‚   β”‚   β”‚   β”œβ”€β”€ novellas/  # Novellas progress (GET/POST)
β”‚   β”‚   β”‚   └── anthologies/ # Anthologies progress (GET/POST)
β”‚   β”‚   β”œβ”€β”€ requests/      # Book requests APIs
β”‚   β”‚   β”‚   β”œβ”€β”€ route.ts   # List/create requests (GET/POST)
β”‚   β”‚   β”‚   └── [id]/      # Update/delete request (PATCH/DELETE)
β”‚   β”‚   └── import/        # Import system APIs
β”‚   β”œβ”€β”€ dashboard/         # Dashboard pages
β”‚   β”‚   β”œβ”€β”€ page.tsx       # Series dashboard
β”‚   β”‚   β”œβ”€β”€ singles/       # Singles dashboard
β”‚   β”‚   β”œβ”€β”€ novellas/      # Novellas dashboard
β”‚   β”‚   β”œβ”€β”€ anthologies/   # Anthologies dashboard
β”‚   β”‚   └── requests/      # Book requests dashboard
β”‚   β”œβ”€β”€ import/            # Admin import page
β”‚   β”œβ”€β”€ order/             # Book browsing pages
β”‚   β”‚   β”œβ”€β”€ series/        # Series books
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx   # Redirect to /series
β”‚   β”‚   β”‚   β”œβ”€β”€ series/    # Browse by series
β”‚   β”‚   β”‚   β”œβ”€β”€ name/      # Browse by name
β”‚   β”‚   β”‚   β”œβ”€β”€ tags/      # Browse by tags
β”‚   β”‚   β”‚   └── factions/  # Browse by factions
β”‚   β”‚   β”œβ”€β”€ singles/       # Single novels
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx   # Redirect to /name
β”‚   β”‚   β”‚   β”œβ”€β”€ name/      # Browse by name
β”‚   β”‚   β”‚   β”œβ”€β”€ tags/      # Browse by tags
β”‚   β”‚   β”‚   └── factions/  # Browse by factions
β”‚   β”‚   β”œβ”€β”€ novellas/      # Novellas
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx   # Redirect to /name
β”‚   β”‚   β”‚   β”œβ”€β”€ name/      # Browse by name
β”‚   β”‚   β”‚   β”œβ”€β”€ tags/      # Browse by tags
β”‚   β”‚   β”‚   └── factions/  # Browse by factions
β”‚   β”‚   └── anthologies/   # Anthologies
β”‚   β”‚       β”œβ”€β”€ page.tsx   # Redirect to /name
β”‚   β”‚       β”œβ”€β”€ name/      # Browse by name
β”‚   β”‚       β”œβ”€β”€ tags/      # Browse by tags
β”‚   β”‚       └── factions/  # Browse by factions
β”‚   └── auth/              # Authentication callbacks
β”œβ”€β”€ components/            # React components
β”‚   β”œβ”€β”€ AppLayout.tsx      # Main layout wrapper
β”‚   β”œβ”€β”€ BookDetailsModal.tsx
β”‚   β”œβ”€β”€ DashboardTabs.tsx  # Dashboard category tabs
β”‚   β”œβ”€β”€ OrderTabs.tsx      # Sorting tabs
β”‚   β”œβ”€β”€ Navbar.tsx
β”‚   └── SeriesView.tsx
β”œβ”€β”€ lib/                   # Utilities and types
β”‚   β”œβ”€β”€ supabase/          # Supabase client setup
β”‚   β”œβ”€β”€ design-system.ts   # Theming and styles
β”‚   └── types.ts           # TypeScript definitions
β”œβ”€β”€ data/                  # Book data
β”‚   β”œβ”€β”€ series/            # Series JSON files
β”‚   β”‚   └── _meta/         # tags.json, factions.json
β”‚   β”œβ”€β”€ singles/           # Singles JSON files
β”‚   β”‚   └── _meta/         # tags.json, factions.json
β”‚   β”œβ”€β”€ novellas/          # Novellas JSON files
β”‚   β”‚   └── _meta/         # tags.json, factions.json
β”‚   └── anthologies/       # Anthologies JSON files
β”‚       └── _meta/         # tags.json, factions.json
β”œβ”€β”€ supabase/              # Database migrations
β”‚   └── migrations/        # SQL migration files
└── .claude/               # Documentation
    β”œβ”€β”€ DESIGN_SYSTEM.md
    β”œβ”€β”€ DATABASE.md
    β”œβ”€β”€ API_ENDPOINTS.md
    └── AUTHENTICATION.md

Database Setup

Option 1: Using Supabase Dashboard (Recommended for new projects)

  1. Create a new Supabase project at https://supabase.com/dashboard
  2. Go to SQL Editor in your Supabase dashboard
  3. Run supabase/migrations/004_complete_fresh_schema.sql - Creates all tables, indexes, and RLS policies
  4. Run supabase/migrations/005_add_book_requests.sql - Adds book requests feature
  5. In Authentication β†’ Providers, enable Google OAuth with your credentials

Option 2: Using Supabase CLI

npx supabase db push

The database includes:

  • Book Tables: series, series_books, singles, novellas, anthologies
  • Reading Progress Tables: reading_progress_series_books, reading_progress_singles, reading_progress_novellas, reading_progress_anthologies
  • Book Requests Table: book_requests - User-submitted book requests with admin management
  • Row Level Security (RLS) on all tables
  • Indexes for optimal query performance

See supabase/migrations/004_complete_fresh_schema.sql for the main schema and 005_add_book_requests.sql for the book requests feature.

Adding Books

Books are stored as JSON files in four category directories:

  • data/series/ - Series with books
  • data/singles/ - Standalone novels
  • data/novellas/ - Novellas
  • data/anthologies/ - Anthologies and collections

To add books:

  1. Create a new JSON file in the appropriate category folder
  2. Follow the schema for that category
  3. Tags and factions will auto-normalize against canonical lists in _meta/ folders
  4. Validate your changes:
npm run validate-data

This script checks for:

  • Missing IDs
  • Duplicate IDs within each table
  • Overlapping IDs between tables (warning only)

For admin access, use the /import page to selectively import JSON files.

Documentation

Comprehensive documentation is available in the .claude/ directory:

  • DESIGN_SYSTEM.md - Colors, typography, component patterns
  • DATABASE.md - Schema, RLS policies, queries
  • API_ENDPOINTS.md - API reference and examples
  • AUTHENTICATION.md - Auth flow and security
  • PROJECT_STRUCTURE.md - Architecture overview
  • ADDING_BOOKS.md - Book import guide

Deployment

Deploy to Vercel

Deploy with Vercel

  1. Push your code to GitHub
  2. Import the repository in Vercel
  3. Add environment variables in Vercel dashboard
  4. Deploy!

Environment Variables for Production

Make sure to set these in your Vercel dashboard:

  • NEXT_PUBLIC_SUPABASE_URL
  • NEXT_PUBLIC_SUPABASE_ANON_KEY
  • SUPABASE_SERVICE_ROLE_KEY (for admin imports)
  • GOOGLE_CLIENT_ID
  • GOOGLE_CLIENT_SECRET
  • ADMIN_EMAILS (comma-separated list)

Contributing

Contributions are welcome! To add new book series:

  1. Fork the repository
  2. Create a new series JSON file following the schema
  3. Test locally
  4. Submit a pull request

License

This is a personal project for tracking Warhammer 40,000 book collections. All Warhammer 40,000 intellectual property belongs to Games Workshop.

Acknowledgments

  • Black Library for the incredible Warhammer 40,000 book collection
  • Games Workshop for the Warhammer 40,000 universe
  • The community for keeping track of reading orders

In the grim darkness of the far future, there are only books to track.

About

Track your progress through 763 Warhammer 40K books across 76+ series. Built with Next.js 15, TypeScript, and Supabase. Features Google OAuth, reading progress tracking, and admin book management.

Topics

Resources

Stars

Watchers

Forks

Contributors