feat: implement SQLite persistent storage for analysis results

- Implemented database initialization and connection management in `database.ts` using Bun's SQLite.
- Created `runs` and `results` tables to track historical analysis metadata and detailed product performance.
- Updated `writer.ts` to persist analysis results to the database within a transaction, replacing the previous CSV output logic.
- Updated README and `.gitignore` to reflect the new persistent storage capability.
This commit is contained in:
Victor Noguera
2026-04-12 23:41:40 -04:00
parent 0162e54007
commit 8ffbd48c46
5 changed files with 223 additions and 25 deletions

View File

@@ -91,7 +91,18 @@ Numeric parsing accepts plain numbers as well as formatted values like `$12.50`,
4. **Keepa fetch** — batch the sellable (uncached) ASINs in a single API call (up to 100 per request)
5. **Enrich** — fetch SP-API pricing + FBA/FBM fees for sellable ASINs; combine with Keepa data and spreadsheet data
6. **LLM analysis** — send batches of 5 sellable products to LM Studio for FBA/FBM/SKIP verdict; skipped ASINs get auto-SKIP verdict (confidence 100) and bypass LLM entirely
7. **Output** — print results table to console (includes all ASINs), optionally write CSV/XLSX
7. **Output** — print results table to console (includes all ASINs), optionally write CSV/XLSX, and **persist results to a SQLite database**.
## Persistent Storage with SQLite
Results from each run are now stored in a SQLite database named `results.db` in the project root. The SQLite implementation details are handled in `src/database.ts`. This allows you to:
- Revisit past analysis results.
- Query and analyze historical data.
- Track product performance over time.
The database will automatically be created if it doesn't exist. Two tables are created:
- `runs`: Stores metadata about each analysis run (timestamp, input file, output file, and summary counts).
- `results`: Stores detailed analysis results for each product from each run, linked to the `runs` table.
## Output columns