# rohith05196/predict_housing_price architecture

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

- Interactive diagram: https://gitdiagram.com/rohith05196/predict_housing_price
- Repository: https://github.com/rohith05196/predict_housing_price

## Overview

##### Project type and purpose
- This is a full-stack, single-service ML web application built with Flask.
- Purpose: expose a trained regression model via a web UI so users can input housing features and receive a price prediction.

##### File structure
- Top level:
- app.py – Flask application (controller + routing)
- reg_predict.pickle & scalar.pickle – serialized model & preprocessor (ML artifacts)
- HousePricing.ipynb – notebook for training/EDA (offline component)
- static/ – CSS, images, client assets
- templates/ – Jinja2 HTML views
- DockerFile & Procfile – containerization & Heroku deployment
- .github/workflows/main.yaml – CI/CD pipeline
- No external database—model files live on disk and are loaded at runtime.

##### README for additional insights
- Confirms Flask + Jinja frontend, pickled model, Docker/Heroku support.
- No mention of a database or external API dependencies.

a. Main components
1) User Browser (UI)
2) Flask Web Server (app.py)
3) Static Assets & Templates (static/, templates/)
4) ML Model Service
– Preprocessor (scalar.pickle)
– Regression Model (reg_predict.pickle)
5) Offline Training Notebook (HousePricing.ipynb)
6) CI/CD Pipeline (GitHub Actions workflow)
7) Container/Hosting (Docker image, Heroku dyno)

b. Relationships and interactions
- Browser → HTTP Request → Flask App
- Flask App loads scalar.pickle → preprocess input
- Flask App loads reg_predict.pickle → predict price
- Flask App renders output via templates to Browser
- DockerFile builds container bundling app + pickles + static/templates
- GitHub Actions triggers on push → builds Docker image → (optional) deploy to Heroku
- Notebook remains a separate offline step (train/update model → regenerate pickles)

c. Architectural patterns/design principles
- MVC‐like separation:
- Model: pickled artifacts
- View: Jinja templates + static assets
- Controller: Flask routes in app.py
- Single container microservice pattern—no external DB
- CI/CD via GitHub Actions for build & test

d. Key technologies/frameworks/libraries
- Flask (Python web framework)
- Jinja2 (templating engine)
- scikit-learn (model serialization)
- pickle (artifact storage)
- Docker (containerization)
- Heroku (PaaS hosting)
- GitHub Actions (CI/CD)

##### Detail and component breakdown
- Route handler for “/” (renders input form)
- Route handler for “/predict” (processes POST, calls predict)
- Static file handler
- Folders under Flask App: templates/, static/
- Environment (virtualenv, dependencies from requirements.txt)
- Port mappings (5000 local, 80/443 on Heroku)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client"
        Browser["User Browser (UI)"]:::frontend
    end

    %% Service Layer
    subgraph "Flask Service"
        FlaskApp["Flask App (app.py)"]:::backend
        subgraph "Views & Assets"
            Templates["Jinja2 Templates"]:::frontend
            StaticAssets["Static Assets"]:::frontend
        end
        subgraph "ML Artifacts"
            Preprocessor["Preprocessor (scalar.pickle)"]:::model
            Model["Regression Model (reg_predict.pickle)"]:::model
        end
        Requirements["Python Env (requirements.txt)"]:::backend
    end

    %% Offline Training
    Notebook["Offline Training Notebook"]:::offline

    %% CI/CD and Deployment
    subgraph "CI/CD & Deployment"
        CI["GitHub Actions Pipeline"]:::infra
        DockerBuild["Docker Build"]:::infra
        Heroku["Heroku Deployment"]:::infra
    end

    %% Flows
    Browser -->|"HTTP Request"| FlaskApp
    FlaskApp -->|"serve templates"| Templates
    FlaskApp -->|"serve static assets"| StaticAssets
    FlaskApp -->|"load scalar.pickle"| Preprocessor
    Preprocessor -->|"transform input"| Model
    Model -->|"predict price"| FlaskApp
    FlaskApp -->|"HTTP Response"| Browser

    CI -->|"on push build image"| DockerBuild
    DockerBuild -->|"push image"| Heroku

    Notebook -.->|"offline retrain"| Preprocessor
    Notebook -.->|"offline retrain"| Model

    FlaskApp --> Requirements

    %% Click Events
    click FlaskApp "https://github.com/rohith05196/predict_housing_price/blob/main/app.py"
    click StaticAssets "https://github.com/rohith05196/predict_housing_price/tree/main/static/"
    click Templates "https://github.com/rohith05196/predict_housing_price/blob/main/templates/home.html"
    click Preprocessor "https://github.com/rohith05196/predict_housing_price/blob/main/scalar.pickle"
    click Model "https://github.com/rohith05196/predict_housing_price/blob/main/reg_predict.pickle"
    click Notebook "https://github.com/rohith05196/predict_housing_price/blob/main/HousePricing.ipynb"
    click CI "https://github.com/rohith05196/predict_housing_price/blob/main/.github/workflows/main.yaml"
    click DockerBuild "https://github.com/rohith05196/predict_housing_price/tree/main/DockerFile"
    click Heroku "https://github.com/rohith05196/predict_housing_price/tree/main/Procfile"
    click Requirements "https://github.com/rohith05196/predict_housing_price/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#2E7D32
    classDef model fill:#FFF3E0,stroke:#E65100,color:#BF360C,shape:cylinder
    classDef infra fill:#ECEFF1,stroke:#37474F,color:#263238
    classDef offline fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C
```
