# stefen-taime/car-price-predictor architecture

> Architecture diagram of the GitHub repository stefen-taime/car-price-predictor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stefen-taime/car-price-predictor
- Repository: https://github.com/stefen-taime/car-price-predictor

## Overview

Car Price Predictor is a Streamlit application backed by a FastAPI car-record API, PostgreSQL, and an asynchronous Kafka/ML prediction loop. Users submit car details in the UI; the API validates and stores them, publishes listing events, and later receives prediction events to update records. The UI fetches records and presents metrics, filters, and charts. A separate training script builds and tracks the model from the Ford dataset; the prediction worker loads the model and preprocessing artifacts. The README documents the Debezium, Kafka, MLflow, and MinIO infrastructure; connections not visible in sampled source are identified as documented.

Main entry points: [`backend/main.py`](https://github.com/stefen-taime/car-price-predictor/blob/main/backend/main.py) (FastAPI service), [`docker-compose.yml`](https://github.com/stefen-taime/car-price-predictor/blob/main/docker-compose.yml) (Kafka topics), [`ml_service/main.py`](https://github.com/stefen-taime/car-price-predictor/blob/main/ml_service/main.py) (Prediction worker), [`streamlit_app/app.py`](https://github.com/stefen-taime/car-price-predictor/blob/main/streamlit_app/app.py) (Streamlit app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_streamlit["Streamlit app<br/>[app.py]"]
end

subgraph group_api_data["API and Data"]
  node_backend["FastAPI service<br/>[main.py]"]
  node_postgres[("PostgreSQL<br/>[init.sql]")]
end

subgraph group_prediction["Prediction Pipeline"]
  node_debezium["Debezium"]
  node_kafka["Kafka topics<br/>[docker-compose.yml]"]
  node_predictor["Prediction worker<br/>[main.py]"]
end

subgraph group_model_ops["Model Management"]
  node_training["Model training<br/>[train.py]"]
  node_dataset["Ford dataset<br/>[ford.csv]"]
  node_mlflow["MLflow tracking"]
  node_minio[("Artifact storage<br/>[docker-compose.yml]")]
end

node_user(("Car user"))

node_user -->|"enters car data"| node_streamlit
node_streamlit -->|"fetches and submits"| node_backend
node_backend -->|"reads and writes cars"| node_postgres
node_backend -->|"publishes listings"| node_kafka
node_postgres -->|"streams changes"| node_debezium
node_debezium -->|"publishes changes"| node_kafka
node_kafka -->|"delivers listing events"| node_predictor
node_predictor -->|"loads tracked model"| node_mlflow
node_predictor -->|"publishes predictions"| node_kafka
node_kafka -->|"delivers predictions"| node_backend
node_training -->|"reads training data"| node_dataset
node_training -->|"logs model and metrics"| node_mlflow
node_mlflow -->|"stores artifacts"| node_minio
node_backend -->|"returns car records"| node_streamlit

click node_streamlit "https://github.com/stefen-taime/car-price-predictor/blob/main/streamlit_app/app.py"
click node_backend "https://github.com/stefen-taime/car-price-predictor/blob/main/backend/main.py"
click node_postgres "https://github.com/stefen-taime/car-price-predictor/blob/main/postgres/init.sql"
click node_debezium "https://github.com/stefen-taime/car-price-predictor/blob/main/debezium-connector-config.json"
click node_kafka "https://github.com/stefen-taime/car-price-predictor/blob/main/docker-compose.yml"
click node_predictor "https://github.com/stefen-taime/car-price-predictor/blob/main/ml_service/main.py"
click node_training "https://github.com/stefen-taime/car-price-predictor/blob/main/ml_service/train.py"
click node_dataset "https://github.com/stefen-taime/car-price-predictor/blob/main/data/ford.csv"
click node_mlflow "https://github.com/stefen-taime/car-price-predictor/blob/main/mlflow/Dockerfile"
click node_minio "https://github.com/stefen-taime/car-price-predictor/blob/main/docker-compose.yml"

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_streamlit,node_user toneBlue
class node_backend,node_postgres toneAmber
class node_debezium,node_kafka,node_predictor toneMint
class node_training,node_dataset,node_mlflow,node_minio toneRose
```

## Components

### User Interface

- [Streamlit app](https://github.com/stefen-taime/car-price-predictor/blob/main/streamlit_app/app.py): `streamlit_app/app.py`

### API and Data

- [FastAPI service](https://github.com/stefen-taime/car-price-predictor/blob/main/backend/main.py): `backend/main.py`
- [PostgreSQL](https://github.com/stefen-taime/car-price-predictor/blob/main/postgres/init.sql): `postgres/init.sql`

### Prediction Pipeline

- [Debezium](https://github.com/stefen-taime/car-price-predictor/blob/main/debezium-connector-config.json): `debezium-connector-config.json`
- [Kafka topics](https://github.com/stefen-taime/car-price-predictor/blob/main/docker-compose.yml): `docker-compose.yml`
- [Prediction worker](https://github.com/stefen-taime/car-price-predictor/blob/main/ml_service/main.py): `ml_service/main.py`

### Model Management

- [Model training](https://github.com/stefen-taime/car-price-predictor/blob/main/ml_service/train.py): `ml_service/train.py`
- [Ford dataset](https://github.com/stefen-taime/car-price-predictor/blob/main/data/ford.csv): `data/ford.csv`
- [MLflow tracking](https://github.com/stefen-taime/car-price-predictor/blob/main/mlflow/Dockerfile): `mlflow/Dockerfile`
- [Artifact storage](https://github.com/stefen-taime/car-price-predictor/blob/main/docker-compose.yml): `docker-compose.yml`

### Other components

- **Car user**

## Connections

- Car user → Streamlit app: enters car data (evidence: `README.md`)
- Streamlit app → FastAPI service: fetches and submits (evidence: `streamlit_app/app.py`)
- FastAPI service → PostgreSQL: reads and writes cars (evidence: `backend/main.py`)
- FastAPI service → Kafka topics: publishes listings (evidence: `backend/main.py`)
- PostgreSQL → Debezium: streams changes (evidence: `README.md`)
- Debezium → Kafka topics: publishes changes (evidence: `README.md`)
- Kafka topics → Prediction worker: delivers listing events (evidence: `ml_service/main.py`)
- Prediction worker → MLflow tracking: loads tracked model (evidence: `ml_service/main.py`)
- Prediction worker → Kafka topics: publishes predictions (evidence: `ml_service/main.py`)
- Kafka topics → FastAPI service: delivers predictions (evidence: `backend/main.py`)
- Model training → Ford dataset: reads training data (evidence: `ml_service/train.py`)
- Model training → MLflow tracking: logs model and metrics (evidence: `ml_service/train.py`)
- MLflow tracking → Artifact storage: stores artifacts (evidence: `README.md`)
- FastAPI service → Streamlit app: returns car records (evidence: `streamlit_app/app.py`)
