# jefisha21-cell/image_compression_ml architecture

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

- Interactive diagram: https://gitdiagram.com/jefisha21-cell/image_compression_ml
- Repository: https://github.com/jefisha21-cell/image_compression_ml

## Overview

This is a single-file Streamlit image-compression dashboard. Users upload a JPG/PNG and choose k; the app converts the image to RGB pixels, projects them with PCA, clusters the projection with K-Means, and reconstructs pixels from cluster centers. It then presents the image comparison, compression metrics, dominant colors, PCA and RGB visualizations, and a JPEG download. These concerns share one implementation file, so the graph represents meaningful runtime stages rather than separate packages. Relationships are supported by the app.py excerpt; no other runtime modules appear in the source index.

Main entry points: [`app.py`](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py) (Color reconstruction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Compression workflow"]
  node_controls["Upload and k controls<br/>[app.py]"]
  node_image_input["RGB image pixels<br/>[app.py]"]
  node_pca["PCA projection<br/>[app.py]"]
  node_kmeans["K-Means clustering<br/>[app.py]"]
  node_reconstruction["Color reconstruction<br/>[app.py]"]
end

subgraph group_dashboard["Dashboard results"]
  node_metrics["Compression metrics<br/>[app.py]"]
  node_comparison["Image comparison<br/>[app.py]"]
  node_analysis["PCA analysis<br/>[app.py]"]
  node_histogram["RGB histogram<br/>[app.py]"]
  node_palette["Dominant palette<br/>[app.py]"]
  node_download["JPEG download<br/>[app.py]"]
end

node_user(("Image user"))

node_user -->|"uploads and selects"| node_controls
node_controls -->|"provides image and k"| node_image_input
node_image_input -->|"projects pixels"| node_pca
node_pca -->|"clusters projection"| node_kmeans
node_kmeans -->|"assigns centroid colors"| node_reconstruction
node_reconstruction -->|"supplies compression results"| node_metrics
node_reconstruction -->|"renders compressed image"| node_comparison
node_pca -->|"reports variance"| node_analysis
node_image_input -->|"plots RGB values"| node_histogram
node_pca -->|"plots projection"| node_analysis
node_reconstruction -->|"shows cluster colors"| node_palette
node_reconstruction -->|"encodes JPEG"| node_download

click node_controls "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"
click node_image_input "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"
click node_pca "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"
click node_kmeans "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"
click node_reconstruction "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"
click node_metrics "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"
click node_comparison "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"
click node_analysis "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"
click node_histogram "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"
click node_palette "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"
click node_download "https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_controls,node_image_input,node_pca,node_kmeans,node_reconstruction,node_user toneBlue
class node_metrics,node_comparison,node_analysis,node_histogram,node_palette,node_download toneAmber
```

## Components

### Compression workflow

- [Upload and k controls](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`
- [RGB image pixels](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`
- [PCA projection](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`
- [K-Means clustering](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`
- [Color reconstruction](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`

### Dashboard results

- [Compression metrics](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`
- [Image comparison](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`
- [PCA analysis](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`
- [RGB histogram](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`
- [Dominant palette](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`
- [JPEG download](https://github.com/jefisha21-cell/image_compression_ml/blob/main/app.py): `app.py`

### Other components

- **Image user**

## Connections

- Image user → Upload and k controls: uploads and selects (evidence: `app.py`)
- Upload and k controls → RGB image pixels: provides image and k (evidence: `app.py`)
- RGB image pixels → PCA projection: projects pixels (evidence: `app.py`)
- PCA projection → K-Means clustering: clusters projection (evidence: `app.py`)
- K-Means clustering → Color reconstruction: assigns centroid colors (evidence: `app.py`)
- Color reconstruction → Compression metrics: supplies compression results (evidence: `app.py`)
- Color reconstruction → Image comparison: renders compressed image (evidence: `app.py`)
- PCA projection → PCA analysis: reports variance (evidence: `app.py`)
- RGB image pixels → RGB histogram: plots RGB values (evidence: `app.py`)
- PCA projection → PCA analysis: plots projection (evidence: `app.py`)
- Color reconstruction → Dominant palette: shows cluster colors (evidence: `app.py`)
- Color reconstruction → JPEG download: encodes JPEG (evidence: `app.py`)
