# styayur/codex-mode-switcher architecture

> Architecture diagram of the GitHub repository styayur/codex-mode-switcher, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/styayur/codex-mode-switcher
- Repository: https://github.com/styayur/codex-mode-switcher

## Overview

Codex Mode Switcher is a single-script PowerShell utility for switching between Codex’s OpenAI/ChatGPT selection and one saved custom provider. The user invokes commands through `codex-mode.ps1`; the documented workflows inspect or update Codex configuration, preserve provider state and backups, and optionally query or invoke the Codex CLI. The README documents these behaviors, but no source excerpts were provided, so internal implementation details are not inferred.

Main entry points: [`codex-mode.ps1`](https://github.com/styayur/codex-mode-switcher/blob/main/codex-mode.ps1) (GPT mode)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commands["Mode commands"]
  node_switcher["Mode switcher<br/>[codex-mode.ps1]"]
  node_status["Status and init<br/>[codex-mode.ps1]"]
  node_gpt["GPT mode<br/>[codex-mode.ps1]"]
  node_restore["Provider restore<br/>[codex-mode.ps1]"]
end

subgraph group_storage["Local configuration"]
  node_config["Codex config"]
  node_provider_state["Saved provider state"]
  node_backups["Config and state backups"]
end

subgraph group_integration["Codex integration"]
  node_codex_cli["Codex CLI"]
  node_credential_store[("Codex credential store")]
end

node_user(("User"))

node_user -->|"invokes"| node_switcher
node_switcher -->|"dispatches"| node_status
node_switcher -->|"dispatches"| node_gpt
node_switcher -->|"dispatches"| node_restore
node_status -->|"reads"| node_config
node_status -->|"queries login"| node_codex_cli
node_status -->|"checks presence"| node_provider_state
node_gpt -->|"updates selection"| node_config
node_gpt -->|"saves provider"| node_provider_state
node_gpt -->|"creates backup"| node_backups
node_gpt -->|"checks or logs in"| node_codex_cli
node_restore -->|"validates and reads"| node_provider_state
node_restore -->|"restores selection"| node_config
node_restore -->|"creates backup"| node_backups
node_codex_cli -.->|"may update"| node_credential_store

click node_switcher "https://github.com/styayur/codex-mode-switcher/blob/main/codex-mode.ps1"
click node_status "https://github.com/styayur/codex-mode-switcher/blob/main/codex-mode.ps1"
click node_gpt "https://github.com/styayur/codex-mode-switcher/blob/main/codex-mode.ps1"
click node_restore "https://github.com/styayur/codex-mode-switcher/blob/main/codex-mode.ps1"

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_switcher,node_status,node_gpt,node_restore,node_user toneBlue
class node_config,node_provider_state,node_backups toneAmber
class node_codex_cli,node_credential_store toneMint
```

## Components

### Mode commands

- [Mode switcher](https://github.com/styayur/codex-mode-switcher/blob/main/codex-mode.ps1): `codex-mode.ps1`
- [Status and init](https://github.com/styayur/codex-mode-switcher/blob/main/codex-mode.ps1): `codex-mode.ps1`
- [GPT mode](https://github.com/styayur/codex-mode-switcher/blob/main/codex-mode.ps1): `codex-mode.ps1`
- [Provider restore](https://github.com/styayur/codex-mode-switcher/blob/main/codex-mode.ps1): `codex-mode.ps1`

### Local configuration

- **Codex config**
- **Saved provider state**
- **Config and state backups**

### Codex integration

- **Codex CLI**
- **Codex credential store**

### Other components

- **User**

## Connections

- User → Mode switcher: invokes (evidence: `README.md`)
- Mode switcher → Status and init: dispatches (evidence: `README.md`)
- Mode switcher → GPT mode: dispatches (evidence: `README.md`)
- Mode switcher → Provider restore: dispatches (evidence: `README.md`)
- Status and init → Codex config: reads (evidence: `README.md`)
- Status and init → Codex CLI: queries login (evidence: `README.md`)
- Status and init → Saved provider state: checks presence (evidence: `README.md`)
- GPT mode → Codex config: updates selection (evidence: `README.md`)
- GPT mode → Saved provider state: saves provider (evidence: `README.md`)
- GPT mode → Config and state backups: creates backup (evidence: `README.md`)
- GPT mode → Codex CLI: checks or logs in (evidence: `README.md`)
- Provider restore → Saved provider state: validates and reads (evidence: `README.md`)
- Provider restore → Codex config: restores selection (evidence: `README.md`)
- Provider restore → Config and state backups: creates backup (evidence: `README.md`)
- Codex CLI → Codex credential store: may update (evidence: `README.md`)
