# jinohpark371/gridflow architecture

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

- Interactive diagram: https://gitdiagram.com/jinohpark371/gridflow
- Repository: https://github.com/jinohpark371/gridflow

## Overview

GridFlow is a photo-theme analysis and carousel-order recommendation product: users choose a theme and photos, then receive a suggested ordering plus photos suggested for removal (not deleted automatically). The frontend uploads resized images to FastAPI; the backend extracts features, scores theme fitness, and returns grouped ordering and skipped-photo details. The README also describes CLIP/color features, pairwise transition-cost learning, Unsplash training-data collection, and an ordering algorithm needing reimplementation. Backend excerpts do not expose every internal call, so unverified links are omitted; unsampled model-training branches are represented from explicit README descriptions.

Main entry points: [`Frontend/components/GridFlowApp.tsx`](https://github.com/jinohpark371/gridflow/blob/main/Frontend/components/GridFlowApp.tsx) (Workflow controller), [`Backend/main.py`](https://github.com/jinohpark371/gridflow/blob/main/Backend/main.py) (Arrange endpoint), [`Ai/dataset.py`](https://github.com/jinohpark371/gridflow/blob/main/Ai/dataset.py) (Training datasets), [`Ai/collect_unsplash_data.py`](https://github.com/jinohpark371/gridflow/blob/main/Ai/collect_unsplash_data.py) (Training data collection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Photo Workflow"]
  node_app["Workflow controller<br/>[GridFlowApp.tsx]"]
  node_theme["Theme selection<br/>[ThemePicker.tsx]"]
  node_picker["Photo selection<br/>[PhotoPicker.tsx]"]
  node_resize["Image resizing<br/>[resize.ts]"]
  node_clientstate["Workflow state<br/>[state.ts]"]
  node_api["Arrange client<br/>[api.ts]"]
  node_results["Recommendations<br/>[ResultView.tsx]"]
end

subgraph group_backend["Analysis API"]
  node_server["Arrange endpoint<br/>[main.py]"]
end

subgraph group_models["AI Analysis"]
  node_features["Feature extraction<br/>[features.py]"]
  node_clip["CLIP similarity<br/>[clip.py]"]
  node_fitness["Theme fitness model<br/>[mlp.py]"]
  node_transition["Transition cost model"]
  node_arranger["Photo arrangement<br/>[arrange_photos.py]"]
  node_checkpoints[("Model checkpoints")]
end

subgraph group_training["Model Preparation"]
  node_collector["Training data collection"]
  node_dataset["Training datasets<br/>[dataset.py]"]
  node_scoringtrain["Fitness model training<br/>[train_mlp.py]"]
  node_transitiontrain["Transition model training"]
  node_evaluator["Theme evaluation<br/>[evaluate_mlp.py]"]
end

node_user(("Photo creator"))
node_unsplash["Unsplash service"]

node_user -->|"starts workflow"| node_app
node_app -->|"renders"| node_theme
node_app -->|"renders"| node_picker
node_app -->|"resizes images"| node_resize
node_app -->|"updates state"| node_clientstate
node_app -->|"submits photos"| node_api
node_api -->|"POST arrange"| node_server
node_server -.->|"extracts features"| node_features
node_server -.->|"scores fitness"| node_fitness
node_server -.->|"requests ordering"| node_arranger
node_arranger -->|"estimates pair costs"| node_transition
node_features -->|"uses similarity"| node_clip
node_server -.->|"loads weights"| node_checkpoints
node_app -->|"renders result"| node_results
node_collector -->|"searches photos"| node_unsplash
node_collector -->|"extracts features"| node_features
node_collector -.->|"writes CSV data"| node_dataset
node_dataset -->|"prepares pairs"| node_scoringtrain
node_dataset -->|"samples pairs"| node_transitiontrain
node_scoringtrain -->|"trains model"| node_fitness
node_evaluator -->|"builds splits"| node_dataset
node_evaluator -->|"evaluates training"| node_scoringtrain
node_fitness -.->|"saves weights"| node_checkpoints
node_transitiontrain -.->|"saves weights"| node_checkpoints

click node_app "https://github.com/jinohpark371/gridflow/blob/main/Frontend/components/GridFlowApp.tsx"
click node_theme "https://github.com/jinohpark371/gridflow/blob/main/Frontend/components/ThemePicker.tsx"
click node_picker "https://github.com/jinohpark371/gridflow/blob/main/Frontend/components/PhotoPicker.tsx"
click node_resize "https://github.com/jinohpark371/gridflow/blob/main/Frontend/lib/resize.ts"
click node_clientstate "https://github.com/jinohpark371/gridflow/blob/main/Frontend/lib/state.ts"
click node_api "https://github.com/jinohpark371/gridflow/blob/main/Frontend/lib/api.ts"
click node_results "https://github.com/jinohpark371/gridflow/blob/main/Frontend/components/ResultView.tsx"
click node_server "https://github.com/jinohpark371/gridflow/blob/main/Backend/main.py"
click node_features "https://github.com/jinohpark371/gridflow/blob/main/Ai/features.py"
click node_clip "https://github.com/jinohpark371/gridflow/blob/main/Ai/clip.py"
click node_fitness "https://github.com/jinohpark371/gridflow/blob/main/Ai/mlp.py"
click node_transition "https://github.com/jinohpark371/gridflow/blob/main/Ai/transition_cost_model.py"
click node_arranger "https://github.com/jinohpark371/gridflow/blob/main/Ai/arrange_photos.py"
click node_checkpoints "https://github.com/jinohpark371/gridflow/tree/main/Ai/checkpoints"
click node_collector "https://github.com/jinohpark371/gridflow/blob/main/Ai/collect_unsplash_data.py"
click node_dataset "https://github.com/jinohpark371/gridflow/blob/main/Ai/dataset.py"
click node_scoringtrain "https://github.com/jinohpark371/gridflow/blob/main/Ai/train_mlp.py"
click node_transitiontrain "https://github.com/jinohpark371/gridflow/blob/main/Ai/transition_cost_model.py"
click node_evaluator "https://github.com/jinohpark371/gridflow/blob/main/Ai/evaluate_mlp.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_app,node_theme,node_picker,node_resize,node_clientstate,node_api,node_results toneBlue
class node_server toneAmber
class node_features,node_clip,node_fitness,node_transition,node_arranger,node_checkpoints toneMint
class node_collector,node_dataset,node_scoringtrain,node_transitiontrain,node_evaluator toneRose
class node_user,node_unsplash toneIndigo
```

## Components

### Photo Workflow

- [Workflow controller](https://github.com/jinohpark371/gridflow/blob/main/Frontend/components/GridFlowApp.tsx): `Frontend/components/GridFlowApp.tsx`
- [Theme selection](https://github.com/jinohpark371/gridflow/blob/main/Frontend/components/ThemePicker.tsx): `Frontend/components/ThemePicker.tsx`
- [Photo selection](https://github.com/jinohpark371/gridflow/blob/main/Frontend/components/PhotoPicker.tsx): `Frontend/components/PhotoPicker.tsx`
- [Image resizing](https://github.com/jinohpark371/gridflow/blob/main/Frontend/lib/resize.ts): `Frontend/lib/resize.ts`
- [Workflow state](https://github.com/jinohpark371/gridflow/blob/main/Frontend/lib/state.ts): `Frontend/lib/state.ts`
- [Arrange client](https://github.com/jinohpark371/gridflow/blob/main/Frontend/lib/api.ts): `Frontend/lib/api.ts`
- [Recommendations](https://github.com/jinohpark371/gridflow/blob/main/Frontend/components/ResultView.tsx): `Frontend/components/ResultView.tsx`

### Analysis API

- [Arrange endpoint](https://github.com/jinohpark371/gridflow/blob/main/Backend/main.py): `Backend/main.py`

### AI Analysis

- [Feature extraction](https://github.com/jinohpark371/gridflow/blob/main/Ai/features.py): `Ai/features.py`
- [CLIP similarity](https://github.com/jinohpark371/gridflow/blob/main/Ai/clip.py): `Ai/clip.py`
- [Theme fitness model](https://github.com/jinohpark371/gridflow/blob/main/Ai/mlp.py): `Ai/mlp.py`
- [Transition cost model](https://github.com/jinohpark371/gridflow/blob/main/Ai/transition_cost_model.py): `Ai/transition_cost_model.py`
- [Photo arrangement](https://github.com/jinohpark371/gridflow/blob/main/Ai/arrange_photos.py): `Ai/arrange_photos.py`
- [Model checkpoints](https://github.com/jinohpark371/gridflow/tree/main/Ai/checkpoints): `Ai/checkpoints`

### Model Preparation

- [Training data collection](https://github.com/jinohpark371/gridflow/blob/main/Ai/collect_unsplash_data.py): `Ai/collect_unsplash_data.py`
- [Training datasets](https://github.com/jinohpark371/gridflow/blob/main/Ai/dataset.py): `Ai/dataset.py`
- [Fitness model training](https://github.com/jinohpark371/gridflow/blob/main/Ai/train_mlp.py): `Ai/train_mlp.py`
- [Transition model training](https://github.com/jinohpark371/gridflow/blob/main/Ai/transition_cost_model.py): `Ai/transition_cost_model.py`
- [Theme evaluation](https://github.com/jinohpark371/gridflow/blob/main/Ai/evaluate_mlp.py): `Ai/evaluate_mlp.py`

### Other components

- **Photo creator**
- **Unsplash service**

## Connections

- Photo creator → Workflow controller: starts workflow (evidence: `Frontend/components/GridFlowApp.tsx`)
- Workflow controller → Theme selection: renders (evidence: `Frontend/components/GridFlowApp.tsx`)
- Workflow controller → Photo selection: renders (evidence: `Frontend/components/GridFlowApp.tsx`)
- Workflow controller → Image resizing: resizes images (evidence: `Frontend/components/GridFlowApp.tsx`)
- Workflow controller → Workflow state: updates state (evidence: `Frontend/components/GridFlowApp.tsx`)
- Workflow controller → Arrange client: submits photos (evidence: `Frontend/components/GridFlowApp.tsx`)
- Arrange client → Arrange endpoint: POST arrange (evidence: `Frontend/lib/api.ts`)
- Arrange endpoint → Feature extraction: extracts features
- Arrange endpoint → Theme fitness model: scores fitness (evidence: `Backend/main.py`)
- Arrange endpoint → Photo arrangement: requests ordering (evidence: `Backend/main.py`)
- Photo arrangement → Transition cost model: estimates pair costs (evidence: `Ai/arrange_photos.py`)
- Feature extraction → CLIP similarity: uses similarity (evidence: `Ai/mlp.py`)
- Arrange endpoint → Model checkpoints: loads weights
- Workflow controller → Recommendations: renders result (evidence: `Frontend/components/GridFlowApp.tsx`)
- Training data collection → Unsplash service: searches photos (evidence: `Ai/collect_unsplash_data.py`)
- Training data collection → Feature extraction: extracts features (evidence: `Ai/collect_unsplash_data.py`)
- Training data collection → Training datasets: writes CSV data
- Training datasets → Fitness model training: prepares pairs (evidence: `Ai/train_mlp.py`)
- Training datasets → Transition model training: samples pairs (evidence: `Ai/dataset.py`)
- Fitness model training → Theme fitness model: trains model (evidence: `Ai/train_mlp.py`)
- Theme evaluation → Training datasets: builds splits (evidence: `Ai/evaluate_mlp.py`)
- Theme evaluation → Fitness model training: evaluates training (evidence: `Ai/evaluate_mlp.py`)
- Theme fitness model → Model checkpoints: saves weights
- Transition model training → Model checkpoints: saves weights
