# adipthadissanayake/used_car_price_prediction_system architecture

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

- Interactive diagram: https://gitdiagram.com/adipthadissanayake/used_car_price_prediction_system
- Repository: https://github.com/adipthadissanayake/used_car_price_prediction_system

## Overview

This is an end-to-end used-car valuation product: vehicle details enter through a web interface, are validated and passed to a prediction service, and return as a price estimate with a confidence interval and interpretability insights. Authenticated users can also save and manage valuation history. A separate model-development workflow cleans and transforms data, trains and tunes regressors, compares candidates, and exports the champion model used by inference. Several links reflect README documentation or the SOURCE INDEX; unsampled implementation details are not inferred.

Main entry points: [`data/processed`](https://github.com/adipthadissanayake/used_car_price_prediction_system/tree/main/data/processed) (Train/test datasets), [`backend/main.py`](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/main.py) (REST API), [`preprocessing/preprocessing.py`](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/preprocessing/preprocessing.py) (Feature transformation), [`backend/service.py`](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/service.py) (Prediction service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Valuation interface"]
  node_frontend["Web interface<br/>[app.js]"]
end

subgraph group_api["API and accounts"]
  node_api_server["REST API<br/>[main.py]"]
  node_validation["Payload validation<br/>[schemas.py]"]
  node_auth["JWT authentication<br/>[auth.py]"]
  node_db[("User and history store<br/>[database.py]")]
end

subgraph group_inference["Prediction runtime"]
  node_service["Prediction service<br/>[service.py]"]
end

subgraph group_ml["Model development"]
  node_linear["Linear regression"]
  node_tree["Decision tree<br/>[decision_tree.py]"]
  node_forest["Random forest<br/>[random_forest.py]"]
  node_boosting["Gradient boosting"]
  node_tuning["Hyperparameter tuning<br/>[tuning.py]"]
  node_comparison["Model evaluation"]
  node_model_artifacts["Model artifacts"]
end

subgraph group_data["Data preparation"]
  node_preprocessor["Feature transformation<br/>[preprocessing.py]"]
  node_raw_data["Raw vehicle dataset<br/>[used_cars.csv]"]
  node_processed_data["Train/test datasets"]
  node_preprocess_artifact["Fitted preprocessor"]
end

node_user(("Valuation user"))

node_user -->|"enters vehicle details"| node_frontend
node_frontend -->|"requests valuation"| node_api_server
node_api_server -->|"validates payload"| node_validation
node_api_server -->|"verifies tokens"| node_auth
node_api_server -->|"requests inference"| node_service
node_api_server -->|"records and retrieves history"| node_db
node_service -->|"uses feature logic"| node_preprocessor
node_raw_data -->|"provides source data"| node_preprocessor
node_preprocessor -->|"exports splits"| node_processed_data
node_preprocessor -->|"saves fitted state"| node_preprocess_artifact
node_processed_data -->|"trains and evaluates"| node_linear
node_processed_data -->|"trains and evaluates"| node_tree
node_processed_data -->|"trains and evaluates"| node_forest
node_processed_data -->|"trains and evaluates"| node_boosting
node_processed_data -->|"supplies experiments"| node_tuning
node_processed_data -->|"supplies evaluation"| node_comparison
node_comparison -->|"exports champion"| node_model_artifacts
node_model_artifacts -->|"loads champion model"| node_service
node_preprocess_artifact -->|"loads preprocessing state"| node_service

click node_frontend "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/frontend/app.js"
click node_api_server "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/main.py"
click node_validation "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/schemas.py"
click node_auth "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/auth.py"
click node_db "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/database.py"
click node_service "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/service.py"
click node_preprocessor "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/preprocessing/preprocessing.py"
click node_raw_data "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/data/raw/used_cars.csv"
click node_processed_data "https://github.com/adipthadissanayake/used_car_price_prediction_system/tree/main/data/processed"
click node_linear "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/models/linear_regression.py"
click node_tree "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/models/decision_tree.py"
click node_forest "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/models/random_forest.py"
click node_boosting "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/models/gradient_boosting.py"
click node_tuning "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/tuning/tuning.py"
click node_comparison "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/evaluation/model_comparison.py"
click node_model_artifacts "https://github.com/adipthadissanayake/used_car_price_prediction_system/tree/main/artifacts/models"
click node_preprocess_artifact "https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/artifacts/preprocessing/preprocessor.joblib"

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_frontend,node_user toneBlue
class node_api_server,node_validation,node_auth,node_db toneAmber
class node_service toneMint
class node_linear,node_tree,node_forest,node_boosting,node_tuning,node_comparison,node_model_artifacts toneRose
class node_preprocessor,node_raw_data,node_processed_data,node_preprocess_artifact toneIndigo
```

## Components

### Valuation interface

- [Web interface](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/frontend/app.js): `frontend/app.js`

### API and accounts

- [REST API](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/main.py): `backend/main.py`
- [Payload validation](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/schemas.py): `backend/schemas.py`
- [JWT authentication](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/auth.py): `backend/auth.py`
- [User and history store](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/database.py): `backend/database.py`

### Prediction runtime

- [Prediction service](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/backend/service.py): `backend/service.py`

### Model development

- [Linear regression](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/models/linear_regression.py): `models/linear_regression.py`
- [Decision tree](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/models/decision_tree.py): `models/decision_tree.py`
- [Random forest](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/models/random_forest.py): `models/random_forest.py`
- [Gradient boosting](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/models/gradient_boosting.py): `models/gradient_boosting.py`
- [Hyperparameter tuning](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/tuning/tuning.py): `tuning/tuning.py`
- [Model evaluation](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/evaluation/model_comparison.py): `evaluation/model_comparison.py`
- [Model artifacts](https://github.com/adipthadissanayake/used_car_price_prediction_system/tree/main/artifacts/models): `artifacts/models`

### Data preparation

- [Feature transformation](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/preprocessing/preprocessing.py): `preprocessing/preprocessing.py`
- [Raw vehicle dataset](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/data/raw/used_cars.csv): `data/raw/used_cars.csv`
- [Train/test datasets](https://github.com/adipthadissanayake/used_car_price_prediction_system/tree/main/data/processed): `data/processed`
- [Fitted preprocessor](https://github.com/adipthadissanayake/used_car_price_prediction_system/blob/main/artifacts/preprocessing/preprocessor.joblib): `artifacts/preprocessing/preprocessor.joblib`

### Other components

- **Valuation user**

## Connections

- Valuation user → Web interface: enters vehicle details (evidence: `README.md`)
- Web interface → REST API: requests valuation (evidence: `README.md`)
- REST API → Payload validation: validates payload (evidence: `backend/main.py`)
- REST API → JWT authentication: verifies tokens (evidence: `backend/main.py`)
- REST API → Prediction service: requests inference (evidence: `backend/main.py`)
- REST API → User and history store: records and retrieves history (evidence: `backend/main.py`)
- Prediction service → Feature transformation: uses feature logic (evidence: `backend/service.py`)
- Raw vehicle dataset → Feature transformation: provides source data (evidence: `README.md`)
- Feature transformation → Train/test datasets: exports splits (evidence: `README.md`)
- Feature transformation → Fitted preprocessor: saves fitted state (evidence: `README.md`)
- Train/test datasets → Linear regression: trains and evaluates (evidence: `README.md`)
- Train/test datasets → Decision tree: trains and evaluates (evidence: `README.md`)
- Train/test datasets → Random forest: trains and evaluates (evidence: `README.md`)
- Train/test datasets → Gradient boosting: trains and evaluates (evidence: `README.md`)
- Train/test datasets → Hyperparameter tuning: supplies experiments (evidence: `README.md`)
- Train/test datasets → Model evaluation: supplies evaluation (evidence: `README.md`)
- Model evaluation → Model artifacts: exports champion (evidence: `evaluation/model_comparison.py`)
- Model artifacts → Prediction service: loads champion model (evidence: `README.md`)
- Fitted preprocessor → Prediction service: loads preprocessing state (evidence: `README.md`)
