# allen246/sync_tool_feature_flag architecture

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

- Interactive diagram: https://gitdiagram.com/allen246/sync_tool_feature_flag
- Repository: https://github.com/allen246/sync_tool_feature_flag

## Overview

This Flask-backed configuration migration tool helps operators generate database pull queries, provide source and destination exports, and produce migration SQL for branch/product, workflow, and feature-flag configuration. It also compares message-queue definitions and offers a v2-only full-tenant export with table selection, review, validation, and migration generation. The browser UI drives the HTTP API; generated SQL is run manually against databases. Source excerpts show the main API, service, and UI entry points; some script and UI internals were not sampled, so uncertain wiring is omitted.

Main entry points: [`app.py`](https://github.com/allen246/sync_tool_feature_flag/blob/main/app.py) (Flask routes), [`static/js/tabs`](https://github.com/allen246/sync_tool_feature_flag/tree/main/static/js/tabs) (Sync domain tabs), [`static/js/tabs/tenant-export.js`](https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/tabs/tenant-export.js) (Tenant export tab), [`static/js/main.js`](https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/main.js) (UI bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Browser interface"]
  node_main["UI bootstrap<br/>[main.js]"]
  node_domain_tabs["Sync domain tabs"]
  node_tenant_tab["Tenant export tab<br/>[tenant-export.js]"]
  node_sql_preview["SQL preview<br/>[sql-preview.js]"]
  node_ui_data["Input and data handling<br/>[data.js]"]
  node_ui_state["Tab and flow state"]
  node_mq_tab["Queue comparison tab<br/>[mq.js]"]
end

subgraph group_api["HTTP API"]
  node_flask["Flask routes<br/>[app.py]"]
end

subgraph group_sync["Configuration sync"]
  node_branch_service["Branch service<br/>[branch_service.py]"]
  node_workflow_service["Workflow service"]
  node_flag_service["Feature flag service"]
  node_branch_scripts["Branch generators"]
  node_workflow_scripts["Workflow generators<br/>[workflow_sync.py]"]
  node_flag_scripts["Flag generators<br/>[feature_flag.py]"]
  node_common["Script and query utilities<br/>[common.py]"]
end

subgraph group_tenant["Tenant export"]
  node_tenant_service["Tenant export service"]
  node_tenant_query["Tenant query builders"]
  node_tenant_registry["Tenant table registry<br/>[tenant_registry.py]"]
  node_tenant_upsert["Tenant validation and upsert<br/>[tenant_upsert.py]"]
end

subgraph group_mq["Queue comparison"]
  node_mq_service["Queue comparison service<br/>[mq_service.py]"]
  node_mq_script["Definition comparator<br/>[mq_comparison.py]"]
end

node_operator(("Operator"))
node_browser(("Browser"))
node_databases[("Source and destination DBs")]

node_operator -->|"uses"| node_browser
node_browser -->|"loads"| node_main
node_main -->|"registers tabs"| node_domain_tabs
node_main -->|"registers v2"| node_tenant_tab
node_main -->|"starts"| node_ui_state
node_domain_tabs -->|"requests domain API"| node_flask
node_tenant_tab -->|"requests export API"| node_flask
node_domain_tabs -->|"uses"| node_ui_data
node_tenant_tab -->|"uses"| node_ui_data
node_domain_tabs -->|"previews SQL"| node_sql_preview
node_tenant_tab -->|"previews SQL"| node_sql_preview
node_flask -->|"dispatches branch"| node_branch_service
node_flask -->|"dispatches workflow"| node_workflow_service
node_flask -->|"dispatches flags"| node_flag_service
node_flask -->|"dispatches export"| node_tenant_service
node_flask -->|"dispatches compare"| node_mq_service
node_branch_service -->|"uses utilities"| node_common
node_branch_service -->|"loads generator"| node_branch_scripts
node_workflow_service -->|"uses utilities"| node_common
node_workflow_service -->|"loads generator"| node_workflow_scripts
node_flag_service -->|"uses utilities"| node_common
node_flag_service -->|"loads generator"| node_flag_scripts
node_tenant_service -->|"builds pull queries"| node_tenant_query
node_tenant_service -->|"reads table metadata"| node_tenant_registry
node_tenant_service -->|"validates and generates"| node_tenant_upsert
node_mq_service -->|"compares definitions"| node_mq_script
node_mq_tab -->|"submits definitions"| node_flask
node_tenant_tab -.->|"operator runs queries"| node_databases
node_domain_tabs -.->|"operator runs queries"| node_databases
node_operator -->|"pastes exports and reviews"| node_tenant_tab
node_operator -->|"pastes exports"| node_domain_tabs

click node_main "https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/main.js"
click node_domain_tabs "https://github.com/allen246/sync_tool_feature_flag/tree/main/static/js/tabs"
click node_tenant_tab "https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/tabs/tenant-export.js"
click node_sql_preview "https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/components/sql-preview.js"
click node_ui_data "https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/lib/data.js"
click node_ui_state "https://github.com/allen246/sync_tool_feature_flag/tree/main/static/js/state"
click node_flask "https://github.com/allen246/sync_tool_feature_flag/blob/main/app.py"
click node_branch_service "https://github.com/allen246/sync_tool_feature_flag/blob/main/services/branch_service.py"
click node_workflow_service "https://github.com/allen246/sync_tool_feature_flag/blob/main/services/workflow_service.py"
click node_flag_service "https://github.com/allen246/sync_tool_feature_flag/blob/main/services/feature_flag_service.py"
click node_branch_scripts "https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/branch_product_sync.py"
click node_workflow_scripts "https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/workflow_sync.py"
click node_flag_scripts "https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/feature_flag.py"
click node_common "https://github.com/allen246/sync_tool_feature_flag/blob/main/services/common.py"
click node_tenant_service "https://github.com/allen246/sync_tool_feature_flag/blob/main/services/tenant_export_service.py"
click node_tenant_query "https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/v2/tenant_export_query.py"
click node_tenant_registry "https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/v2/tenant_registry.py"
click node_tenant_upsert "https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/v2/tenant_upsert.py"
click node_mq_tab "https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/tabs/mq.js"
click node_mq_service "https://github.com/allen246/sync_tool_feature_flag/blob/main/services/mq_service.py"
click node_mq_script "https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/mq_comparison.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_main,node_domain_tabs,node_tenant_tab,node_sql_preview,node_ui_data,node_ui_state,node_mq_tab,node_browser toneBlue
class node_flask,node_databases toneAmber
class node_branch_service,node_workflow_service,node_flag_service,node_branch_scripts,node_workflow_scripts,node_flag_scripts,node_common toneMint
class node_tenant_service,node_tenant_query,node_tenant_registry,node_tenant_upsert toneRose
class node_mq_service,node_mq_script,node_operator toneIndigo
```

## Components

### Browser interface

- [UI bootstrap](https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/main.js): `static/js/main.js`
- [Sync domain tabs](https://github.com/allen246/sync_tool_feature_flag/tree/main/static/js/tabs): `static/js/tabs`
- [Tenant export tab](https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/tabs/tenant-export.js): `static/js/tabs/tenant-export.js`
- [SQL preview](https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/components/sql-preview.js): `static/js/components/sql-preview.js`
- [Input and data handling](https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/lib/data.js): `static/js/lib/data.js`
- [Tab and flow state](https://github.com/allen246/sync_tool_feature_flag/tree/main/static/js/state): `static/js/state`
- [Queue comparison tab](https://github.com/allen246/sync_tool_feature_flag/blob/main/static/js/tabs/mq.js): `static/js/tabs/mq.js`

### HTTP API

- [Flask routes](https://github.com/allen246/sync_tool_feature_flag/blob/main/app.py): `app.py`

### Configuration sync

- [Branch service](https://github.com/allen246/sync_tool_feature_flag/blob/main/services/branch_service.py): `services/branch_service.py`
- [Workflow service](https://github.com/allen246/sync_tool_feature_flag/blob/main/services/workflow_service.py): `services/workflow_service.py`
- [Feature flag service](https://github.com/allen246/sync_tool_feature_flag/blob/main/services/feature_flag_service.py): `services/feature_flag_service.py`
- [Branch generators](https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/branch_product_sync.py): `scripts/branch_product_sync.py`
- [Workflow generators](https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/workflow_sync.py): `scripts/workflow_sync.py`
- [Flag generators](https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/feature_flag.py): `scripts/feature_flag.py`
- [Script and query utilities](https://github.com/allen246/sync_tool_feature_flag/blob/main/services/common.py): `services/common.py`

### Tenant export

- [Tenant export service](https://github.com/allen246/sync_tool_feature_flag/blob/main/services/tenant_export_service.py): `services/tenant_export_service.py`
- [Tenant query builders](https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/v2/tenant_export_query.py): `scripts/v2/tenant_export_query.py`
- [Tenant table registry](https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/v2/tenant_registry.py): `scripts/v2/tenant_registry.py`
- [Tenant validation and upsert](https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/v2/tenant_upsert.py): `scripts/v2/tenant_upsert.py`

### Queue comparison

- [Queue comparison service](https://github.com/allen246/sync_tool_feature_flag/blob/main/services/mq_service.py): `services/mq_service.py`
- [Definition comparator](https://github.com/allen246/sync_tool_feature_flag/blob/main/scripts/mq_comparison.py): `scripts/mq_comparison.py`

### Other components

- **Operator**
- **Browser**
- **Source and destination DBs**

## Connections

- Operator → Browser: uses
- Browser → UI bootstrap: loads
- UI bootstrap → Sync domain tabs: registers tabs
- UI bootstrap → Tenant export tab: registers v2
- UI bootstrap → Tab and flow state: starts
- Sync domain tabs → Flask routes: requests domain API
- Tenant export tab → Flask routes: requests export API
- Sync domain tabs → Input and data handling: uses
- Tenant export tab → Input and data handling: uses
- Sync domain tabs → SQL preview: previews SQL
- Tenant export tab → SQL preview: previews SQL
- Flask routes → Branch service: dispatches branch
- Flask routes → Workflow service: dispatches workflow
- Flask routes → Feature flag service: dispatches flags
- Flask routes → Tenant export service: dispatches export
- Flask routes → Queue comparison service: dispatches compare
- Branch service → Script and query utilities: uses utilities
- Branch service → Branch generators: loads generator
- Workflow service → Script and query utilities: uses utilities
- Workflow service → Workflow generators: loads generator
- Feature flag service → Script and query utilities: uses utilities
- Feature flag service → Flag generators: loads generator
- Tenant export service → Tenant query builders: builds pull queries
- Tenant export service → Tenant table registry: reads table metadata
- Tenant export service → Tenant validation and upsert: validates and generates
- Queue comparison service → Definition comparator: compares definitions
- Queue comparison tab → Flask routes: submits definitions
- Tenant export tab → Source and destination DBs: operator runs queries
- Sync domain tabs → Source and destination DBs: operator runs queries
- Operator → Tenant export tab: pastes exports and reviews
- Operator → Sync domain tabs: pastes exports
