Skip to content
reaatech

Files · Perplexity Competitive Intelligence for E-commerce SMBs

77 (1 binary, 629.2 kB total)attempt 1

README.md·3204 B·markdown
markdown
# Perplexity Competitive Intelligence for E-commerce SMBs
 
> Automatically tracks competitor pricing, product changes, and marketing moves to generate daily briefs for small e-commerce businesses.
 
A tutorialized reference solution from [reaatech.com](https://reaatech.com), demonstrating how to build production-grade AI systems with the `@reaatech/*` package family.
 
## Problem
 
Small e-commerce business owners spend hours each week manually checking competitor websites for pricing changes, new products, and marketing campaigns. This manual process is error-prone, inconsistent, and scales poorly — a single person cannot monitor dozens of competitors across multiple dimensions. Missed competitive moves directly translate to lost revenue.
 
## Architecture
 
| Package | Role |
|---|---|
| **Perplexity** | Researches competitor websites using an online LLM, extracting pricing, product, and marketing changes |
| **Browserbase** | Headless browser infrastructure to scrape rendered competitor pages |
| **fastembed** | Generates local embeddings (BGEBaseEN) for change descriptions without API costs |
| **ChromaDB** | Vector store for similarity search across historical change events |
| **agent-memory** | Fact memory layer that stores, retrieves, and decays competitor intelligence over time |
| **confidence-router** | Prioritizes which competitors to scan each cycle based on business priority and context |
| **structured-repair-core** | Repairs malformed LLM JSON output through 6 fallback strategies |
| **Langfuse** | Open-source observability — traces every API call and pipeline step |
| **Slack webhooks** | Delivers daily briefs to the team channel via Block Kit |
| **node-cron** | Schedules the daily intel pipeline at 8 AM |
 
## Data Flow
 
```
Competitor URL

Browserbase scrape (headless browser → rendered text)

Perplexity analysis (online LLM research → raw JSON)

structured-repair (strip fences, coerce types, fallback strategies)

fastembed embedding (BGEBaseEN passageEmbed → vector)

ChromaDB (vector storage + similarity search)
    + agent-memory (fact extraction + retention)

Slack notification (Block Kit message → team channel)
```
 
## Setup
 
1. Clone the repository
2. Copy `.env.example` to `.env.local` and fill in all API keys:
   - `PERPLEXITY_API_KEY` — Perplexity AI API key
   - `BROWSERBASE_API_KEY` — Browserbase API key
   - `BROWSERBASE_PROJECT_ID` — Browserbase project ID
   - `OPENAI_API_KEY` — OpenAI API key (for agent-memory extraction)
   - `SLACK_WEBHOOK_URL` — Incoming Slack webhook URL
   - `LANGFUSE_PUBLIC_KEY` + `LANGFUSE_SECRET_KEY` — Langfuse observability keys (optional — pipeline runs without them)
3. Install dependencies:
   ```bash
   pnpm install
   ```
4. Start the dev server:
   ```bash
   pnpm dev
   ```
 
## Usage
 
- **Daily cron**: The pipeline runs automatically at 8 AM every day (configurable via `CRON_SCHEDULE`)
- **Manual trigger**: Send a `POST` request to `/api/report` to trigger an immediate intel run
- **View latest brief**: Send a `GET` request to `/api/report` to retrieve the most recent brief
 
## License
 
MIT — see [LICENSE](./LICENSE).