<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Stephany Alves</title>
    <description>The latest articles on DEV Community by Stephany Alves (@stephanyalves).</description>
    <link>https://dev.to/stephanyalves</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4234439%2F81092d88-fec4-4b8b-84c7-ac0a148c2944.jpeg</url>
      <title>DEV Community: Stephany Alves</title>
      <link>https://dev.to/stephanyalves</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stephanyalves"/>
    <language>en</language>
    <item>
      <title>I automated the monthly market brief I always wanted as an aerospace buyer.</title>
      <dc:creator>Stephany Alves</dc:creator>
      <pubDate>Wed, 11 Nov 2026 13:30:00 +0000</pubDate>
      <link>https://dev.to/stephanyalves/i-automated-the-monthly-market-brief-i-always-wanted-as-an-aerospace-buyer-28hh</link>
      <guid>https://dev.to/stephanyalves/i-automated-the-monthly-market-brief-i-always-wanted-as-an-aerospace-buyer-28hh</guid>
      <description>&lt;p&gt;I spent four years buying aircraft parts, from propulsion components to avionics. Often, there was only one supplier to turn to, and I’d find out about a price increase when it landed in my inbox.&lt;/p&gt;

&lt;p&gt;Every month I had the same three questions before a negotiation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is demand for these parts going up or down?&lt;/li&gt;
&lt;li&gt;Are supplier prices moving, and how fast?&lt;/li&gt;
&lt;li&gt;What is the exchange rate doing to my import cost?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The answers exist, all of them public and free. They are just spread across three government sources that update on different days, in different formats, in two languages. So I built a pipeline that collects them, does the math and writes the one-page brief I wanted back then. It runs by itself on the 16th of every month.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/stephanyalves-eng/procurement-market-briefs" rel="noopener noreferrer"&gt;stephanyalves-eng/procurement-market-briefs&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What it produces
&lt;/h2&gt;

&lt;p&gt;Every edition has six one-page reports, each in English and Brazilian Portuguese, as HTML, PDF and PNG:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Report&lt;/th&gt;
&lt;th&gt;Data&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Aerospace Supply Market Brief&lt;/td&gt;
&lt;td&gt;Public: Comex Stat, BLS PPI, Banco Central PTAX&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Brazil EV Supply Chain Brief&lt;/td&gt;
&lt;td&gt;Public: Comex Stat, import duty schedule&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Monthly Procurement Performance Report&lt;/td&gt;
&lt;td&gt;Synthetic buyer, indexed to public prices and FX&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Monthly Supplier Quality Report&lt;/td&gt;
&lt;td&gt;Synthetic EV plant&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Six Sigma Supplier Quality Report&lt;/td&gt;
&lt;td&gt;Synthetic EV plant&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supplier Non-Conformance Report&lt;/td&gt;
&lt;td&gt;Synthetic EV plant&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The synthetic ones are labeled as synthetic on the page and in the README. More on how they are built below, because that part turned out to be the most interesting problem.&lt;/p&gt;

&lt;p&gt;Each page answers one sourcing question and ends with actions. The November edition opened with: aircraft parts imports up 11.1%, avionics producer prices up 17.2%, and a sharp BRL selloff raising import costs. A buyer can read that in ten seconds and walk into a meeting with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;The flow has four steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fetch.&lt;/strong&gt; &lt;code&gt;pipeline/fetch_public.py&lt;/code&gt; downloads PTAX and IPCA from the Banco Central do Brasil, producer price indexes from the U.S. Bureau of Labor Statistics and import statistics by NCM code from Comex Stat.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extend the synthetic data.&lt;/strong&gt; &lt;code&gt;pipeline/synthetic.py&lt;/code&gt; appends the new month to a fictitious buyer's purchase orders, RFQs and quality notifications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build.&lt;/strong&gt; One Python module per report computes the metrics, draws the charts with matplotlib and writes the text. Playwright renders each page to an A4 PDF.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Publish.&lt;/strong&gt; A GitHub Actions workflow commits the new edition and attaches it as an artifact.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Three decisions made the difference between a script that works once and a pipeline that runs every month without me.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The schedule follows the data, not the calendar
&lt;/h3&gt;

&lt;p&gt;The first instinct is to run on the 1st. That would publish stale numbers, because the sources release on different days. Comex Stat publishes the previous month early in the month, and the BLS releases the PPI around mid-month. So the workflow runs on the 16th, after both are out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;schedule&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# 16th of every month, 11:23 UTC (08:23 in Brasília)
&lt;/span&gt;    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cron&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"23 11 16 * *"&lt;/span&gt;
  &lt;span class="na"&gt;workflow_dispatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Comex Stat API only accepts a few requests per minute, so the client waits between calls and backs off on errors. That is why the job has a 90 minute timeout: the download alone takes 10 to 30 minutes.&lt;/p&gt;

