# parveshahameds/clustify architecture

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

- Interactive diagram: https://gitdiagram.com/parveshahameds/clustify
- Repository: https://github.com/parveshahameds/clustify

## Overview

##### Project type and purpose
- From the file tree (app.py, templates/, model files) and README summary, this is a monolithic Python web application (likely Flask) that serves a customer-segmentation tool. It loads pre-trained ML artifacts (CatBoost and pickle models), offers an HTML interface for users to upload data, runs inference, and returns segmented results.

##### File structure
- Top level
– app.py: entry point, defines HTTP routes and controllers
– requirements.txt: Python dependencies (Flask, scikit-learn, catboost, etc.)
– vercel.json: deployment configuration for Vercel
– app.log: application log file
- Model artifacts
– customer_segmentation_catboost.cbm
– customer_segmentation_model.pkl
- Presentation layer
– templates/index.html: Jinja2 template for the upload form and results

##### README for additional insights
- Although the README describes React/Node.js, the file layout shows a pure Python app with server-rendered HTML. So treat it as a Flask + Jinja2 web UI with embedded ML inference.

##### Detail
- Startup sequence: app.py loads models at launch.
- Error path: exception → app.log.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        Browser["Browser"]:::external
        VercelHosting["Vercel Hosting / CDN"]:::comm
    end

    subgraph "Application Layer"
        FlaskApp["Flask Application"]:::compute
        TemplateEngine["Template Engine (Jinja2)"]:::compute
        ModelModule["ML Model Loader & Inference Module"]:::compute
    end

    subgraph "Persistence Layer"
        ModelCat["customer_segmentation_catboost.cbm"]:::storage
        ModelPkl["customer_segmentation_model.pkl"]:::storage
        TempStorage["File System / Temp Storage"]:::storage
        LogStore["app.log (Log Store)"]:::storage
    end

    %% Request Flow - GET
    Browser -->|HTTP GET /| VercelHosting
    VercelHosting -->|Forwards Request| FlaskApp
    FlaskApp -->|Render Form| TemplateEngine
    TemplateEngine -->|HTML| VercelHosting
    VercelHosting -->|HTML Response| Browser

    %% Request Flow - POST /segment
    Browser -->|POST CSV/JSON| VercelHosting
    VercelHosting -->|Forwards Request| FlaskApp
    FlaskApp -->|Save Upload| TempStorage
    FlaskApp -->|Inference Request| ModelModule
    ModelModule -->|Load Model| ModelCat
    ModelModule -->|Load Model| ModelPkl
    ModelModule -->|Return Result| FlaskApp
    FlaskApp -->|Pass Result| TemplateEngine
    TemplateEngine -->|Rendered HTML| VercelHosting
    VercelHosting -->|HTML Response| Browser

    %% Logging
    FlaskApp -->|Log Events/Errors| LogStore

    %% Startup
    FlaskApp -.->|Lazy Load Models on Startup| ModelCat
    FlaskApp -.->|Lazy Load Models on Startup| ModelPkl

    %% Click Events
    click VercelHosting "https://github.com/parveshahameds/clustify/blob/master/vercel.json"
    click FlaskApp "https://github.com/parveshahameds/clustify/blob/master/app.py"
    click TemplateEngine "https://github.com/parveshahameds/clustify/blob/master/templates/index.html"
    click ModelCat "https://github.com/parveshahameds/clustify/blob/master/customer_segmentation_catboost.cbm"
    click ModelPkl "https://github.com/parveshahameds/clustify/blob/master/customer_segmentation_model.pkl"
    click LogStore "https://github.com/parveshahameds/clustify/blob/master/app.log"
    click Requirements "https://github.com/parveshahameds/clustify/blob/master/requirements.txt"

    %% Styles
    classDef comm fill:#cce5ff,stroke:#66b0ff,stroke-width:1px,color:#004085
    classDef compute fill:#d4edda,stroke:#28a745,stroke-width:1px,color:#155724
    classDef storage fill:#fff3cd,stroke:#ffeeba,stroke-width:1px,color:#856404
    classDef external fill:#e2e3e5,stroke:#d6d8db,stroke-width:1px,color:#383d41
```
