# rishitak-cloud/frameagent architecture

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

- Interactive diagram: https://gitdiagram.com/rishitak-cloud/frameagent
- Repository: https://github.com/rishitak-cloud/frameagent

## Overview

FrameAgent is a Streamlit photography-composition adviser. A photographer uploads an image; the web app constructs composition analysis, which obtains a subject mask and centroid, evaluates composition rules, optionally suggests a crop, and separately requests a NIMA aesthetic score. The app presents annotated rule images, verdicts, and scores. The README identifies `web.py` as the launch path; the sampled `web_v2.py` excerpt describes a revised interface, but its omitted analysis code limits tracing its internal wiring. The graph follows the inspected `str/web.py` and `str/composition_rules.py` implementation.

Main entry points: [`str/composition_rules.py`](https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py) (Rule analysis), [`str/web.py`](https://github.com/rishitak-cloud/frameagent/blob/main/str/web.py) (Streamlit app), [`str/nima_import.py`](https://github.com/rishitak-cloud/frameagent/blob/main/str/nima_import.py) (NIMA scoring), [`str/u2net.py`](https://github.com/rishitak-cloud/frameagent/blob/main/str/u2net.py) (U²-Net mask)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_web["Streamlit app<br/>[web.py]"]
  node_photo["Uploaded photo"]
end

subgraph group_analysis["Composition analysis"]
  node_rules["Rule analysis"]
  node_subject["Subject centroid"]
  node_thirds["Thirds check"]
  node_golden["Golden ratio check"]
  node_centre["Centre check"]
  node_symmetry["Symmetry check"]
  node_lines["Leading lines check"]
end

subgraph group_models["Model scoring"]
  node_masker["U²-Net mask<br/>[u2net.py]"]
  node_nima["NIMA scoring<br/>[nima_import.py]"]
end

subgraph group_results["Guidance and results"]
  node_crop["Crop suggestion"]
  node_display["Annotated results<br/>[web.py]"]
end

node_photographer(("Photographer"))
node_rembg["rembg model"]
node_pyiqa["pyiqa metric"]

node_photographer -->|"uploads photo"| node_web
node_web -->|"reads upload"| node_photo
node_web -->|"runs checks"| node_rules
node_rules -->|"requests mask"| node_masker
node_masker -->|"removes background"| node_rembg
node_masker -->|"returns mask"| node_rules
node_rules -->|"derives centroid"| node_subject
node_rules -->|"checks position"| node_thirds
node_rules -->|"checks position"| node_golden
node_rules -->|"checks position"| node_centre
node_rules -->|"compares halves"| node_symmetry
node_rules -->|"detects diagonals"| node_lines
node_web -->|"requests if eligible"| node_crop
node_web -->|"requests score"| node_nima
node_nima -->|"creates metric"| node_pyiqa
node_pyiqa -->|"returns score"| node_nima
node_rules -->|"returns checks"| node_web
node_crop -->|"returns crop"| node_web
node_nima -->|"returns score"| node_web
node_web -->|"renders results"| node_display
node_display -->|"shows guidance"| node_photographer

click node_web "https://github.com/rishitak-cloud/frameagent/blob/main/str/web.py"
click node_rules "https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py"
click node_masker "https://github.com/rishitak-cloud/frameagent/blob/main/str/u2net.py"
click node_subject "https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py"
click node_thirds "https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py"
click node_golden "https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py"
click node_centre "https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py"
click node_symmetry "https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py"
click node_lines "https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py"
click node_crop "https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py"
click node_nima "https://github.com/rishitak-cloud/frameagent/blob/main/str/nima_import.py"
click node_display "https://github.com/rishitak-cloud/frameagent/blob/main/str/web.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_web,node_photo toneBlue
class node_rules,node_subject,node_thirds,node_golden,node_centre,node_symmetry,node_lines toneAmber
class node_masker,node_nima toneMint
class node_crop,node_display toneRose
class node_photographer,node_rembg,node_pyiqa toneIndigo
```

## Components

### User interface

- [Streamlit app](https://github.com/rishitak-cloud/frameagent/blob/main/str/web.py): `str/web.py`
- **Uploaded photo**

### Composition analysis

- [Rule analysis](https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py): `str/composition_rules.py`
- [Subject centroid](https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py): `str/composition_rules.py`
- [Thirds check](https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py): `str/composition_rules.py`
- [Golden ratio check](https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py): `str/composition_rules.py`
- [Centre check](https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py): `str/composition_rules.py`
- [Symmetry check](https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py): `str/composition_rules.py`
- [Leading lines check](https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py): `str/composition_rules.py`

### Model scoring

- [U²-Net mask](https://github.com/rishitak-cloud/frameagent/blob/main/str/u2net.py): `str/u2net.py`
- [NIMA scoring](https://github.com/rishitak-cloud/frameagent/blob/main/str/nima_import.py): `str/nima_import.py`

### Guidance and results

- [Crop suggestion](https://github.com/rishitak-cloud/frameagent/blob/main/str/composition_rules.py): `str/composition_rules.py`
- [Annotated results](https://github.com/rishitak-cloud/frameagent/blob/main/str/web.py): `str/web.py`

### Other components

- **Photographer**
- **rembg model**
- **pyiqa metric**

## Connections

- Photographer → Streamlit app: uploads photo
- Streamlit app → Uploaded photo: reads upload
- Streamlit app → Rule analysis: runs checks
- Rule analysis → U²-Net mask: requests mask
- U²-Net mask → rembg model: removes background
- U²-Net mask → Rule analysis: returns mask
- Rule analysis → Subject centroid: derives centroid
- Rule analysis → Thirds check: checks position
- Rule analysis → Golden ratio check: checks position
- Rule analysis → Centre check: checks position
- Rule analysis → Symmetry check: compares halves
- Rule analysis → Leading lines check: detects diagonals
- Streamlit app → Crop suggestion: requests if eligible
- Streamlit app → NIMA scoring: requests score
- NIMA scoring → pyiqa metric: creates metric
- pyiqa metric → NIMA scoring: returns score
- Rule analysis → Streamlit app: returns checks
- Crop suggestion → Streamlit app: returns crop
- NIMA scoring → Streamlit app: returns score
- Streamlit app → Annotated results: renders results
- Annotated results → Photographer: shows guidance
