# github-community-projects/safe-settings architecture

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

- Interactive diagram: https://gitdiagram.com/github-community-projects/safe-settings
- Repository: https://github.com/github-community-projects/safe-settings

## Overview

Safe-Settings is a GitHub App for centrally defining and enforcing organization and repository policy. Its main workflow handles GitHub events, loads admin-repository YAML, combines organization, suborg, and repo policy, then applies changes to target repositories or validates proposed changes in dry-run mode and reports results. The map also includes policy generation and enterprise app-installation management. Relationships are based on the README and shown source/index references; unsampled implementation details are not asserted.

Main entry points: [`lib/settings.js`](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settings.js) (Settings orchestration), [`index.js`](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/index.js) (Safe-Settings app), [`lib/configManager.js`](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/configManager.js) (YAML config loader), [`lib/mergeDeep.js`](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/mergeDeep.js) (Policy merge and comparison)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_event_flow["Event orchestration"]
  node_app["Safe-Settings app<br/>[index.js]"]
  node_cron_sync["Scheduled sync<br/>[index.js]"]
end

subgraph group_policy_config["Policy configuration"]
  node_admin_repo[("Admin repository")]
  node_config_manager["YAML config loader<br/>[configManager.js]"]
  node_org_policy["Organization policy<br/>[settings.js]"]
  node_suborg_policy["Suborg policy<br/>[settings.js]"]
  node_repo_policy["Repository policy<br/>[settings.js]"]
  node_policy_merge["Policy merge and comparison<br/>[mergeDeep.js]"]
  node_repo_selector["Repository targeting<br/>[repoSelector.js]"]
end

subgraph group_reconciliation["Policy reconciliation"]
  node_settings_engine["Settings orchestration<br/>[settings.js]"]
  node_repo_settings["Repository settings<br/>[repository.js]"]
  node_branch_rules["Branches and rulesets<br/>[branches.js]"]
  node_team_access["Teams and access<br/>[teams.js]"]
  node_environments["Environments<br/>[environments.js]"]
  node_variables_properties["Variables and properties<br/>[variables.js]"]
  node_other_plugins["Other settings plugins<br/>[diffable.js]"]
  node_target_repos[("Organization repositories")]
end

subgraph group_reporting_admin["Validation and administration"]
  node_dry_run["Dry-run validation<br/>[index.js]"]
  node_checks_comments["Checks and PR reports<br/>[index.js]"]
  node_settings_generator["Settings generator"]
  node_app_installations["App installations"]
  node_nop_commands["No-op change records<br/>[nopcommand.js]"]
end

node_github(("GitHub events"))

node_github -->|"sends events"| node_app
node_cron_sync -->|"triggers sync"| node_app
node_app -->|"fetches policy"| node_admin_repo
node_config_manager -->|"loads YAML"| node_admin_repo
node_admin_repo -->|"returns config"| node_config_manager
node_app -->|"loads config"| node_config_manager
node_config_manager -->|"provides settings"| node_org_policy
node_config_manager -->|"provides settings"| node_suborg_policy
node_config_manager -->|"provides settings"| node_repo_policy
node_org_policy -->|"overlaid by suborg"| node_policy_merge
node_suborg_policy -->|"overlaid by repo"| node_policy_merge
node_repo_policy -->|"sets precedence"| node_policy_merge
node_app -->|"processes policy"| node_settings_engine
node_policy_merge -->|"supplies merged policy"| node_settings_engine
node_settings_engine -.->|"targets repositories"| node_repo_selector
node_settings_engine -->|"reconciles"| node_repo_settings
node_settings_engine -->|"reconciles"| node_branch_rules
node_settings_engine -->|"reconciles"| node_team_access
node_settings_engine -->|"reconciles"| node_environments
node_settings_engine -.->|"reconciles"| node_variables_properties
node_settings_engine -->|"dispatches plugins"| node_other_plugins
node_repo_settings -->|"applies settings"| node_target_repos
node_branch_rules -.->|"updates protections"| node_target_repos
node_team_access -->|"updates access"| node_target_repos
node_environments -->|"updates environments"| node_target_repos
node_variables_properties -.->|"updates policy data"| node_target_repos
node_app -->|"validates PR changes"| node_dry_run
node_dry_run -->|"reports results"| node_checks_comments
node_settings_engine -->|"records planned changes"| node_nop_commands
node_app -->|"generates policy"| node_settings_generator
node_settings_generator -.->|"writes generated config"| node_admin_repo
node_app -.->|"manages installations"| node_app_installations

