All skills

Briefing-mpd

current

Briefing-mpd is a Django and Django REST Framework service that combines merchandise performance decisions (MPD) with a daily retail briefing dashboard. It reads style, final-style, analytical, snapshot, and competitor data from PostgreSQL-backed tables, calculates inventory and demand exceptions, exposes item-level decision APIs, and supports briefing feed approvals. It also includes snapshot-building and synchronization services, Redis configuration, and a vendored gRPC notification publisher.

main·2a89d6d8e112·generated by gpt-5.6-luna·9/4/2026, 1:17:46 PM View as Markdown

This service helps retail teams decide what to do with merchandise. It highlights products at risk of selling out, carrying too much stock, or experiencing unusual demand; compares pricing with competitors; and presents these findings in a daily briefing where users can review and approve or reject recommended actions.

6
Merchandise Performance DecisioningproductionwritePlanninguser facingagent facing93%

Lets merchandise teams review individual styles, understand their commercial impact, and record actions such as holding price, promoting, repricing, increasing price, or applying a permanent markdown.

The MPD application provides item listing and detail views, impact-matrix data, single decisions, bulk decision previews and submissions, and decision status. Decision actions are represented by constants including ACTION_NONE, ACTION_PERMANENT_MARKDOWN, ACTION_PRICE_INCREASE, ACTION_PROMO, and ACTION_REPRICING, with decisions persisted through the MpdDecision model.

Inventory and Demand Exception MonitoringproductionreadInventoryuser facingagent facing95%

Identifies products that may sell out, have excess stock, experience a demand spike, or suffer a demand drop so teams can focus on the most urgent issues.

The briefing snapshot schema stores weeks of cover, four-week rate of sale, sales variance, closing stock, on-order units, exception counts, revenue at risk, and boolean flags for stockout, overstock, demand spike, and demand drop. The implemented thresholds are below 2 weeks of cover, above 12 weeks of cover, and sales variance above or below 25%.

Daily Merchandise BriefingproductionreadReportinguser facing91%

Provides a daily feed of product and category issues, commercial changes, and recommended actions for retail users to review.

The briefing application exposes a dashboard, scan operation, feed-item detail, and approval routes. Category-engine code generates market and change feed items from daily snapshot data, including category sales summaries, SKU counts, revenue concentration, and week-over-week observations.

Briefing Recommendation ApprovalpartialwritePlanninguser facingagent facing82%

Allows users to approve or reject actions proposed in the merchandise briefing, creating a review step before changes are accepted.

ApprovalDetailView, ApproveActionView, and RejectActionView are wired under the briefing URL configuration. The repository also defines approval-status event configuration and notification publishing support, although the supplied evidence does not show the complete approval persistence or event implementation.

Competitor Price BenchmarkingpartialreadReportinguser facinginternal90%

Compares the retailer’s average selling prices with competitor prices by category and subcategory, showing price gaps and the amount of competitor coverage.

CompetitorRollup queries webscraping_productweeklysnapshot, webscraping_scrapedproduct, and webscraping_website tables for the latest weekly competitor prices. It calculates competitor average, minimum, and maximum prices, competitor counts, tracked product counts, and the percentage gap against supplied internal prices; it can build context for downstream language-model analysis.

Briefing Snapshot SynchronizationproductionexecuteReportingagent facinginternal90%

Builds and refreshes a daily product-performance snapshot so briefing metrics can be calculated consistently and served quickly.

Snapshot builder code creates tenant-specific daily_briefing_snapshot tables and ingests analytical results using PostgreSQL COPY. It reads analytical and master metadata from configured database connections, supports a scan endpoint and a sync endpoint, and uses a shared database alias named merchmix_sync.

4
Review and act on an MPD item

A user or agent inspects a style’s current performance, reviews its impact matrix, and records a merchandise action.

  1. 1.List available merchandise items through the MPD items endpoint.
  2. 2.Retrieve a style by style reference.
  3. 3.Retrieve the style’s impact matrix and decision status.
  4. 4.Submit a single decision or preview and submit a bulk decision.
  5. 5.Use the configured action values to represent the recommended commercial response.
Generate and review the daily briefing

