# pandey-a/fake-product-review-model architecture

> Architecture diagram of the GitHub repository pandey-a/fake-product-review-model, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pandey-a/fake-product-review-model
- Repository: https://github.com/pandey-a/fake-product-review-model

## Overview

##### Project Type and Purpose
- This is a simple full-stack Python web application (Flask) for classifying product reviews as “real” or “fake” using three pre-trained machine-learning models (Logistic Regression, Random Forest, SVM).
- The user interacts via a single HTML page, typing or pasting a review. The backend preprocesses text (using NLTK stopwords), loads one of the `.pkl` models, runs inference, and returns a prediction.

##### File-Structure Analysis
- Top level:
- `app.py` – Flask application entry point
- `requirements.txt` – Python dependencies
- `lr_model.pkl`, `rf_model.pkl`, `svc_model.pkl` – serialized ML models
- `nltk_data/` – local copy of NLTK corpora for stopword removal
- `templates/index.html` – frontend view
- No separate “static” or “backend” dir, so the structure follows a lightweight MVC:
- Model layer = the three `.pkl` files + text preprocessing code in `app.py`
- View layer = `index.html` in `templates/`
- Controller = Flask routes in `app.py`

##### README Insights
- Minimal, but project name confirms its core: a Fake-Product-Review-Model web service.

a. Main Components
1. User Browser (Client)
2. Web Server (Flask / app.py)
3. Preprocessing Module (NLTK stop-word removal)
4. Model Inference Module (LR, RF, SVC loaded from `.pkl`)
5. Data Store (local file system with `nltk_data/` and model artifacts)
b. Relationships & Data Flow
c. Architectural Patterns & Principles
- MVC-style separation: View (HTML template) vs Controller (Flask routes) vs Model (ML artifacts)
- Single-process microservice: minimal external dependencies
- Layered pipeline: Input → Preprocess → Inference → Output
d. Key Technologies
- Python 3.x, Flask (web framework)
- NLTK (text preprocessing)
- scikit-learn (pickled ML models)
- HTML/Jinja2 templates

##### Attention to Detail
- Preprocessing step explicitly (NLTK stopwords folder)
- If desired, indicate external calls (none in this version, but you could note “no external API calls”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["User Browser (Client)"]:::frontend
        IndexTemplate["HTML Template (index.html)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        FlaskApp["Flask Application (app.py)"]:::backend
        Preprocessing["Preprocessing Module (NLTK Stopword Removal)"]:::backend
        ModelInference["Model Inference Module"]:::backend
        subgraph "ML Models"
            LR["Logistic Regression Model"]:::data
            RF["Random Forest Model"]:::data
            SVC["SVC Model"]:::data
        end
    end

    %% Data Store
    subgraph "Data Store"
        NLTKData["NLTK Data Directory"]:::data
    end

    %% Repository Files
    subgraph "Project Files"
        Requirements["requirements.txt"]:::repo
        Readme["README.md"]:::repo
        Gitignore[".gitignore"]:::repo
    end

    %% Connections
    Browser -->|"GET /"| FlaskApp
    FlaskApp -->|"renders form"| IndexTemplate
    Browser -->|"POST /predict"| FlaskApp
    FlaskApp -->|"raw text"| Preprocessing
    Preprocessing -->|"tokens/features"| ModelInference
    ModelInference -->|"prediction"| FlaskApp
    FlaskApp -->|"JSON/HTML response"| Browser

    %% Dependencies on Data Store
    Preprocessing -->|"stopwords"| NLTKData
    ModelInference -->|"loads models"| LR
    ModelInference -->|"loads models"| RF
    ModelInference -->|"loads models"| SVC

    %% Repo dependencies
    FlaskApp --> Requirements
    FlaskApp --> Readme
    FlaskApp --> Gitignore

    %% Click Events
    click Browser "https://github.com/pandey-a/fake-product-review-model/blob/main/templates/index.html"
    click IndexTemplate "https://github.com/pandey-a/fake-product-review-model/blob/main/templates/index.html"
    click FlaskApp "https://github.com/pandey-a/fake-product-review-model/blob/main/app.py"
    click Preprocessing "https://github.com/pandey-a/fake-product-review-model/blob/main/app.py"
    click LR "https://github.com/pandey-a/fake-product-review-model/blob/main/lr_model.pkl"
    click RF "https://github.com/pandey-a/fake-product-review-model/blob/main/rf_model.pkl"
    click SVC "https://github.com/pandey-a/fake-product-review-model/blob/main/svc_model.pkl"
    click NLTKData "https://github.com/pandey-a/fake-product-review-model/tree/main/nltk_data/"
    click Requirements "https://github.com/pandey-a/fake-product-review-model/blob/main/requirements.txt"
    click Readme "https://github.com/pandey-a/fake-product-review-model/blob/main/README.md"
    click Gitignore "https://github.com/pandey-a/fake-product-review-model/blob/main/.gitignore"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#4a90e2,stroke-width:1px;
    classDef backend fill:#d4edda,stroke:#28a745,stroke-width:1px;
    classDef data fill:#fff3cd,stroke:#ffc107,stroke-width:1px;
    classDef repo fill:#e2e3e5,stroke:#6c757d,stroke-width:1px;
```
