# maazuddin1/banglore_realestate_forecast-using-cicd-piplines architecture

> Architecture diagram of the GitHub repository maazuddin1/banglore_realestate_forecast-using-cicd-piplines, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines
- Repository: https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines

## Overview

##### Project Type and Purpose
- This is a full-stack, machine-learning-powered web application.
- It exposes a Flask-based frontend for user interactions and a backend ML service for price predictions.

##### File Structure
- Top-Level
– app.py: Flask app entry point and route definitions
– main.py: CLI or alternative execution script
– setup.py & requirements.txt: packaging and dependency management
– .github/workflows/python-app.yml: CI/CD pipeline
- Data & Models
– data/bengaluru_house_prices.csv: raw dataset (used offline in notebooks)
– models/*.pkl: serialized feature names and trained regression model
- Source Code (src/)
– preprocessing.py: data cleaning, feature engineering, one-hot encoding
– model.py: model training, evaluation, loading logic
– EDA.py: exploratory data analysis (offline, batch)
- Templates
– templates/index.html: user input form
– templates/results.html: prediction display
- Tests
– tests/: unit tests for model and API integration

##### Gather Insights from the README
- Core flow: User → Flask App → Preprocessing → ML Model → Prediction → UI
- Exposed endpoint: POST /predict returns JSON with predicted price
- CI/CD: runs tests, lints, and deploys via GitHub Actions

##### Main Components
a. User Interface (Browser)
b. Flask Application Layer
c. Preprocessing Module
d. ML Inference Module (loads lr_regg.pkl & feature_names.pkl)
e. Data Stores
– Raw Data (CSV file, used offline)
– Model Artifacts (Pickle files)
f. CI/CD Pipeline (GitHub Actions)

##### Relationships and Data Flow
1. User fills form in Browser → HTTP POST to /predict on Flask App
2. Flask App dispatches to preprocessing.py → transforms inputs into feature vector
3. Preprocessing output passed to model.py → loads pickled model → inference
4. Prediction returned to Flask App → renders results.html or JSON response
5. (Offline) EDA.py and model.py used during training stage with data CSV → produce new .pkl files

##### Architectural Patterns & Design Principles
- Separation of concerns: UI / routing (app.py) vs. data processing vs. model inference
- Modularity: src/ holds reusable components; templates/ holds presentation logic
- Test-driven: tests/ ensures model correctness and API stability
- CI/CD: automated testing and deployment via GitHub Actions

##### Relevant Technologies & Frameworks
- Flask (web framework)
- scikit-learn (LinearRegression, pickling)
- Jinja2 (templating engine)
- GitHub Actions (CI/CD)
- Python packaging (setup.py, requirements.txt)

##### Essential Elements to Capture
- Clear component labels
- Distinction between online inference path and offline training pipeline
- CI/CD pipeline integration (trigger → test → deploy)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        UI["User Interface (Browser)"]:::frontend
        Index["Index Template"]:::frontend
        Results["Results Template"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        Flask["Flask Application"]:::backend
        CLI["Alternative Entry/CLI"]:::backend
        Preproc["Preprocessing Module"]:::backend
        Model["ML Inference Module"]:::backend
    end

    %% Data Stores
    subgraph "Data Stores"
        CSV["Raw Dataset (CSV)"]:::data
        FeatureNames["Feature Names Pickle"]:::data
        RegressionModel["Regression Model Pickle"]:::data
    end

    %% Offline Training Pipeline
    subgraph "Offline Training Pipeline"
        EDA["EDA Script"]:::backend
        Notebook["Analysis Notebook"]:::backend
        TrainPreproc["Preprocessing Module"]:::backend
        TrainModel["Model Training"]:::backend
        ProduceArtifacts["Produce Model Artifacts"]:::data
    end

    %% Tests
    subgraph "Unit Tests"
        TestModel["tests/test_model.py"]:::infra
        Test2["tests/test2direct.py"]:::infra
    end

    %% Config
    subgraph "Configuration"
        Requirements["requirements.txt"]:::infra
        Setup["setup.py"]:::infra
    end

    %% CI/CD
    CI["CI/CD Pipeline"]:::infra

    %% Online Inference Flow
    UI -->|"renders form"| Index
    Index -->|"GET /"| Flask
    UI -->|"POST /predict"| Flask
    Flask -->|"transform input"| Preproc
    Preproc -->|"feature vector"| Model
    Model -->|"prediction"| Flask
    Flask -->|"render results"| Results

    %% Offline Training Flow
    CSV --> EDA
    Notebook --> EDA
    EDA --> TrainPreproc
    TrainPreproc --> TrainModel
    TrainModel --> ProduceArtifacts
    ProduceArtifacts --> FeatureNames
    ProduceArtifacts --> RegressionModel

    %% CI/CD and Testing
    CI -->|"runs tests"| TestModel
    CI -->|"runs tests"| Test2
    CI -->|"checks config"| Requirements
    CI -->|"checks config"| Setup
    CI -->|"deploy app"| Flask

    %% Click Events
    click Index "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/templates/index.html"
    click Results "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/templates/results.html"
    click Flask "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/app.py"
    click CLI "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/main.py"
    click Preproc "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/src/preprocessing.py"
    click Model "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/src/model.py"
    click CSV "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/data/bengaluru_house_prices.csv"
    click FeatureNames "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/models/feature_names.pkl"
    click RegressionModel "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/models/lr_regg.pkl"
    click EDA "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/src/EDA.py"
    click Notebook "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/notebooks/Analysis_notebook.ipynb"
    click TestModel "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/tests/test_model.py"
    click Test2 "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/tests/test2direct.py"
    click Requirements "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/requirements.txt"
    click Setup "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/setup.py"
    click CI "https://github.com/maazuddin1/banglore_realestate_forecast-using-cicd-piplines/blob/main/.github/workflows/python-app.yml"

    %% Styles
    classDef frontend fill:#ccffcc,stroke:#333,stroke-width:1px;
    classDef backend fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef data fill:#ffff99,stroke:#333,stroke-width:1px;
    classDef infra fill:#cccccc,stroke:#333,stroke-width:1px;
```