The service calculates product and category exceptions and presents them as briefing feed items.

  1. 1.Read analytical and master merchandise data from configured PostgreSQL connections.
  2. 2.Calculate rate of sale, weeks of cover, demand variance, exception counts, and revenue at risk.
  3. 3.Write or refresh the tenant daily briefing snapshot.
  4. 4.Generate market and change category feed items from the snapshot.
  5. 5.Expose the briefing dashboard and individual feed items for review.
Approve or reject a briefing action

A reviewer evaluates a proposed briefing action and records the outcome.

  1. 1.Open an approval by its identifier.
  2. 2.Review the associated briefing information.
  3. 3.Approve or reject the proposed action.
  4. 4.Optionally publish a configured notification event through the vendored notification client.
Compare internal and competitor pricing

The service creates category-level pricing context for merchandising analysis.

  1. 1.Read the latest competitor product weekly snapshot.
  2. 2.Aggregate competitor prices by category and subcategory.
  3. 3.Combine competitor averages with supplied internal average prices.
  4. 4.Calculate price gaps and return structured benchmarking context.

A Django monolith-style microservice with separate MPD and briefing applications. HTTP views delegate business calculations to service modules, while Django ORM models and explicitly managed PostgreSQL tables provide persistence. The service is deployable as a Gunicorn container on Azure Container Apps or Google Cloud Run.

