feat: add mid-range sellers by category analysis pipeline

This new pipeline identifies products meeting specific monthly sold, price, seller count, and Amazon buy box share criteria across categories. It fetches comprehensive product data from Keepa and SP-API, analyzes it using an LLM, and persists the results.

A key enhancement is the introduction of a dedicated Redis cache for Keepa and SP-API responses. This reduces API token consumption and improves performance for subsequent runs by caching enriched ASIN data with a 12-hour TTL. Products are saved regardless of their sellability status to provide a complete view.
This commit is contained in:
Victor Noguera
2026-05-02 12:03:31 -04:00
parent 9b832b7839
commit f2c8a9728d
5 changed files with 2409 additions and 1 deletions

View File

@@ -45,6 +45,38 @@ bun run src/sp-test.ts B07SN9BHVV # Auth + sellers endpoint + pricing offer c
bun run src/sp-test.ts --sellability B07SN9BHVV # Standalone sellability check
```
## Category Pipelines
Run category-focused discovery flows with Keepa + SP-API + LLM:
```bash
bun run bestsellers
bun run monthly-sold
bun run mid-range
```
Mid-range process:
- Script: `bun run mid-range`
- Source: `src/mid-range-sellers-by-category.ts`
- Default filters:
- Monthly sold between `100` and `1000`
- Price between `$15` and `$200` (using Keepa current price, fallback avg 90d)
- Seller count between `3` and `20`
- If Amazon is a seller, Amazon buy box share must be between `15%` and `85%`
- Sellability behavior:
- Sellability is still fetched and saved (`can_sell`, `sellability_status`, `sellability_reason`)
- Matching products are persisted regardless of sellability status
- Caching behavior:
- Uses Redis to cache Keepa + SP-API API enrichment per ASIN
- Cache TTL is fixed at `12 hours`
Example:
```bash
bun run mid-range --category-limit 10 --per-category-top 50 --category-candidate-pool 250 --min-monthly-sold 100 --max-monthly-sold 1000 --min-price 15 --max-price 200 --min-seller-count 3 --max-seller-count 20 --min-amazon-buybox-share-pct 15 --max-amazon-buybox-share-pct 85
```
## UPC to ASIN Mapping
You can map UPCs to ASINs directly through the Keepa integration in `src/keepa.ts`.