AstroBaaS

Analytics & reporting

Revenue Analytics, Profitability & Reporting

Paid pluginsize Lplanned, not built

Indicative price, not an offer: $29-79/mo

Generated from docs/plan/paid/revenue-analytics-profitability-reporting/PLAN.md in the AstroBaaS repository. Nothing described below is implemented — it is the written plan for it.

A paid analytics module calculating per-product and per-channel profitability (revenue minus COGS minus fulfillment costs), with margin drill-down, channel attribution, and profitability forecasting. Core exposes order data; this pack owns COGS tracking, cost allocation, and profitability dashboards.

The problem

Merchant sees €100K revenue but 60% margin on Product A (€60 profit) vs 10% margin on Product B (€10 profit). Without COGS tracking, they overspend marketing on low-margin products, miss that 20% of SKUs drive 80% of profit, and cannot forecast profitability of new products.

What it does

  • COGS tracking: merchants set COGS per product variant (€5 for product A), updated when suppliers change prices
  • Fulfillment costs: assign shipping/packaging cost per product or per order (flat fee or variable by weight)
  • Channel attribution: attribute revenue to source (organic/paid ads/affiliate), calculate profitability per channel
  • Margin calculation: (revenue - COGS - fulfillment) / revenue = gross margin %
  • Profitability dashboard: product list (sorted by profit $), channel profitability (bar chart), margin distribution (histogram)
  • Drill-down: click product/channel, see underlying orders, margin per order, profitability trend (last 30/60/90 days)
  • Forecasting: if Product A margin is 60% and we project €10K revenue next month, forecast profit is €6K

What it deliberately does NOT do

Each boundary carries its reason. A boundary without a reason gets crossed by the next person who reads this.

  • Operating expenses (rent, salaries, utilities)—owned by expense tracking module
  • Multi-warehouse cost allocation (different fulfillment costs per location)—too complex; merchants set flat rates
  • Supplier invoice matching and automatic COGS updates—owned by AP module
  • Tax impact on profitability—owned by tax module
  • Profit sharing/commission calculations for affiliates—owned by affiliate module

Data model

New entities: ProductCOGS (id, productVariantId, cogs, currency, updatedAt); FulfillmentCost (id, orderId, costType[shipping|packaging|handling], costAmount, costCurrency); ProfitabilityMetric (id, merchantId, type[product|channel], typeId, revenue, cogs, fulfillmentCost, grossMargin, grossMarginPercent, calculatedAt). Links: ProductCOGS.productVariantId → ProductVariant, FulfillmentCost.orderId → Order, ProfitabilityMetric.typeId → ProductVariant or Channel. Migration: if COGS not set, assume 0 (merchants must backfill).

API

  • POST /api/v1/products/{variantId}/cogs — set COGS for product variant (staff only)
  • GET /api/v1/products/{variantId}/cogs — fetch COGS (staff only)
  • POST /api/v1/orders/{id}/fulfillment-cost — add fulfillment cost to order (staff only, audit logged)
  • GET /api/v1/profitability/by-product — profitability per product (staff only, filterable by date range)
  • GET /api/v1/profitability/by-channel — profitability per channel (staff only)
  • GET /api/v1/profitability/dashboard — profitability summary (total profit, margin %, top 5 products by profit) (staff only)
  • POST /api/v1/profitability/forecast — forecast profit based on historical margins (staff only)

Every route added here must also appear in src/pages/openapi.json.ts — a test fails the build if it does not.

Admin

Profitability page: COGS section (list products, edit COGS per variant, history of COGS changes). Dashboard card: total gross profit (€25K), gross margin % (45%), trend (up 3% vs last month). Product profitability table: product name, revenue, COGS, fulfillment cost, gross margin ($), gross margin (%), sortable by margin %. Channel profitability card: organic (40% margin, €15K profit), paid (30% margin, €8K profit), affiliate (25% margin, €2K profit).

The seam — why this is paid

Core owns: order data (line items, revenue, customer ID, channel attribution if set). Paid pack owns: ProductCOGS entity, FulfillmentCost entity, margin calculation, channel profitability rollup, forecasting logic. Seam drawn here because profitability calculation methods vary (gross margin vs. contribution margin vs. EBITDA)—support team configures the model for each merchant.

Paid module owns cost-of-goods tracking, margin calculation, channel profitability attribution, and custom dashboard engine; core exposes order data only

Dependencies

  • core:orders — read order revenue, line items, dates
  • core:products — read product variant data, link to COGS
  • core:channels — read channel attribution (assumes order.channel is set)
  • assumption: Customer.acquisitionChannel or Order.channel is populated

Acceptance checks

Each of these must be able to fail. Before claiming this is done, break the code deliberately and watch each one go red.

  • Product A variant (id: sku_abc) has COGS set to €5; order includes Product A at €20; profitability is €20 - €5 = €15 gross profit
  • Order includes fulfillment cost €2.50 (shipping); profitability is €20 - €5 - €2.50 = €12.50
  • Product B is sold via ‘Paid Ads’ channel; order revenue €100, COGS €60, fulfillment €10; channel profitability includes this €30 margin
  • Profitability by product lists Product A: €50K revenue, €10K COGS, €2K fulfillment = €38K gross profit, 76% margin
  • Channel profitability shows: Organic (200 orders, €40K revenue, 50% margin); Paid (100 orders, €30K revenue, 30% margin)
  • Profitability dashboard shows: Gross profit €25K, gross margin 45%, top 5 products by profit sorted correctly
  • Forecast: Product A projects €10K revenue next month at 76% historical margin = €7.6K forecast profit
  • Drill-down on Organic channel shows 200 orders, sorted by margin; each order shows revenue, COGS, fulfillment cost, margin $

Risks

COGS must be accurate—if unset or wrong, profitability is wrong. Implement validation (warn if COGS > 50% of price). Fulfillment cost assignment is manual—if not entered for all orders, profitability is understated. Channel attribution requires order.channel to be set—if missing, orders are unattributed. Margin forecast assumes historical = future; add confidence interval or volatility warning. Multi-currency orders must convert to shop currency—implement FX rate lock (order.conversionRate).

Commercial context

Suggested price$29-79/mo
Rival anchorReport Pundit $29-99/mo, TP True Profit monthly, Propel freemium ($25-199/mo)

The anchor is what the nearest equivalent charges on Shopify or Magento today. It is context for a pricing decision, not the decision.


Generated from the commerce plan. See docs/COMMERCE-PLAN.md for the full catalogue and ../../AI-GUIDE.md for how to work on this repository.