Components
mpd Django app for item retrieval, impact matrices, decisions, bulk previews, decision submission, metadata, and decision status.briefing Django app for dashboard, scan, synchronization, feed items, and approval actions.briefing/services/builder.py for analytical snapshot construction and PostgreSQL COPY ingestion.briefing/services/category_engine.py for category-level market and change feed generation.briefing/services/competitor.py for competitor price aggregation and pricing context.common Django app for shared models and views.merchmix_ai.sync_tables for tenant-aware synchronization table naming.merchmix_notify for vendored gRPC notification publishing and recipient resolution.mpd_briefing_service Django project for settings, routing, WSGI, ASGI, health, and deployment runtime.
Patterns
Django class-based API views with Django REST Framework responses.Service-layer business logic around Django ORM and direct SQL.Tenant-aware routing and table resolution using the X-Tenant-Client-Id request header and tenant-specific snapshot tables.Separate analytical/synchronization database connection from the default application database.PostgreSQL bulk ingestion using COPY.Containerized deployment behind Gunicorn.
18
KindIdentifierDescription
httpGET /health/Returns service health and identifies the MPD and briefing sections.
httpGET /Returns a service status response with links to the MPD and briefing sections.
httpGET /mpd/items/ and GET /api/mpd/items/Lists MPD merchandise items.
httpGET /mpd/items/<style_ref>/ and GET /api/mpd/items/<style_ref>/Returns details for a merchandise style identified by style reference.
httpGET /mpd/items/<style_ref>/impact-matrix/ and GET /api/mpd/items/<style_ref>/impact-matrix/Returns impact-matrix information for a merchandise style.
httpPOST /mpd/decision/ and POST /api/mpd/decision/Records a single merchandise decision.
httpPOST /mpd/decision/bulk/ and POST /api/mpd/decision/bulk/Records bulk merchandise decisions.
httpPOST /mpd/decision/bulk/preview/ and POST /api/mpd/decision/bulk/preview/Previews the result of a bulk merchandise decision before submission.
httpGET /mpd/decision/status/ and GET /api/mpd/decision/status/Returns merchandise decision status information.
httpGET /mpd/meta/ and GET /api/mpd/meta/Returns MPD metadata and configured decision information.
httpGET /api/briefing/ and GET /briefing/Returns the briefing dashboard.
httpGET /api/briefing/scan/ and GET /briefing/scan/Runs or retrieves briefing scan output.
httpGET /api/briefing/sync/ and GET /briefing/sync/Runs or retrieves briefing snapshot synchronization.
httpGET /api/briefing/feed/<id>/ and GET /briefing/feed/<id>/Returns a briefing feed item.
httpGET /api/briefing/approvals/<id>/ and GET /briefing/approvals/<id>/Returns an approval record or approval details.
httpPOST /api/briefing/approvals/<id>/approve/ and POST /briefing/approvals/<id>/approve/Approves a briefing action.
httpPOST /api/briefing/approvals/<id>/reject/ and POST /briefing/approvals/<id>/reject/Rejects a briefing action.
othermerchmix_notify gRPC publisherVendored notification-service client and generated protobuf/gRPC stubs for publishing configured domain events.
7
RouteNamePurpose
/Service homeShows service status and links to MPD and briefing sections.
/health/Health checkReports that the MPD and briefing service is running.
/api/briefing/Briefing dashboardPresents the daily merchandise briefing and its feed.
/mpd/items/MPD item listProvides the merchandise styles available for performance review.
/mpd/items/<style_ref>/MPD item detailShows details for one style.
/mpd/items/<style_ref>/impact-matrix/Impact matrixShows the commercial impact information used for a style decision.
/admin/Django administrationProvides the framework administration interface.
8
EntityOwnershipDescription
MpdDecisionownsRecorded merchandise performance decisions and their status for styles or decision scopes.
StylereadsMerchandise style records used as the primary MPD item dimension.
FinalStylereadsTime- or scope-specific style performance records used to select the latest MPD data and decision context.
Daily briefing snapshotownsTenant-specific daily SKU metrics including stock, sales, forecast, rate of sale, weeks of cover, pricing, suppliers, risk flags, exceptions, revenue at risk, and recommended actions.
FeedItemownsGenerated briefing cards or feed entries for product, market, and change observations.
ApprovalwritesBriefing action review records addressed by approval detail, approve, and reject routes.
Competitor product weekly snapshotreadsExternal analytical competitor price observations grouped by category and subcategory.
Competitor scraped product and websitereadsCompetitor product classification and website identity used in price rollups.
10
NameKindRelationshipCriticality
PostgreSQL application databasedatabasedepends_oncritical
Analytical/shared synchronization PostgreSQL databasedatabasereadscritical
Redisdatabaseusessupporting
Notification serviceinternal servicepublishesoptional
Django REST Frameworklibraryusescritical
Djangolibraryusescritical
Pandaslibraryusesrequired
Gunicornlibraryusesrequired
Azure Container Appsotherusessupporting
Google Cloud Runotherusessupporting
Python 3.12Django 5.2Django REST FrameworkPostgreSQLDjango ORMDirect PostgreSQL SQL and COPY ingestionRedis and django-redisPandasgRPC and Protocol BuffersGunicornDockerAzure Container AppsGoogle Cloud RunWhiteNoisedjango-cors-headers
8
  • The supplied source excerpt truncates mpd/services.py and does not include the MPD models, serializers, views, or briefing views, so exact request and response schemas cannot be established.
  • The repository exposes no GraphQL, queue consumer, CLI, or webhook contract in the supplied endpoint evidence.
  • NATS is reported by the scanner as messaging infrastructure, but no NATS client or concrete publish/consume code is shown in the supplied source; it should not be assumed to be an active integration.
  • Notification publishing is present as vendored infrastructure, but the supplied evidence does not prove which briefing events are actually emitted at runtime.
  • Competitor benchmarking code is implemented, but no dedicated competitor HTTP route is shown; it appears to be an internal service used by briefing generation or downstream context building.
  • Authentication and authorization behavior is not established by the supplied routes. Django authentication middleware is enabled, but no explicit API authentication policy is shown.
  • The dependency manifests omit pandas even though briefing services import it, which may cause deployment or runtime issues unless it is supplied transitively or through the actual build environment.
  • The repository contains both Azure and Google Cloud deployment configurations; the active production target cannot be determined from the source alone.

Use this repository for MPD item analysis and decisions, daily merchandise exception briefings, briefing feed review, and approval workflows.

  • For style-level analysis, start with the MPD items endpoint, then retrieve the item impact matrix and decision status before proposing or recording an action.
  • Use only the defined action categories when creating decisions: none, permanent markdown, price increase, promotion, or repricing.
  • For briefing analysis, treat weeks of cover, demand variance, exception count, revenue at risk, and recommended action as the primary signals.
  • Include the tenant context expected by the service, especially the X-Tenant-Client-Id header, when calling tenant-specific endpoints.
  • Use bulk decision preview before submitting bulk decisions where possible.
  • Do not assume that a briefing recommendation has been executed merely because it appears in the feed; use the approval endpoints and decision status to verify its state.
  • Do not treat competitor benchmarking as a standalone public API unless the deployed views expose an additional route not present in the supplied routing evidence.
  • Avoid relying on undocumented response shapes; inspect serializers and views in the repository before automating against fields not listed here.