The strategic insights engine is a Python script that queries the enriched analytics views, computes four key marketing signals, and writes a human-readable Markdown report toDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/andresshm/fini-marketing-intelligence/llms.txt
Use this file to discover all available pages before exploring further.
reports/strategic_insights.md on every pipeline run. Rather than requiring an analyst to manually interpret dashboards, the engine quantifies the most important findings — which customer segments drive revenue, how promotions affect margins, which new product launched strongest, and which region lags the rest — and pairs each metric with a concrete recommendation. All four insights are derived from the same two PostgreSQL views: vw_sales_enriched for transactional data and vw_product_launches for new-product performance.
Data Sources
The script loads both views into pandas DataFrames at the start of every run:vw_sales_enriched is a flat view joining fact_sales, dim_customers, and dim_products, making columns such as purchase_frequency, region, discount, units, revenue, and margin available without additional joins. vw_product_launches extends the sales data with launch_date and days_since_launch for every product, enabling first-90-day cohort analysis.
The Four Insight Categories
Customer Value
Groups revenue by the Output example: The Medium and High frequency segments generate 79.6% of total revenue, confirming that retaining existing frequent buyers is more impactful than acquiring new low-frequency customers.
purchase_frequency dimension in vw_sales_enriched, identifies the top two frequency segments by total revenue, and calculates their combined share of overall revenue.Promotions
Splits all transactions into two groups — discounted (Output example: Promotions increase average units sold by +49.8% while average margin changes by +6.0%, indicating that the volume uplift more than compensates for the discount — a net-positive result when applied selectively.
discount > 0) and non-discounted (discount == 0) — then calculates the percentage change in average units sold and average margin between the two groups.Product Launches
Filters Output example: Fruit Rings was the strongest launch, generating €11,730 in its first 90 days — making it the benchmark product whose marketing mix and distribution strategy should be studied and replicated.
vw_product_launches to the first 90 days post-launch, aggregates revenue by product, and identifies the single highest-revenue product in that window.Regional Performance
Groups revenue from Output example: The South region accounts for only 18.7% of total revenue, the smallest share of any region — flagging it as a priority for targeted growth campaigns or distribution expansion.
vw_sales_enriched by region, identifies the lowest-performing region, and calculates its share of total revenue.Sample Report Output
Below is a real example ofreports/strategic_insights.md produced by the engine from the current dataset:
Report Output
The engine writes the assembled insights toreports/strategic_insights.md using Python’s built-in file I/O:
The
reports/strategic_insights.md file is overwritten on every pipeline run — it always reflects the most recently loaded data. Archive previous versions manually or via version control if you need a historical record of insight snapshots.