This manual explains how the trend-research-automation system works end-to-end:
data collection, storage, normalization, scoring, dashboards, exports, reports, competitor analysis,
configuration, maintenance, and future extension.
The system is designed to help a pajamas, lingerie, homewear, loungewear, and nightwear brand decide what to create and what to test. It combines trend demand, competitor advertising signals, internal fit heuristics, and future-ready placeholders for owned performance data.
The output is not a generic trend feed. It is a decision-support system intended to answer questions like:
config/: editable YAML business configurationsrc/providers/: external source adapterssrc/pipelines/: executable workflowssrc/services/: scoring, classification, reporting, alerts, config loadingsrc/models/: schemas and SQLite managementdashboards/: Streamlit app plus dashboard export CSVreports/: rendered HTML reports and alert filesGoogle Trends is the strongest direct demand signal in the current setup. The project uses Egypt-focused tracked terms and collects interest data with locale-aware handling.
Stored in: google_trends_raw
Competitor ads are collected through Apify using the Facebook Ads Library scraper actor. Exact Facebook page URLs are preferred where available because they produce better results than broad keyword search.
Stored in: meta_competitor_raw
TikTok is currently supported through mock and manual workflows. The architecture is ready for a more live integration later, but a stable live collector is not yet part of the current system.
Internal Instagram, Facebook, and TikTok performance data can be imported manually. This is the future source for true historical performance weighting, including CTR, orders, revenue, and conversion-derived fit.
The project uses SQLite. The main operational tables are:
| Table | Purpose |
|---|---|
tracked_terms | Keyword inventory used by live and manual collection. |
google_trends_raw | Raw Google Trends rows. |
tiktok_trends_raw | Raw TikTok trend rows. |
meta_competitor_raw | Raw competitor ad rows from Meta/Apify. |
social_performance_raw | Owned content/ad performance inputs. |
normalized_trends | Unified cross-source trend signal table. |
trend_scores | Final scored trend decisions. |
weekly_shortlist | Action-oriented shortlist for testing. |
final_score = (google_score * 0.30) + (tiktok_score * 0.25) + (competitor_score * 0.20) + (fit_score * 0.15) + (historical_conversion_fit_score * 0.10)
| Decision | Rule | Meaning |
|---|---|---|
paid_test | >= 75 | Strong enough to justify paid testing. |
organic_test | >= 55 and < 75 | Strong enough for content testing. |
watchlist | >= 35 and < 55 | Worth monitoring, not a top priority. |
ignore | < 35 | Low priority right now. |
Fit score is a heuristic measure of how relevant a topic is to the brand. It rewards direct product terms such as pajamas, lingerie, homewear, satin, cotton, and Egyptian Arabic equivalents.
If owned performance data exists, the system can infer fit from revenue, orders, and CTR. If not, it defaults to a
neutral score of 50.
Competitor score is the strongest of:
Because competitor conversion rate is not available from Ad Library scraping, the system uses a transparent proxy. It rewards:
Competitor relevance is intentionally constrained:
campaign_angle and offer_text.pajama, lingerie, and homewear are used for overlap matching.exact match, tag_overlap, or none.Executive summary of the current system state: top score, top trend, current shortlist size, the top curated trend table, and basic charts.
Detailed trend ranking view with the full planning-ready fields: scores, decision, platform recommendation, hook, format, paid-vs-organic recommendation, and shortlist rationale.
Raw competitor ad rows. This is where scraped ad text, offer text, and media type can be inspected directly.
Audit layer for Google keyword support. It shows, for each Google keyword, whether any competitor ad supports it by:
exact: the keyword appears in ad-relevant texttag_overlap: the competitor ad shares the same category tagsnone: no current competitor supportData quality and debugging section. Use it to inspect what was ingested from each source and how it was normalized.
Action layer for execution teams. Shows why a trend matters now and what to make first.
Download center for CSV and HTML outputs.
| Field | Meaning |
|---|---|
trend_topic | Trend being ranked. |
final_score | Weighted final priority score. |
decision | Operational recommendation: paid, organic, watchlist, ignore. |
platform_priority | Recommended primary platform. |
recommended_hook | Suggested opening angle. |
recommended_format | Recommended creative format. |
why_now | Human-readable rationale for acting now. |
content_hook | Shortlist-ready execution angle. |
Main commands:
python -m src.main ingest-google-trends python -m src.main ingest-meta-competitors python -m src.main normalize-signals python -m src.main score-trends python -m src.main build-weekly-shortlist python -m src.main export-dashboard python -m src.main generate-daily-report python -m src.main generate-weekly-report python -m src.main run-daily-pipeline python -m src.main run-weekly-pipeline python -m src.main run-dashboard
Main editable files:
config/settings.yaml: global settings, scheduler times, provider enablement, pathsconfig/tracked_terms.yaml: the keyword universeconfig/competitors.yaml: competitor list, platforms, handles, optional page_urlconfig/scoring.yaml: weights, thresholds, fit keywords, competitor proxy settings| Issue | Likely Cause | Action |
|---|---|---|
| Competitor scrape returns weak data | Generic keyword search instead of exact page URL | Add or improve page_url in competitors.yaml. |
| No competitor data | Actor timeout or empty page results | Retry scrape, reduce scope, or improve competitor source URLs. |
| Scores look inflated | Matching rules too broad | Inspect the Keyword Support tab and tighten taxonomy rules. |
| Dashboard looks outdated | Exports not regenerated after scoring | Run score-trends, build-weekly-shortlist, and export-dashboard. |
.env.The system has been structured so it can evolve without a full rewrite. Recommended next upgrades:
README.md: quick-start operational instructionsUSER_MANUAL.html: this full manualdashboards/app.py: Streamlit dashboardsrc/services/trend_scoring.py: main scoring logicsrc/providers/meta_ad_library.py: competitor scrape adapterdb/trend_research.db: SQLite databasedashboards/dashboard_dataset.csv: dashboard-ready exportThis manual is designed to be maintained with the codebase. When major provider, scoring, or dashboard behavior changes, update this file at the same time so the operational model stays aligned with the implementation.