# System Architecture Analysis

## Overview

- **Project**: proxy
- **Language**: python
- **Files**: 27
- **Lines**: 11266
- **Functions**: 337
- **Classes**: 45
- **Avg CC**: 3.7
- **Critical (CC≥10)**: 20

## Architecture

### frontend/ (1 files, 344L, 22 functions)

- `proxym-dashboard.jsx` — 344L, 22 methods, CC↑28

### htmlcov/ (1 files, 735L, 65 functions)

- `coverage_html_cb_dd2e7eb5.js` — 735L, 65 methods, CC↑21

### root/ (1 files, 14L, 0 functions)

- `project.sh` — 14L, 0 methods, CC↑0

### scripts/ (2 files, 136L, 0 functions)

- `jetson-entrypoint.sh` — 43L, 0 methods, CC↑0
- `setup.sh` — 93L, 0 methods, CC↑0

### src/proxym/ (4 files, 1241L, 51 functions)

- `main.py` — 638L, 28 methods, CC↑12
- `ctl.py` — 507L, 21 methods, CC↑11
- `config.py` — 93L, 2 methods, CC↑3
- `__init__.py` — 3L, 0 methods, CC↑0

### src/proxym/accounts/ (1 files, 343L, 19 functions)

- `__init__.py` — 343L, 19 methods, CC↑12

### src/proxym/cache/ (1 files, 333L, 10 functions)

- `__init__.py` — 333L, 10 methods, CC↑9

### src/proxym/context/ (5 files, 510L, 20 functions)

- `detector.py` — 208L, 9 methods, CC↑9
- `session.py` — 144L, 8 methods, CC↑6
- `tool_selector.py` — 101L, 2 methods, CC↑5
- `_context.py` — 33L, 1 methods, CC↑3
- `__init__.py` — 24L, 0 methods, CC↑0

### src/proxym/dashboard/ (2 files, 597L, 36 functions)

- `panel.jsx` — 332L, 16 methods, CC↑15
- `__init__.py` — 265L, 20 methods, CC↑3

### src/proxym/mcp/ (4 files, 380L, 16 functions)

- `client.py` — 148L, 4 methods, CC↑6
- `router.py` — 95L, 4 methods, CC↑5
- `registry.py` — 113L, 8 methods, CC↑4
- `__init__.py` — 24L, 0 methods, CC↑0

### src/proxym/middleware/ (1 files, 60L, 3 functions)

- `__init__.py` — 60L, 3 methods, CC↑5

### src/proxym/providers/ (1 files, 330L, 4 functions)

- `__init__.py` — 330L, 4 methods, CC↑8

### src/proxym/router/ (2 files, 581L, 24 functions)

- `__init__.py` — 328L, 10 methods, CC↑11
- `strategy.py` — 253L, 14 methods, CC↑9

### src/proxym/virt/ (7 files, 1207L, 58 functions)

- `_config.py` — 87L, 1 methods, CC↑9
- `browser_profiles.py` — 325L, 11 methods, CC↑9
- `_orchestrator.py` — 510L, 28 methods, CC↑7
- `clonebox_adapter.py` — 209L, 17 methods, CC↑5
- `_check.py` — 17L, 1 methods, CC↑3
- _2 more files_

### src/proxym/virt/profiles/ (1 files, 69L, 4 functions)

- `__init__.py` — 69L, 4 methods, CC↑5

### src/proxym/watch/ (2 files, 150L, 5 functions)

- `__init__.py` — 146L, 5 methods, CC↑5
- `client.py` — 4L, 0 methods, CC↑0

## Key Exports

- **AccountsPanel** (function, CC=15) ⚠ split
- **Dashboard** (function, CC=28) ⚠ split
- **table** (function, CC=21) ⚠ split
- **table_body_rows** (function, CC=21) ⚠ split
- **no_rows** (function, CC=21) ⚠ split
- **footer** (function, CC=21) ⚠ split
- **ratio_columns** (function, CC=21) ⚠ split
- **filter_handler** (function, CC=21) ⚠ split
- **AccountsPanel** (function, CC=15) ⚠ split
- **AccountCredentials** (class, CC̄=5.0)
- **ProjectsConfig** (class, CC̄=9.0)

## Hotspots (High Fan-Out)

- **main** — fan-out=29: Orchestrates 29 calls
- **Dashboard** — fan-out=25: Orchestrates 25 calls
- **chat_completions** — fan-out=22: OpenAI-compatible chat completions with intelligent routing.

Extra headers:
  X
- **detect_firefox_profiles** — fan-out=17: Detect Firefox profiles by parsing profiles.ini.
- **_detect_chromium_family** — fan-out=17: Detect profiles for Chrome/Chromium from Local State file.
- **AccountManager._dict_to_account** — fan-out=16: Orchestrates 16 calls
- **analyze_request** — fan-out=15: Analysis pipeline, 15 stages

## Refactoring Priorities

| # | Action | Impact | Effort |
|---|--------|--------|--------|
| 1 | Split Dashboard (CC=28 → target CC<10) | high | low |
| 2 | Split god module htmlcov/coverage_html_cb_dd2e7eb5.js (735L, 0 classes) | high | high |
| 3 | Split god module src/proxym/main.py (638L, 0 classes) | high | high |
| 4 | Split god module src/proxym/ctl.py (507L, 0 classes) | high | high |
| 5 | Split god module src/proxym/virt/_orchestrator.py (510L, 1 classes) | high | high |
| 6 | Split table (CC=21 → target CC<10) | medium | low |
| 7 | Split table_body_rows (CC=21 → target CC<10) | medium | low |
| 8 | Split no_rows (CC=21 → target CC<10) | medium | low |
| 9 | Split footer (CC=21 → target CC<10) | medium | low |
| 10 | Split ratio_columns (CC=21 → target CC<10) | medium | low |

## Context for LLM

When suggesting changes:
1. Start from hotspots and high-CC functions
2. Follow refactoring priorities above
3. Maintain public API surface — keep backward compatibility
4. Prefer minimal, incremental changes

