2.9 KiB
2.9 KiB
Claude Guidelines for this Project
-
Use the consolidated DB everywhere
- Preferred env:
CRAWLSY_DATABASE_URL(fallbackDATABASE_URL). - Do NOT create dutchie tables in the legacy DB. Apply migrations 031/032/033 to the consolidated DB and restart.
- Preferred env:
-
Dispensary vs Store
- Dutchie pipeline uses
dispensaries(not legacystores). For dutchie crawls, always work with dispensary ID. - Ignore legacy fields like
dutchie_plus_idand slug guessing. Use the record’smenu_urlandplatform_dispensary_id.
- Dutchie pipeline uses
-
Menu detection and platform IDs
- Set
menu_typefrommenu_urldetection; resolveplatform_dispensary_idformenu_type='dutchie'. - Admin should have “refresh detection” and “resolve ID” actions; schedule/crawl only when
menu_type='dutchie'ANDplatform_dispensary_idis set.
- Set
-
Queries and mapping
- The DB returns snake_case; code expects camelCase. Always alias/map:
platform_dispensary_id AS "platformDispensaryId"- Map via
mapDbRowToDispensarywhen loading dispensaries (scheduler, crawler, admin crawl).
- Avoid
SELECT *; explicitly select and/or map fields.
- The DB returns snake_case; code expects camelCase. Always alias/map:
-
Scheduling
/scraper-scheduleshould accept filters/search (All vs AZ-only, name).- “Run Now”/scheduler must skip or warn if
menu_type!='dutchie'orplatform_dispensary_idmissing. - Use
dispensary_crawl_statusview; show reason when not crawlable.
-
Crawling
- Trigger dutchie crawls by dispensary ID (e.g.,
/api/az/admin/crawl/:idorrunDispensaryOrchestrator(id)). - Update existing products (by stable product ID), append snapshots for history (every 4h cadence), download images locally (
/images/...), store local URLs. - Use dutchie GraphQL pipeline only for
menu_type='dutchie'.
- Trigger dutchie crawls by dispensary ID (e.g.,
-
Frontend
- Forward-facing URLs:
/api/az,/az,/az-schedule; no vendor names. /scraper-schedule: add filters/search, keep as master view for all schedules; reflect platform ID/menu_type status and controls (resolve ID, run now, enable/disable/delete).
- Forward-facing URLs:
-
No slug guessing
- Do not guess slugs; use the DB record’s
menu_urland ID. Resolve platform ID from the URL/cName; if set, crawl directly by ID.
- Do not guess slugs; use the DB record’s
-
Verify locally before pushing
- Apply migrations, restart backend, ensure auth (
userstable) exists, run dutchie crawl for a known dispensary (e.g., Deeply Rooted), check/api/az/dashboard,/api/az/stores/:id/products,/az,/scraper-schedule.
- Apply migrations, restart backend, ensure auth (
-
Image storage (no MinIO)
- Save images to local filesystem only. Do not create or use MinIO in Docker.
- Product images:
/images/products/<dispensary_id>/<product_id>-<hash>.webp(+medium/+thumb). - Brand images:
/images/brands/<brand_slug_or_sku>-<hash>.webp. - Store local URLs in DB fields (keep original URLs as fallback only).
- Serve
/imagesvia backend static middleware.