# Bibliothek

Book-centered catalog for Ignacio's collection, with grouped photos, inline metadata cleanup, and a game-style OCR review flow.

## Local run

```powershell
.\venv\Scripts\Activate.ps1
python run.py
```

Open `http://127.0.0.1:8000`.

## Deployment shape

- App: `Vercel` Python runtime
- Metadata: `Supabase Postgres`
- Images: compressed derivatives in `Supabase Storage`
- Access: invite-only `Supabase Auth` magic links

## Files added for deployment

- `api/index.py` - Vercel entrypoint
- `vercel.json` - route all traffic to FastAPI and exclude large local files
- `.env.example` - required production environment variables
- `scripts/crop_books.py` - smart crop pipeline with manual no-crop overrides
- `scripts/prepare_images.py` - generate upload-friendly image derivatives
- `scripts/upload_to_supabase_storage.py` - upload optimized images to a bucket
- `scripts/migrate_sqlite_to_postgres.py` - upsert catalog data into Postgres
- `supabase/schema.sql` - initial schema for the `bibliothek` project

## Suggested deployment flow

1. Create a new Supabase project named `bibliothek`.
2. Apply `supabase/schema.sql`.
3. Configure Supabase Auth `Site URL` and allowed redirect URLs, then invite `ignaciolagosruiz@gmail.com`.
4. Generate optimized images with `scripts/prepare_images.py`.
5. Upload optimized images to Storage.
6. Migrate SQLite data into Postgres.
7. Configure Vercel env vars from `.env.example`.
8. Deploy to Vercel.

## Crop overrides

- The hard cases you flagged are now forced to stay uncropped and only downscaled for readability.
- Rebuild the whole derivative set with `python scripts/crop_books.py batch`.
- Test individual images with `python scripts/crop_books.py test <image1> <image2>`.
