Skip to content
vp.Ven Petrov
WorkAI demoWritingResourcesResume / CVAboutAt a glance
Inside the financial lab

What actually runs when you press refresh?

I wanted a reader to be able to question a number and follow it back to the report. That shaped the implementation: keep the source with the data, calculate in Python, and let the interface show both the result and how it was reached.

Report explorer The original income bridge

Follow one number through the system

Page 17 of the report lists fourth-quarter net sales of 13,336 USD million for 2025 and 13,153 for 2024. The local dataset keeps those two values together with their unit, period and source reference.

Python calculates 13,336 − 13,153 = +183. FastAPI returns that result as JSON, and React draws the net-sales bar. Six other contributions bring the total change in operating income to +86 USD million.

That explains where the movement comes from arithmetically. Explaining why the business changed is a separate task, using the company’s commentary and keeping it attributed to the report.

Five decisions behind that simple chart

  1. Start with reviewed source data

    The figures come from the public Novartis report. Selected tables were transcribed into JSON and checked against the report. Each fact retains its period, unit, accounting basis and source page. This version does not automatically extract or understand an arbitrary PDF.

  2. Validate and calculate in Python

    The backend checks the shape and meaning of the input, including expense signs, compatible periods and complete financial lines. Ordinary Python arithmetic produces the changes, margins, shares and reconciliation checks. An LLM does not calculate these numbers.

  3. Expose the calculation through FastAPI

    backend/app.py defines the HTTP routes. GET /api/review builds the focused quarterly review; GET /api/report builds the wider explorer dataset. These routes call the Python functions on the server and return JSON.

  4. Let the interface ask different questions

    The React page displays the returned dataset as charts and tables. Period changes, product sorting and source searches happen in the browser. Refreshing makes a new request to the Python service. The page labels whether it is showing that response or a saved calculation.

  5. Try inputs that should fail

    The test suite changes signs, periods, units and totals on purpose. A test passes when the calculation rejects the bad input. Saved-output checks also compare a fresh calculation with the version shipped in the site. These tests check this dataset and its rules, not the financial accuracy of every possible document.

What runs on Vercel, and what runs in the browser?

The Next.js site serves the pages and React controls. The Python application is deployed separately within the same project as a Vercel Function, entered through api/index.py. Requests under /api/ are routed to that FastAPI application.

Changing a chart filter uses data already in the browser. Pressing refresh calls the Python service and requests a fresh calculation. Neither action asks an LLM to calculate a financial value.

This excerpt is read directly from the backend source when the site is built. FastAPI registers the URL; build_review() does the work.

@application.get("/api/review")
    def review():
        report = build_review()
        report["model"] = current_model_status()
        return report

The service’s interactive API documentation lets you inspect the routes and responses. The calculation pipeline and tests check the financial response before it reaches the chart.

A chart can add up and still be wrong.

If both years’ operating-income totals are wrong by the same amount, the error cancels out when you subtract them. Checking only the change would miss it. Both original income statements must also reconcile.

    income, sales = by_id["operating_income"], by_id["net_sales"]
    delta = income["current"] - income["prior"]
    residual = delta - sum(c["delta"] for c in contributions)
    # Reject an offsetting error that reconciles deltas but breaks both P&L totals.
    for period in ("prior", "current"):
        if sum(by_id[key][period] for key in CONTRIBUTION_IDS) != income[period]:
            raise ValueError(f"{period} income-statement total does not reconcile")
    if residual:
        raise ValueError("the income movement does not reconcile")

A test changes both totals by the same amount to make sure the validator catches exactly that problem. Another changes an expense to a positive number. The wider report applies similar checks to income, cash, balance-sheet totals and the company’s non-IFRS reconciliations.

Why keep a saved result?

The portfolio should still be readable when its Python service is unavailable. The saved JSON is a generated artifact from the same code, with source identifiers and validation results. It is a fallback, not evidence that a request ran successfully. That is why the mode stays visible.

Where AI helped, and where it is being tested

I used Codex to help build this example and independent agents to check its figures and claims. The source choices, expense signs, reconciliation rules and displayed results are the parts I need to review. Generating the code does not settle those decisions.

This explorer uses ordinary code for the calculations and fixed text for its brief. In the separate Finance evidence desk, I tested whether a second AI agent improves a generated explanation. That page shows recorded model responses and measured results. Keeping the two flows separate makes it possible to inspect the arithmetic before judging the writing.

Inspect or run it yourself

Python source, data and tests Live report response

