# mhiqrambg/gsuite2router architecture

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

- Interactive diagram: https://gitdiagram.com/mhiqrambg/gsuite2router
- Repository: https://github.com/mhiqrambg/gsuite2router

## Overview

gsuite2router is a CLI for adding Google accounts as Antigravity connections on 9Router and scanning, deleting, or resetting connections based on quota and status. For adding, the CLI reads account credentials, requests OAuth authorization from 9Router, uses a fresh Chrome profile for Google login and consent, then exchanges the returned code to create a connection; successful accounts are removed from the input file. The delete command scans provider connections and usage, deletes selected connections, and resets/tests those kept. The OAuth excerpt is partial, so browser details beyond the documented flow are not expanded.

Main entry points: [`gsuite2router/cli.py`](https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/cli.py) (CLI commands), [`gsuite2router/router_api.py`](https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/router_api.py) (9Router API client), [`gsuite2router/google_auth.py`](https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/google_auth.py) (Google login flow), [`gsuite2router/accounts.py`](https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/accounts.py) (Account file I/O)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["CLI orchestration"]
  node_cli["CLI commands<br/>[cli.py]"]
end

subgraph group_inputs["Inputs and config"]
  node_config["Config I/O<br/>[config.py]"]
  node_configfile["Config file"]
  node_accountio["Account file I/O<br/>[accounts.py]"]
  node_accountfile["Account file"]
end

subgraph group_oauth["Google OAuth"]
  node_googleauth["Google login flow<br/>[google_auth.py]"]
end

subgraph group_connections["Connection management"]
  node_routerapi["9Router API client<br/>[router_api.py]"]
  node_deleter["Quota scan and cleanup<br/>[delete.py]"]
end

node_user(("Operator"))
node_router["9Router instance"]
node_chrome["Chrome browser"]
node_google["Google OAuth"]

node_user -->|"runs commands"| node_cli
node_cli -->|"loads and saves"| node_config
node_config -->|"reads and writes"| node_configfile
node_cli -->|"reads accounts"| node_accountio
node_accountio -->|"reads and edits"| node_accountfile
node_cli -->|"logs in and authorizes"| node_routerapi
node_cli -->|"submits credentials"| node_googleauth
node_googleauth -->|"controls browser"| node_chrome
node_chrome -->|"performs OAuth login"| node_google
node_googleauth -->|"returns auth code"| node_cli
node_cli -->|"exchanges auth code"| node_routerapi
node_routerapi -->|"calls REST API"| node_router
node_cli -->|"removes successes"| node_accountio
node_cli -->|"runs cleanup"| node_deleter
node_deleter -->|"scans and manages"| node_routerapi

click node_cli "https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/cli.py"
click node_config "https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/config.py"
click node_accountio "https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/accounts.py"
click node_routerapi "https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/router_api.py"
click node_googleauth "https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/google_auth.py"
click node_deleter "https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/delete.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_cli,node_chrome toneBlue
class node_config,node_configfile,node_accountio,node_accountfile toneAmber
class node_googleauth,node_router toneMint
class node_routerapi,node_deleter toneRose
class node_user,node_google toneIndigo
```

## Components

### CLI orchestration

- [CLI commands](https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/cli.py): `gsuite2router/cli.py`

### Inputs and config

- [Config I/O](https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/config.py): `gsuite2router/config.py`
- **Config file**
- [Account file I/O](https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/accounts.py): `gsuite2router/accounts.py`
- **Account file**

### Google OAuth

- [Google login flow](https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/google_auth.py): `gsuite2router/google_auth.py`

### Connection management

- [9Router API client](https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/router_api.py): `gsuite2router/router_api.py`
- [Quota scan and cleanup](https://github.com/mhiqrambg/gsuite2router/blob/main/gsuite2router/delete.py): `gsuite2router/delete.py`

### Other components

- **Operator**
- **9Router instance**
- **Chrome browser**
- **Google OAuth**

## Connections

- Operator → CLI commands: runs commands
- CLI commands → Config I/O: loads and saves
- Config I/O → Config file: reads and writes
- CLI commands → Account file I/O: reads accounts
- Account file I/O → Account file: reads and edits
- CLI commands → 9Router API client: logs in and authorizes
- CLI commands → Google login flow: submits credentials
- Google login flow → Chrome browser: controls browser
- Chrome browser → Google OAuth: performs OAuth login
- Google login flow → CLI commands: returns auth code
- CLI commands → 9Router API client: exchanges auth code
- 9Router API client → 9Router instance: calls REST API
- CLI commands → Account file I/O: removes successes
- CLI commands → Quota scan and cleanup: runs cleanup
- Quota scan and cleanup → 9Router API client: scans and manages