click node_app "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/index.js"
click node_cron_sync "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/index.js"
click node_config_manager "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/configManager.js"
click node_org_policy "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settings.js"
click node_suborg_policy "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settings.js"
click node_repo_policy "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settings.js"
click node_policy_merge "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/mergeDeep.js"
click node_repo_selector "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/repoSelector.js"
click node_settings_engine "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settings.js"
click node_repo_settings "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/repository.js"
click node_branch_rules "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/branches.js"
click node_team_access "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/teams.js"
click node_environments "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/environments.js"
click node_variables_properties "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/variables.js"
click node_other_plugins "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/diffable.js"
click node_dry_run "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/index.js"
click node_checks_comments "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/index.js"
click node_settings_generator "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settingsGenerator.js"
click node_app_installations "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/appOctokitClient.js"
click node_nop_commands "https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/nopcommand.js"

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_cron_sync toneBlue
class node_admin_repo,node_config_manager,node_org_policy,node_suborg_policy,node_repo_policy,node_policy_merge,node_repo_selector toneAmber
class node_settings_engine,node_repo_settings,node_branch_rules,node_team_access,node_environments,node_variables_properties,node_other_plugins,node_target_repos toneMint
class node_dry_run,node_checks_comments,node_settings_generator,node_app_installations,node_nop_commands toneRose
class node_github toneIndigo
```

## Components

### Event orchestration

- [Safe-Settings app](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/index.js): `index.js`
- [Scheduled sync](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/index.js): `index.js`

### Policy configuration

- **Admin repository**
- [YAML config loader](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/configManager.js): `lib/configManager.js`
- [Organization policy](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settings.js): `lib/settings.js`
- [Suborg policy](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settings.js): `lib/settings.js`
- [Repository policy](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settings.js): `lib/settings.js`
- [Policy merge and comparison](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/mergeDeep.js): `lib/mergeDeep.js`
- [Repository targeting](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/repoSelector.js): `lib/repoSelector.js`

### Policy reconciliation

- [Settings orchestration](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settings.js): `lib/settings.js`
- [Repository settings](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/repository.js): `lib/plugins/repository.js`
- [Branches and rulesets](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/branches.js): `lib/plugins/branches.js`
- [Teams and access](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/teams.js): `lib/plugins/teams.js`
- [Environments](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/environments.js): `lib/plugins/environments.js`
- [Variables and properties](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/variables.js): `lib/plugins/variables.js`
- [Other settings plugins](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/plugins/diffable.js): `lib/plugins/diffable.js`
- **Organization repositories**

### Validation and administration

- [Dry-run validation](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/index.js): `index.js`
- [Checks and PR reports](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/index.js): `index.js`
- [Settings generator](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/settingsGenerator.js): `lib/settingsGenerator.js`
- [App installations](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/appOctokitClient.js): `lib/appOctokitClient.js`
- [No-op change records](https://github.com/github-community-projects/safe-settings/blob/main-enterprise/lib/nopcommand.js): `lib/nopcommand.js`

### Other components

- **GitHub events**

## Connections

- GitHub events → Safe-Settings app: sends events (evidence: `README.md`)
- Scheduled sync → Safe-Settings app: triggers sync (evidence: `README.md`)
- Safe-Settings app → Admin repository: fetches policy (evidence: `README.md`)
- YAML config loader → Admin repository: loads YAML (evidence: `lib/configManager.js`)
- Admin repository → YAML config loader: returns config (evidence: `lib/configManager.js`)
- Safe-Settings app → YAML config loader: loads config (evidence: `README.md`)
- YAML config loader → Organization policy: provides settings (evidence: `README.md`)
- YAML config loader → Suborg policy: provides settings (evidence: `README.md`)
- YAML config loader → Repository policy: provides settings (evidence: `README.md`)
- Organization policy → Policy merge and comparison: overlaid by suborg (evidence: `README.md`)
- Suborg policy → Policy merge and comparison: overlaid by repo (evidence: `README.md`)
- Repository policy → Policy merge and comparison: sets precedence (evidence: `README.md`)
- Safe-Settings app → Settings orchestration: processes policy (evidence: `README.md`)
- Policy merge and comparison → Settings orchestration: supplies merged policy (evidence: `README.md`)
- Settings orchestration → Repository targeting: targets repositories (evidence: `lib/settings.js`)
- Settings orchestration → Repository settings: reconciles (evidence: `lib/settings.js`)
- Settings orchestration → Branches and rulesets: reconciles (evidence: `lib/settings.js`)
- Settings orchestration → Teams and access: reconciles (evidence: `lib/settings.js`)
- Settings orchestration → Environments: reconciles (evidence: `lib/settings.js`)
- Settings orchestration → Variables and properties: reconciles (evidence: `lib/settings.js`)
- Settings orchestration → Other settings plugins: dispatches plugins (evidence: `lib/settings.js`)
- Repository settings → Organization repositories: applies settings (evidence: `lib/plugins/repository.js`)
- Branches and rulesets → Organization repositories: updates protections
- Teams and access → Organization repositories: updates access (evidence: `lib/plugins/teams.js`)
- Environments → Organization repositories: updates environments (evidence: `lib/plugins/environments.js`)
- Variables and properties → Organization repositories: updates policy data
- Safe-Settings app → Dry-run validation: validates PR changes (evidence: `README.md`)
- Dry-run validation → Checks and PR reports: reports results (evidence: `README.md`)
- Settings orchestration → No-op change records: records planned changes (evidence: `lib/nopcommand.js`)
- Safe-Settings app → Settings generator: generates policy (evidence: `index.js`)
- Settings generator → Admin repository: writes generated config
- Safe-Settings app → App installations: manages installations (evidence: `index.js`)
