# yash176a/pricing-engine architecture

> Architecture diagram of the GitHub repository yash176a/pricing-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yash176a/pricing-engine
- Repository: https://github.com/yash176a/pricing-engine

## Overview

This is a synthetic-market dynamic pricing engine: it generates noisy historical observations, fits a demand model, and selects prices to maximize modeled profit. Its evaluation scores the optimized policy against the market’s true demand function, then can register and promote the trained model. The serving API resolves the production model for demand predictions and price recommendations. The graph follows the sampled training, evaluation, registry, optimizer, and service code; other README capabilities are included only where documented, and no unsampled implementation details are assumed.

Main entry points: [`src/pricing_engine/train.py`](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/train.py) (Training and evaluation), [`src/pricing_engine/service.py`](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/service.py) (FastAPI service), [`src/pricing_engine/optimizer.py`](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/optimizer.py) (Price optimizer), [`eval/run_eval.py`](https://github.com/yash176a/pricing-engine/blob/main/eval/run_eval.py) (Evaluation runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market_eval["Market and evaluation"]
  node_market["Synthetic market<br/>[data.py]"]
  node_trainer["Training and evaluation<br/>[train.py]"]
  node_evaluator["Evaluation runner<br/>[run_eval.py]"]
  node_true_demand["True demand function<br/>[data.py]"]
end

subgraph group_pricing["Pricing models"]
  node_demand["Demand model<br/>[demand_model.py]"]
  node_optimizer["Price optimizer<br/>[optimizer.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_registry["Model registry"]
  node_registry["Versioned model registry<br/>[registry.py]"]
  node_model_store[("Registry files<br/>[registry.py]")]
end

subgraph group_serving["Serving interface"]
  node_cli["Command-line interface<br/>[cli.py]"]
  node_api["FastAPI service<br/>[service.py]"]
end

node_user(("Operator / API client"))

node_user -->|"runs commands"| node_cli
node_user -->|"sends requests"| node_api
node_cli -->|"runs evaluation"| node_evaluator
node_cli -->|"starts server"| node_api
node_evaluator -->|"trains and evaluates"| node_trainer
node_evaluator -->|"registers and promotes"| node_registry
node_trainer -->|"generates market"| node_market
node_trainer -->|"fits model"| node_demand
node_trainer -->|"chooses prices"| node_optimizer
node_trainer -->|"scores policies"| node_true_demand
node_market -->|"generates observations"| node_true_demand
node_optimizer -->|"queries predictions"| node_demand
node_registry -->|"persists artifacts"| node_model_store
node_api -->|"resolves and loads"| node_registry
node_api -->|"optimizes prices"| node_optimizer
node_api -->|"predicts demand"| node_demand
node_config -->|"sets training parameters"| node_trainer
node_config -->|"sets price bounds"| node_optimizer

click node_cli "https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/cli.py"
click node_market "https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/data.py"
click node_trainer "https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/train.py"
click node_evaluator "https://github.com/yash176a/pricing-engine/blob/main/eval/run_eval.py"
click node_demand "https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/demand_model.py"
click node_optimizer "https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/optimizer.py"
click node_config "https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/config.py"
click node_registry "https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/registry.py"
click node_model_store "https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/registry.py"
click node_api "https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/service.py"
click node_true_demand "https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/data.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_market,node_trainer,node_evaluator,node_true_demand,node_user toneBlue
class node_demand,node_optimizer,node_config toneAmber
class node_registry,node_model_store toneMint
class node_cli,node_api toneRose
```

## Components

### Market and evaluation

- [Synthetic market](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/data.py): `src/pricing_engine/data.py`
- [Training and evaluation](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/train.py): `src/pricing_engine/train.py`
- [Evaluation runner](https://github.com/yash176a/pricing-engine/blob/main/eval/run_eval.py): `eval/run_eval.py`
- [True demand function](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/data.py): `src/pricing_engine/data.py`

### Pricing models

- [Demand model](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/demand_model.py): `src/pricing_engine/demand_model.py`
- [Price optimizer](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/optimizer.py): `src/pricing_engine/optimizer.py`
- [Runtime settings](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/config.py): `src/pricing_engine/config.py`

### Model registry

- [Versioned model registry](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/registry.py): `src/pricing_engine/registry.py`
- [Registry files](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/registry.py): `src/pricing_engine/registry.py`

### Serving interface

- [Command-line interface](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/cli.py): `src/pricing_engine/cli.py`
- [FastAPI service](https://github.com/yash176a/pricing-engine/blob/main/src/pricing_engine/service.py): `src/pricing_engine/service.py`

### Other components

- **Operator / API client**

## Connections

- Operator / API client → Command-line interface: runs commands (evidence: `README.md`)
- Operator / API client → FastAPI service: sends requests (evidence: `README.md`)
- Command-line interface → Evaluation runner: runs evaluation (evidence: `src/pricing_engine/cli.py`)
- Command-line interface → FastAPI service: starts server (evidence: `src/pricing_engine/cli.py`)
- Evaluation runner → Training and evaluation: trains and evaluates (evidence: `eval/run_eval.py`)
- Evaluation runner → Versioned model registry: registers and promotes (evidence: `eval/run_eval.py`)
- Training and evaluation → Synthetic market: generates market (evidence: `src/pricing_engine/train.py`)
- Training and evaluation → Demand model: fits model (evidence: `src/pricing_engine/train.py`)
- Training and evaluation → Price optimizer: chooses prices (evidence: `src/pricing_engine/train.py`)
- Training and evaluation → True demand function: scores policies (evidence: `src/pricing_engine/train.py`)
- Synthetic market → True demand function: generates observations (evidence: `src/pricing_engine/data.py`)
- Price optimizer → Demand model: queries predictions (evidence: `src/pricing_engine/optimizer.py`)
- Versioned model registry → Registry files: persists artifacts (evidence: `src/pricing_engine/registry.py`)
- FastAPI service → Versioned model registry: resolves and loads (evidence: `src/pricing_engine/service.py`)
- FastAPI service → Price optimizer: optimizes prices (evidence: `src/pricing_engine/service.py`)
- FastAPI service → Demand model: predicts demand (evidence: `src/pricing_engine/service.py`)
- Runtime settings → Training and evaluation: sets training parameters (evidence: `src/pricing_engine/train.py`)
- Runtime settings → Price optimizer: sets price bounds (evidence: `src/pricing_engine/optimizer.py`)
