# ouardaoui/igma-to-next-sync architecture

> Architecture diagram of the GitHub repository ouardaoui/igma-to-next-sync, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ouardaoui/igma-to-next-sync
- Repository: https://github.com/ouardaoui/igma-to-next-sync

## Overview

##### Project Type and Purpose
- This is a command-line Python utility (a CLI tool) in the “Figma-to-Next Sync Suite.”
- Purpose: automate analysis of Figma-export diffs and provide an interactive, keyboard-driven review workflow, then apply approved changes to your codebase.

##### File Structure Analysis
Top-level files:
- review.py        → “Review Engine” (CLI entrypoint for quick, detailed, apply, fix, show-decisions, side-by-side, smart-diff)
- sync.py          → “Sync Analyzer / Apply Engine” (analyze old vs. new export, apply individual updates)
- clean_imports.py → Optional code-cleanup utility
- script.py        → Helper or wrapper script (e.g., to drive workflows)
- workflow.sh      → Shell orchestration of sync → review → apply
- requirements.txt → Python dependencies
- README_*.md      → Process documentation / linting helpers
- review_decisions.json (generated) → JSON store for approved/rejected/partial decisions
- apply_approved.sh (generated)     → Bash script to batch-apply updates

##### README Insights
- Defines command set (–quick, –review, –apply, –fix-decisions, –show-decisions, –smart-diff, –side-by-side)
- Shows how decisions flow from “analysis” (sync.py) → “review” → “apply”
- Describes JSON decision-store structure and auto-generated apply script

1. CLI Entry Point
- review.py
- sync.py
- clean_imports.py
2. Sync Analyzer Module
- Reads old/new project directories
- Produces diff files/structures in figma-sync/
3. Review Engine Module
- Quick Review
- Detailed Review
- Side-by-Side & Smart Diff
4. Decision Manager (Data Store)
- Reads/Writes review_decisions.json
5. Apply Engine Module
- sync.py --apply-update
- Generates apply_approved.sh
6. File System / Figma Export (External Input)

b. Relationships & Data Flow:
- User invokes CLI → dispatch to appropriate module (review or sync)
- Sync Analyzer reads file system → outputs diff files
- Review Engine loads diffs → interacts via console UI → updates Decision Manager
- User runs “apply” → Apply Engine reads JSON → applies updates via sync.py → backups → generates bash script
- Optionally, Clean Imports or script.py can be inserted pre/post apply

c. Architectural Patterns & Principles:
- Modular monolith: clearly separated modules under one codebase
- Command pattern: each CLI flag is a command object/handler
- Single source of truth for decisions (JSON)
- Separation of concerns: Analysis, Review UI, Decision Storage, Apply

d. Key Technologies & Libraries:
- Python 3.x
- argparse / click (or similar CLI parsing)
- JSON I/O (built-in json)
- ANSI coloring (colorama or curses)
- File system operations (os, pathlib, shutil)

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "CLI Entry Point"
    Review["review.py"]:::cli
    SyncCmd["sync.py"]:::cli
    Clean["clean_imports.py"]:::cli
  end

  Review -->|"quick, review, apply, fix-decisions, show-decisions, smart-diff, side-by-side"| ReviewEngine["Review Engine Module"]:::module
  SyncCmd -->|"--quick, --review"| ReviewEngine
  SyncCmd -->|"--analyze"| SyncAnalyzer["Sync Analyzer Module"]:::module
  SyncCmd -->|"--apply-update"| ApplyEngine["Apply Engine Module"]:::module

  Figma["Figma Export"]:::external
  Figma -->|"export files"| SyncAnalyzer
  SyncAnalyzer -->|"diff files/structures"| ReviewEngine
  ReviewEngine -->|"writes decisions"| DecisionManager["Decision Manager\n(JSON)"]:::datastore
  SolveLoop["File System\n(updated codebase)"]:::external
  ApplyEngine -->|"reads decisions.json"| DecisionManager
  ApplyEngine -->|"apply updates & backup"| SolveLoop
  ApplyEngine -->|"generates apply_approved.sh"| ApplyScript["apply_approved.sh"]:::aux
  SolveLoop -->|"triggers next analysis"| SyncAnalyzer

  subgraph "Auxiliary"
    Workflow["workflow.sh"]:::aux
    Script["script.py"]:::aux
  end
  Workflow --> Review
  Workflow --> SyncCmd
  Workflow --> ApplyEngine

  subgraph "Dependencies & Docs"
    Dependencies["requirements.txt"]:::aux
    Doc1["README.md"]:::aux
    Doc2["README_sync.md"]:::aux
    Doc3["README_review.md"]:::aux
    Doc4["README_clean_imports.md"]:::aux
    Doc5["README_analyze_project.md"]:::aux
  end

  classDef cli fill:#BBDEFB,stroke:#0288D1,color:#000;
  classDef module fill:#E8F5E9,stroke:#388E3C,color:#000;
  classDef datastore fill:#FFF9C4,stroke:#FBC02D,color:#000;
  classDef external fill:#CFD8DC,stroke:#546E7A,color:#000;
  classDef aux fill:#ECEFF1,stroke:#90A4AE,color:#000;

  click Review "https://github.com/ouardaoui/igma-to-next-sync/blob/master/review.py"
  click SyncCmd "https://github.com/ouardaoui/igma-to-next-sync/blob/master/sync.py"
  click Clean "https://github.com/ouardaoui/igma-to-next-sync/blob/master/clean_imports.py"
  click Workflow "https://github.com/ouardaoui/igma-to-next-sync/blob/master/workflow.sh"
  click Script "https://github.com/ouardaoui/igma-to-next-sync/blob/master/script.py"
  click ApplyScript "https://github.com/ouardaoui/igma-to-next-sync/blob/master/apply_approved.sh"
  click DecisionManager "https://github.com/ouardaoui/igma-to-next-sync/blob/master/review_decisions.json"
  click Dependencies "https://github.com/ouardaoui/igma-to-next-sync/blob/master/requirements.txt"
  click Doc1 "https://github.com/ouardaoui/igma-to-next-sync/blob/master/README.md"
  click Doc2 "https://github.com/ouardaoui/igma-to-next-sync/blob/master/README_sync.md"
  click Doc3 "https://github.com/ouardaoui/igma-to-next-sync/blob/master/README_review.md"
  click Doc4 "https://github.com/ouardaoui/igma-to-next-sync/blob/master/README_clean_imports.md"
  click Doc5 "https://github.com/ouardaoui/igma-to-next-sync/blob/master/README_analyze_project.md"
```
