How rkv762/dhaga-next-purchase-nudge works
Dhaga & Co.’s Next Purchase Nudge turns customer orders, browsing, returns and reviews into a grounded product recommendation and re-engagement message, with evaluation and human-review outcomes. The main workflow runs through the API or local demo into a pipeline that fetches history, profiles and routes the customer, checks safety and ranks products, verifies SKUs, then drafts and evaluates a message. Supporting capabilities include configurable model selection, reviewer decisions, cost tracking and a browser UI. Some stage links rely on README documentation because source excerpts are partial.
Main entry points: pipeline.py Pipeline runner · data_access.py CSV data access · app.py FastAPI API · schemas.py Model and result schemas
Components 22
User entry points
- Web demo
index.html - FastAPI API
app.py - Local demo CLI
scripts/demo.py
Pipeline orchestration
- Pipeline runner
src/pipeline.py - Model and result schemas
src/schemas.py - Run settings
src/settings.py
Recommendation stages
- Profile extraction
src/chains.py - Persona routing
src/chains.py - Persona safety check
src/chains.py - SKU shortlist
src/chains.py - SKU grounding
src/data_access.py - Message drafting
src/chains.py - Message evaluation
src/chains.py - Model chains
src/chains.py
Data and governance
- CSV data access
src/data_access.py - Synthetic customer data
data - Decision log
src/data_access.py - Review decisions
src/review.py - Model cost estimates
src/pricing.py
Model services
- Anthropic or OpenRouter
Other components
- Customer or operator
- Human reviewer
Connections 32
- Customer or operator → Web demo: uses
README.md - Web demo → FastAPI API: calls API
README.md - Customer or operator → Local demo CLI: runs
README.md - Local demo CLI → Pipeline runner: runs
scripts/demo.py - FastAPI API → Pipeline runner: runs
app.py - FastAPI API → CSV data access: lists customers
app.py - FastAPI API → Run settings: configures run
app.py - FastAPI API → Review decisions: submits decision
app.py - Human reviewer → Web demo: reviews result
- Human reviewer → FastAPI API: submits review
app.py - Pipeline runner → CSV data access: fetches history
src/pipeline.py - Pipeline runner → Profile extraction: extracts profile
src/pipeline.py - Pipeline runner → Persona routing: routes persona
README.md - Pipeline runner → Persona safety check: checks safety
src/pipeline.py - Pipeline runner → SKU shortlist: ranks candidates
src/pipeline.py - Pipeline runner → CSV data access: gets candidates
src/pipeline.py - Pipeline runner → SKU grounding: verifies SKUs
src/pipeline.py - Pipeline runner → Message drafting: drafts message
src/pipeline.py - Pipeline runner → Message evaluation: evaluates draft
src/pipeline.py - Pipeline runner → Run settings: uses settings
src/pipeline.py - Profile extraction → Model and result schemas: returns profile
src/chains.py - Persona routing → Model and result schemas: returns decision
src/chains.py - Persona safety check → Model and result schemas: returns check
src/chains.py - SKU shortlist → Model and result schemas: returns picks
src/chains.py - Message drafting → Model and result schemas: returns draft
src/chains.py - Message evaluation → Model and result schemas: returns score
src/chains.py - CSV data access → Synthetic customer data: reads CSVs
src/data_access.py - Review decisions → CSV data access: validates customer
src/review.py - Review decisions → CSV data access: records decision
src/review.py - Pipeline runner → CSV data access: logs outcome
src/pipeline.py - Model chains → Anthropic or OpenRouter: calls model
- Model cost estimates → Anthropic or OpenRouter: prices usage