&lt;p&gt;Every source also fails soft. If one API is down, the pipeline keeps the last file it has, finishes the edition and records the problem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;SOURCES&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="no"&gt;SOURCES&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;failed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"WARNING {name} failed, keeping the previous file: {e}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The page then states how far each source goes, so a reader never mistakes old data for new data. In procurement, a brief that silently shows last month's exchange rate is worse than no brief.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The headline is computed, not written
&lt;/h3&gt;

&lt;p&gt;This is the part I like most. A monthly report with a fixed sentence like "prices increased" is wrong the first month prices fall. So every headline, highlight and action is built from the numbers and changes wording when the data changes direction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;up&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"g"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;h1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Aircraft parts demand {'up' if up else 'down'} {abs(g):.1f}% "&lt;/span&gt; \
     &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"and avionics prices {'up' if av &amp;gt;= 0 else 'down'} {abs(av):.1f}%"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;fx_event&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;fx_event&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"chg"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;h2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;", while a sharp BRL selloff raises import costs"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"vs"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;h2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;", with the BRL still {abs(k['vs']):.0f}% stronger than a year ago"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"vs"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;h2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;", and a BRL {k['vs']:.0f}% weaker than a year ago adds to import costs"&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;h2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;", with the BRL back near last year's level"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Simplified from &lt;code&gt;briefs/aerospace.py&lt;/code&gt;, which also builds the Portuguese version in the same step.)&lt;/p&gt;

&lt;p&gt;The same idea handles layout. Long text would push a page past one A4 sheet, so &lt;code&gt;render_fit&lt;/code&gt; renders the page, measures its height and tightens spacing step by step until it fits in 1123 px. The edition manifest records which level each page needed, which tells me when a text should be edited instead of squeezed.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Synthetic data that cannot see the future
&lt;/h3&gt;

&lt;p&gt;Real purchase order data is confidential, so the procurement and quality reports run on a fictitious company. The hard part was not generating fake rows. It was making a dataset that behaves like a real ERP export month after month.&lt;/p&gt;

&lt;p&gt;A real buyer looking at open orders on October 31 does not know which ones will arrive late in November. If the generator just created each month's data fresh, late deliveries would appear out of nowhere and the trend lines would jump.&lt;/p&gt;

&lt;p&gt;So the dataset has two layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Truth tables&lt;/strong&gt; hold every record with its real future dates: when an order will actually arrive, when a quality notification will actually close.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The view&lt;/strong&gt; is what a buyer would see on the cutoff date. Future receipts stay blank and open notifications stay open.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cutoff&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Tables as a buyer would see them on the cutoff date."""&lt;/span&gt;
    &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cutoff&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isoformat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="no"&gt;P&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;P&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;P&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data_pedido&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="no"&gt;P&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"data_recebimento"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;P&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;receb_real&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;P&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;receb_real&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two more rules keep it honest over time. Each new month is generated with a random seed derived from its own dates, so any edition can be rebuilt exactly. And extending the data only appends days after the last generated date; it never rewrites a past record. October's report does not change because November was generated.&lt;/p&gt;

&lt;p&gt;Prices in the synthetic orders are not random either. Each part category is indexed to the real BLS PPI series for its industry, and the currency conversion uses the real monthly PTAX. The company is fake, but its costs move with the real market.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I built it
&lt;/h2&gt;

&lt;p&gt;I developed this with AI pair programming (Claude). The split matters, so here it is plainly: the business questions, the choice of sources and metrics, the data logic (including the truth and view design for the synthetic data) and the review of every number are mine. The AI wrote much of the code with me and sped up the parts I am still learning.&lt;/p&gt;

&lt;p&gt;For someone coming from procurement into data, that is the honest way to work: I know which question a buyer needs answered and how to check that the answer is right, and the AI closes the gap between that and running code.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would do differently
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Headline templates grow fast.&lt;/strong&gt; Every new condition multiplies the branches I have to keep consistent in two languages. A small rules table would scale better than nested &lt;code&gt;if&lt;/code&gt; statements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One run a month hides problems.&lt;/strong&gt; A dry run a few days before the 16th, with &lt;code&gt;--skip-fetch&lt;/code&gt;, would catch layout or data issues before the real edition.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monthly data is the ceiling.&lt;/strong&gt; The PTAX is daily, but Comex Stat and the PPI are monthly, so the brief cannot react faster than its slowest source.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install -r requirements.txt
python -m playwright install chromium
python run_edition.py --skip-fetch   &lt;span class="c"&gt;# rebuild from the data in the repo&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will want a free &lt;code&gt;BLS_API_KEY&lt;/code&gt; for fresh downloads, since anonymous BLS requests have a low daily limit.&lt;/p&gt;

&lt;p&gt;If you work in procurement, supply chain or data, what’s one question you find yourself answering by hand every month? I’d love to hear about it in the comments. And if you’ve had a look at the code, I’d appreciate your thoughts, especially on how the synthetic data is put together.&lt;/p&gt;

</description>
      <category>python</category>
      <category>datascience</category>
      <category>automation</category>
      <category>githubactions</category>
    </item>
  </channel>
</rss>
