# ojasrane/singular-value-decomposition architecture

> Architecture diagram of the GitHub repository ojasrane/singular-value-decomposition, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ojasrane/singular-value-decomposition
- Repository: https://github.com/ojasrane/singular-value-decomposition

## Overview

This repository is an SVD learning and image-compression application, exposed through a Streamlit lab and reusable Python modules. Users can explore compression interactively, upload and compress images for download, view images or custom `.svd` files, and experiment with PCA. The compute path supports both NumPy-optimized and from-scratch SVD; PCA uses the optimized method, while metrics quantify reconstruction and storage tradeoffs. Edges follow the README and shown imports/calls; unsampled page details and analysis notebooks are not expanded into runtime flows.

Main entry points: [`web_app/pages/playground.py`](https://github.com/ojasrane/singular-value-decomposition/blob/main/web_app/pages/playground.py) (SVD and PCA playground), [`optimized_method/optimized_svd.py`](https://github.com/ojasrane/singular-value-decomposition/blob/main/optimized_method/optimized_svd.py) (Optimized SVD), [`web_app/landing_page.py`](https://github.com/ojasrane/singular-value-decomposition/blob/main/web_app/landing_page.py) (Lab home), [`application/image_compression.py`](https://github.com/ojasrane/singular-value-decomposition/blob/main/application/image_compression.py) (Image compression)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Interactive lab"]
  node_landing["Lab home<br/>[landing_page.py]"]
  node_compressor_ui["Image compressor<br/>[compressor.py]"]
  node_playground["SVD and PCA playground<br/>[playground.py]"]
  node_viewer["Image viewer<br/>[image_viewer.py]"]
end

subgraph group_compute["SVD and PCA"]
  node_image_compression["Image compression"]
  node_optimized_svd["Optimized SVD<br/>[optimized_svd.py]"]
  node_scratch_svd["Scratch SVD"]
  node_pca["PCA"]
end

subgraph group_formats["Encoding and metrics"]
  node_encoder["SVD file encoder<br/>[svd.py]"]
  node_metrics["Compression metrics<br/>[metrics.py]"]
  node_utils["Array and file helpers<br/>[utils.py]"]
end

node_user(("Visitor"))

node_user -->|"opens lab"| node_landing
node_landing -->|"routes to"| node_playground
node_landing -->|"routes to"| node_compressor_ui
node_landing -->|"routes to"| node_viewer
node_compressor_ui -->|"compresses image"| node_image_compression
node_compressor_ui -->|"reads ratio"| node_metrics
node_playground -->|"reconstructs"| node_optimized_svd
node_playground -->|"gets k"| node_image_compression
node_playground -->|"fits and projects"| node_pca
node_playground -->|"plots quality"| node_metrics
node_viewer -->|"decodes SVD"| node_encoder
node_image_compression -->|"decomposes and reconstructs"| node_optimized_svd
node_image_compression -->|"decomposes"| node_scratch_svd
node_pca -->|"decomposes data"| node_optimized_svd
node_encoder -->|"decomposes and reconstructs"| node_optimized_svd
node_encoder -->|"reads bytes"| node_utils
node_metrics -->|"extracts diagonal"| node_utils
node_optimized_svd -->|"extracts diagonal"| node_utils

click node_landing "https://github.com/ojasrane/singular-value-decomposition/blob/main/web_app/landing_page.py"
click node_compressor_ui "https://github.com/ojasrane/singular-value-decomposition/blob/main/web_app/pages/compressor.py"
click node_playground "https://github.com/ojasrane/singular-value-decomposition/blob/main/web_app/pages/playground.py"
click node_viewer "https://github.com/ojasrane/singular-value-decomposition/blob/main/web_app/pages/image_viewer.py"
click node_image_compression "https://github.com/ojasrane/singular-value-decomposition/blob/main/application/image_compression.py"
click node_optimized_svd "https://github.com/ojasrane/singular-value-decomposition/blob/main/optimized_method/optimized_svd.py"
click node_scratch_svd "https://github.com/ojasrane/singular-value-decomposition/blob/main/mathematical_foundation/svd_from_scratch.py"
click node_pca "https://github.com/ojasrane/singular-value-decomposition/blob/main/application/principal_component_analysis.py"
click node_encoder "https://github.com/ojasrane/singular-value-decomposition/blob/main/svd_encoder/svd.py"
click node_metrics "https://github.com/ojasrane/singular-value-decomposition/blob/main/metrics/metrics.py"
click node_utils "https://github.com/ojasrane/singular-value-decomposition/blob/main/utils.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_landing,node_compressor_ui,node_playground,node_viewer toneBlue
class node_image_compression,node_optimized_svd,node_scratch_svd,node_pca toneAmber
class node_encoder,node_metrics,node_utils toneMint
class node_user toneIndigo
```

## Components

### Interactive lab

- [Lab home](https://github.com/ojasrane/singular-value-decomposition/blob/main/web_app/landing_page.py): `web_app/landing_page.py`
- [Image compressor](https://github.com/ojasrane/singular-value-decomposition/blob/main/web_app/pages/compressor.py): `web_app/pages/compressor.py`
- [SVD and PCA playground](https://github.com/ojasrane/singular-value-decomposition/blob/main/web_app/pages/playground.py): `web_app/pages/playground.py`
- [Image viewer](https://github.com/ojasrane/singular-value-decomposition/blob/main/web_app/pages/image_viewer.py): `web_app/pages/image_viewer.py`

### SVD and PCA

- [Image compression](https://github.com/ojasrane/singular-value-decomposition/blob/main/application/image_compression.py): `application/image_compression.py`
- [Optimized SVD](https://github.com/ojasrane/singular-value-decomposition/blob/main/optimized_method/optimized_svd.py): `optimized_method/optimized_svd.py`
- [Scratch SVD](https://github.com/ojasrane/singular-value-decomposition/blob/main/mathematical_foundation/svd_from_scratch.py): `mathematical_foundation/svd_from_scratch.py`
- [PCA](https://github.com/ojasrane/singular-value-decomposition/blob/main/application/principal_component_analysis.py): `application/principal_component_analysis.py`

### Encoding and metrics

- [SVD file encoder](https://github.com/ojasrane/singular-value-decomposition/blob/main/svd_encoder/svd.py): `svd_encoder/svd.py`
- [Compression metrics](https://github.com/ojasrane/singular-value-decomposition/blob/main/metrics/metrics.py): `metrics/metrics.py`
- [Array and file helpers](https://github.com/ojasrane/singular-value-decomposition/blob/main/utils.py): `utils.py`

### Other components

- **Visitor**

## Connections

- Visitor → Lab home: opens lab (evidence: `README.md`)
- Lab home → SVD and PCA playground: routes to (evidence: `web_app/landing_page.py`)
- Lab home → Image compressor: routes to (evidence: `web_app/landing_page.py`)
- Lab home → Image viewer: routes to (evidence: `web_app/landing_page.py`)
- Image compressor → Image compression: compresses image (evidence: `web_app/pages/compressor.py`)
- Image compressor → Compression metrics: reads ratio (evidence: `web_app/pages/compressor.py`)
- SVD and PCA playground → Optimized SVD: reconstructs (evidence: `web_app/pages/playground.py`)
- SVD and PCA playground → Image compression: gets k (evidence: `web_app/pages/playground.py`)
- SVD and PCA playground → PCA: fits and projects (evidence: `web_app/pages/playground.py`)
- SVD and PCA playground → Compression metrics: plots quality (evidence: `web_app/pages/playground.py`)
- Image viewer → SVD file encoder: decodes SVD (evidence: `web_app/pages/image_viewer.py`)
- Image compression → Optimized SVD: decomposes and reconstructs (evidence: `application/image_compression.py`)
- Image compression → Scratch SVD: decomposes (evidence: `application/image_compression.py`)
- PCA → Optimized SVD: decomposes data (evidence: `application/principal_component_analysis.py`)
- SVD file encoder → Optimized SVD: decomposes and reconstructs (evidence: `svd_encoder/svd.py`)
- SVD file encoder → Array and file helpers: reads bytes (evidence: `svd_encoder/svd.py`)
- Compression metrics → Array and file helpers: extracts diagonal (evidence: `metrics/metrics.py`)
- Optimized SVD → Array and file helpers: extracts diagonal (evidence: `optimized_method/optimized_svd.py`)
