Overview
EpiNeko’s library management system allows users to organize their anime collection across different viewing statuses. The library is built on top of Supabase with row-level security, ensuring each user’s data is private and secure.Add to Library
Save anime to your collection with a single click
Update Status
Change viewing status as you progress through series
Track Progress
Monitor episodes watched and completion percentage
Remove Items
Clean up your library by removing unwanted entries
Library Item Structure
Each item in your library contains comprehensive information about the anime and your viewing progress:Core Functions
Adding to Library
Add a new anime to your personal collection using theaddToLibrary function:
The
user_id is automatically populated from the authenticated user’s session. Users must be logged in to add items to their library.- Retrieves the current user from Supabase Auth
- Inserts the item into the
user_librarytable - Returns the created item with all fields populated
- Throws an error if the user is not authenticated
Updating Library Items
Change the status or progress of an existing library item:Removing from Library
Remove an anime from your library completely:- Deletes the item matching both
user_idandanime_id_jikan - Ensures users can only remove their own items
- No error thrown if item doesn’t exist
Retrieving Library Data
Fetch your entire library or a specific item:- Get All Items
- Get Single Item
updated_at descending (src/services/library.ts:63-72).UI Components
LibraryButton Component
TheLibraryButton component provides a complete interface for managing library items with status dropdown:
1
Initial State
When not in library, displays ”+ AÑADIR A MI LISTA” button
2
Added State
After adding, shows ”✓ EN MI LISTA” and a status dropdown appears
3
Status Selection
Users can change between watching, completed, plan to watch, and dropped
4
Removal
Clicking the main button when in library removes the item
- 📺 VIENDO (watching)
- ✅ COMPLETADO (completed)
- ⏳ PENDIENTE (plan_to_watch)
- ❌ ABANDONADO (dropped)
Library Page
The library page displays all items in a responsive grid layout:- Features
- Usage
- Responsive grid (2-6 columns based on screen size)
- Loading skeletons during data fetch
- Empty state with call-to-action
- Direct links to anime detail pages
- Sorted by most recently updated
Database Schema
The library is backed by a PostgreSQL table with row-level security:- Users can only view, insert, update, and delete their own library items
- All operations are protected by
auth.uid() = user_idchecks - Row-level security is enabled on the table
Error Handling
All library functions properly handle authentication and database errors:Best Practices
Optimistic Updates
Update the UI immediately before API calls complete for better UX
Error Rollback
Revert optimistic updates if operations fail
Check Before Add
Use
getLibraryItem to check if an anime is already in the library before attempting to add itPartial Updates
Only include changed fields in
updateLibraryItem calls to minimize data transferRelated Features
- Progress Tracking - Track episode completion
- Scoring System - Rate your anime
- Watch Status - Understanding status types
- User Profile - View library statistics