# vigneshwarr3/car_price_predictor architecture

> Architecture diagram of the GitHub repository vigneshwarr3/car_price_predictor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vigneshwarr3/car_price_predictor
- Repository: https://github.com/vigneshwarr3/car_price_predictor

## Overview

##### Project Type and Purpose
- This is a full-stack ML application that:
- Scrapes and stores raw data
- Cleans and analyzes that data
- Trains multiple regression models and picks the best one
- Exposes predictions via a FastAPI backend
- Presents a user-friendly Streamlit frontend
- Is containerized with Docker and deployed on a private server

##### File Structure
- Top-level ML components (Codes/ notebooks):
- scrapeCarData.ipynb → data collection (Selenium + BeautifulSoup)
- clean.ipynb → data preprocessing (Pandas)
- EDA.ipynb → exploratory analysis (Matplotlib/Seaborn)
- testing_models.ipynb → model evaluation (scikit-learn)
- Data folder: raw and intermediate files (all_urls.txt, car_data.zip, columns.txt, etc.)
- API layer: api.py (FastAPI with key/token auth)
- Frontend: Home.py plus pages/1_EDA.py, 2_Model Comparison.py, 3_Predict Price.py (Streamlit multipage)
- Deployment: Dockerfile, requirements.txt

##### README for Additional Insights
- The README confirms the ML pipeline stages, tech stack (Selenium, BeautifulSoup, Pandas, scikit-learn, FastAPI, Streamlit, Docker), and deployment target (private server).

##### Main Components & Interactions
a. Data Acquisition
- External Service: Carvana website
- Scraper Service: Selenium + BeautifulSoup
- Raw Data Store: local files (data/*.txt, data/car_data.zip)
b. Data Processing
- Cleaning Pipeline: Pandas (Codes/clean.ipynb)
- Clean Data Store: processed CSV/Parquet (you may bundle under “Processed Data”)
c. Model Training & Selection
- EDA & Feature Engineering (Codes/EDA.ipynb)
- Model Evaluation (testing_models.ipynb)
- Model Artifact: serialized best model (pickle/joblib)
d. Backend API
- FastAPI app (api.py)
- Authentication layer (API key / token)
- Endpoints:
– GET /vehicles → fetch cleaned data
– POST /predict → return price prediction
- Containerization: Dockerfile
e. Frontend Interface
- Streamlit app (Home.py + pages/*.py)
- Pages for EDA, Model Comparison, Price Prediction
- Consumes FastAPI endpoints

##### Architectural Patterns & Design Principles
- Separation of concerns: scraper, ETL, model training, API, UI all decoupled
- Pipeline pattern for ML: data ingestion → preprocessing → training → serving
- Micro-service style for prediction API
- Containerization to ensure environment consistency

##### Essential Elements
- Names & labels for each component (e.g., “Model Trainer (scikit-learn)”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Tier 1: Data Ingestion & Storage
    subgraph "Tier 1: Data Ingestion & Storage"
        Carvana["Carvana Website"]:::external
        Scraper["Scraper Service\n(Selenium + BeautifulSoup)"]:::compute
        RawData["Raw Data Store\n(data/)"]:::data
    end

    %% Tier 2: ML Pipeline
    subgraph "Tier 2: ML Pipeline"
        Cleaning["Cleaning Pipeline\n(Pandas)"]:::compute
        ProcessedData["Processed Data Store\n(csv/parquet)"]:::data
        EDA["EDA & Feature Engineering\n(Matplotlib/Seaborn)"]:::compute
        ModelEval["Model Evaluation\n(scikit-learn)"]:::compute
        ModelArtifact["Model Artifact\n(pickle)"]:::data
    end

    %% Tier 3: Serving (API)
    subgraph "Tier 3: Serving (API)"
        Docker["Container Boundary\n(Dockerfile)"]:::api
        API["API Service\n(FastAPI)"]:::api
    end

    %% Tier 4: Presentation (Streamlit)
    subgraph "Tier 4: Presentation (Streamlit)"
        Home["UI Launcher\n(Streamlit)"]:::ui
        Page1["1_EDA Page"]:::ui
        Page2["2_Model Comparison Page"]:::ui
        Page3["3_Predict Price Page"]:::ui
    end

    %% Data & Process Flows
    Carvana -->|"HTML"| Scraper
    Scraper -->|"raw files (txt/zip)"| RawData
    RawData -->|"CSV"| Cleaning
    Cleaning -->|"processed CSV"| ProcessedData
    ProcessedData -->|"data for analysis"| EDA
    EDA -->|"features"| ModelEval
    ModelEval -->|"best model"| ModelArtifact
    ModelArtifact -->|"loaded by"| API

    %% API to UI Flows
    API -->|"HTTP JSON"| Home
    Home -->|"GET /vehicles"| API
    Page1 -->|"GET /vehicles"| API
    Page2 -->|"GET /vehicles"| API
    Page3 -->|"POST /predict"| API

    %% Documentation & Dependencies
    Doc["Documentation\n(Readme.md)"]:::external
    Req["Requirements\n(requirements.txt)"]:::external

    %% Relationships for Docs
    Doc -.->|"""project overview"""| Carvana
    Req -.->|"""env setup"""| Docker

    %% Click Events
    click Scraper "https://github.com/vigneshwarr3/car_price_predictor/blob/main/Codes/scrapeCarData.ipynb"
    click RawData "https://github.com/vigneshwarr3/car_price_predictor/tree/main/data/"
    click Cleaning "https://github.com/vigneshwarr3/car_price_predictor/blob/main/Codes/clean.ipynb"
    click EDA "https://github.com/vigneshwarr3/car_price_predictor/blob/main/Codes/EDA.ipynb"
    click ModelEval "https://github.com/vigneshwarr3/car_price_predictor/blob/main/Codes/testing_models.ipynb"
    click API "https://github.com/vigneshwarr3/car_price_predictor/blob/main/api.py"
    click Docker "https://github.com/vigneshwarr3/car_price_predictor/tree/main/Dockerfile"
    click Home "https://github.com/vigneshwarr3/car_price_predictor/blob/main/Home.py"
    click Page1 "https://github.com/vigneshwarr3/car_price_predictor/blob/main/pages/1_EDA.py"
    click Page2 "https://github.com/vigneshwarr3/car_price_predictor/blob/main/pages/2_Model Comparison.py"
    click Page3 "https://github.com/vigneshwarr3/car_price_predictor/blob/main/pages/3_Predict Price.py"
    click Req "https://github.com/vigneshwarr3/car_price_predictor/blob/main/requirements.txt"
    click Doc "https://github.com/vigneshwarr3/car_price_predictor/blob/main/Readme.md"

    %% Styles
    classDef data fill:lightgreen,stroke:#333,stroke-width:1px
    classDef compute fill:lightblue,stroke:#333,stroke-width:1px
    classDef api fill:orange,stroke:#333,stroke-width:1px
    classDef ui fill:plum,stroke:#333,stroke-width:1px
    classDef external fill:lightgray,stroke:#333,stroke-width:1px
```