The source package includes setup instructions and pinned dependencies. The public site runs the Python service as a Vercel Function. For local development, the same application can run with Uvicorn. The data comes from the published report.

Ven PetrovSoftware engineer · Barcelona
GitHub ↗LinkedIn ↗Email ↗

Find a project or a note

18 results

Transfutur ERP · ExperienceERP for transport and logisticsAs the sole engineer, I built an ERP from zero for transport and logistics. It supported roughly €5–6 million in annual invoicing across two offices, and I kept it running for about a year.Finance evidence desk · Project storyCan an AI reviewer improve a financial explanation?A finance review needs the right explanation as well as the right numbers. I tested one AI analyst, an added reviewer and self-review on the same public report. The added review produced fewer supported answers.Financial review lab · Project storyWhat contributed to an $86 million rise in operating income?I built a financial-report explorer around a question I could check: how did seven income-statement movements add up to an $86 million increase? The same source now supports comparisons of sales, cash flow and reported versus core results.MNQ time-series research · ExperimentA time-series model that failed on later dataA model gained about $2,351 in the research simulation, then lost about $1,728 in three later windows. I followed the experiment from data acquisition and time intervals to costs, evaluation and the decision to reject it for trading.Crude-oil narrative tracker · Project storyFollowing crude-oil news without losing the market numbersI used a short personal experiment to follow global events alongside crude-oil prices and position values. The prototype calculates the numbers before asking Claude Code for an assessment and keeps a limited recent history.NQ/MNQ backtest engine · Technical noteYesterday’s short was blocking today’s trades in the simulatorWhen input stopped before the scheduled close, the strategy forgot a position but a shared counter kept counting it. Closing the old position before resetting the day restored the trade record and released the block.Small-cap edge research · Project storyWhat would make a small-cap price pattern worth testing?I built a Python and DuckDB prototype to turn trading ideas into named tests, compare their costs and revisit them in later periods. The candidates deteriorated under further checks, and the source exposed a misleading pass flag.Gadgeon Europe applications · ExperienceConnected-device dashboards and mobile apps at Gadgeon EuropeThe dashboards let people monitor energy use and control connected devices through data from several APIs. My work covered customized Ionic and Angular apps, integrations, store releases and maintenance.ctxforge · Project storyctxforge: turn “add search” into a task an agent can build“Add search” leaves decisions about data, matching and behavior unanswered. I built an editable toolkit that asks an LLM to uncover those requirements and show its assumptions before a coding agent starts.Sociedades Inactivas enquiries · Technical noteAn enquiry should survive a failed emailA failed notification should not make someone submit the same enquiry twice. The implemented form keeps the saved request and its reference while email delivery is retried; live activation is still pending.Astro local-services website · Project storyKeeping local service pages and their FAQs consistentA city page should only offer services enabled for that location. I used shared Astro templates with explicit availability rules, and one FAQ selection for both the visible page and its structured data.3D Spaces website migration · Project storyMoving 3D Spaces without moving its mailboxThe website could move to Next.js and Vercel, while email still depended on the old host. I carried over the pages, enquiry flow and analytics, then checked what the cutover had actually preserved.Capture CRM · Project storySave the listing now, connect the person when the details arriveA classified listing may arrive before its phone number or contact name. Capture CRM keeps those records separate, then lets a later capture complete the existing listing and bring contact status back to the browsing page.Product-description comparison bench · ExperimentWhere did the product description get that detail wrong?A product description can go wrong when the image is read or when the copy is written. This local bench exposes both steps, lets me switch models and records request measurements. A matched quality comparison is still unfinished.Between Us · Project storyBetween Us: keeping control of a generated filmA more emotional dialogue take still needed convincing acting and framing. I kept the alternatives, widened shots to reveal gestures and changed the workflow when its studio limited the films I wanted to make.Restaurant-service voice agent · ExperimentDesigning a restaurant-service call around the real offerThe first correction was the offer: a paid service had become a free visit in one draft. I then compared how the Spanish voice-agent prompts handled new speakers, technical limits and booking results.Vapi and Telnyx voice integration · Technical noteThe Vapi agent could speak, but it could not hear me clearlyI could hear the assistant, but it could not understand my distorted audio. Three codec tests changed the connection behavior and brought the greeting back; the caller-audio problem remains unresolved.Warloop: Echoes of Solmara · Project storyWarloop: turning generated character art into a playable prototypeGood-looking character images became tiny figures, a backwards walk and misplaced bosses in the game. I worked through the gap between generated art and playable behavior.
esc to close · Tab to move through results