# eedcd/hoj-tool architecture

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

- Interactive diagram: https://gitdiagram.com/eedcd/hoj-tool
- Repository: https://github.com/eedcd/hoj-tool

## Overview

HOJ Tool is a Windows-oriented assistant for HOJ-like online judges, with a WebView-hosted web interface and a legacy command-line mode. The main workflow is to configure OJ/browser/AI settings, start an auto-solving mode, let the solver obtain problem data and code through the AI/browser workflow, then submit and verify results. Separate capabilities include account bans and submission analytics. The graph follows the sampled server/API call sites and README-described features; browser-to-API wiring and unsampled implementation details are not asserted.

Main entry points: [`routers/api.py`](https://github.com/eedcd/hoj-tool/blob/main/routers/api.py) (Web API), [`cli/main.py`](https://github.com/eedcd/hoj-tool/blob/main/cli/main.py) (CLI entry), [`server.py`](https://github.com/eedcd/hoj-tool/blob/main/server.py) (Web server), [`module/auto_solver.py`](https://github.com/eedcd/hoj-tool/blob/main/module/auto_solver.py) (Problem solver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webview["Desktop WebView<br/>[main.py]"]
  node_server["Web server<br/>[server.py]"]
  node_pages["Page routes<br/>[pages.py]"]
  node_settings["Settings UI<br/>[index.js]"]
  node_solveui["Solver UI<br/>[index.js]"]
  node_banui["Ban UI<br/>[index.js]"]
  node_statsui["Statistics UI<br/>[index.js]"]
  node_api["Web API<br/>[api.py]"]
  node_port["Port selection<br/>[port_utils.py]"]
end

subgraph group_solve["Auto solving"]
  node_solver["Problem solver<br/>[auto_solver.py]"]
  node_oj["HOJ judge"]
  node_ai["360bot AI"]
end

subgraph group_manage["Account and analytics"]
  node_ban["Account banning<br/>[ban_account.py]"]
  node_statistics["Submission statistics<br/>[statistics.py]"]
end

subgraph group_cli["Legacy CLI"]
  node_cli_main["CLI entry<br/>[main.py]"]
  node_cli_config["CLI configuration<br/>[config.py]"]
  node_cli_interaction["CLI interaction<br/>[interaction.py]"]
  node_cli_api["HOJ client API<br/>[api.py]"]
  node_rank["Rank browser<br/>[rank.py]"]
  node_tools["CLI toolbox<br/>[tools.py]"]
end

node_user(("User"))

node_user -->|"launches"| node_webview
node_webview -->|"opens server URL"| node_server
node_server -->|"selects port"| node_port
node_server -->|"registers routes"| node_pages
node_server -->|"registers API"| node_api
node_user -->|"configures"| node_settings
node_settings -.->|"uses configuration API"| node_api
node_user -->|"chooses solve mode"| node_solveui
node_solveui -.->|"starts solver"| node_api
node_api -->|"starts training task"| node_solver
node_solver -->|"fetches problems and submits"| node_oj
node_solver -->|"requests solutions"| node_ai
node_user -->|"requests account ban"| node_banui
node_banui -.->|"uses ban API"| node_api
node_api -.->|"dispatches ban work"| node_ban
node_user -.->|"views analytics"| node_statsui
node_statsui -.->|"requests statistics"| node_api
node_api -->|"gets statistics"| node_statistics
node_statistics -->|"fetches submissions"| node_oj
node_user -->|"runs legacy mode"| node_cli_main
node_cli_main -->|"loads settings"| node_cli_config
node_cli_main -->|"prompts user"| node_cli_interaction
node_cli_main -->|"creates client"| node_cli_api
node_cli_main -->|"dispatches ranking"| node_rank
node_rank -->|"fetches rankings"| node_cli_api
node_rank -->|"renders ranking"| node_cli_interaction
node_cli_main -->|"dispatches toolbox"| node_tools
node_tools -->|"uses HOJ client"| node_cli_api

click node_webview "https://github.com/eedcd/hoj-tool/blob/main/main.py"
click node_server "https://github.com/eedcd/hoj-tool/blob/main/server.py"
click node_pages "https://github.com/eedcd/hoj-tool/blob/main/routers/pages.py"
click node_settings "https://github.com/eedcd/hoj-tool/blob/main/static/settings/index.js"
click node_solveui "https://github.com/eedcd/hoj-tool/blob/main/static/auto_solver/index.js"
click node_banui "https://github.com/eedcd/hoj-tool/blob/main/static/ban_account/index.js"
click node_statsui "https://github.com/eedcd/hoj-tool/blob/main/static/statistics/index.js"
click node_api "https://github.com/eedcd/hoj-tool/blob/main/routers/api.py"
click node_solver "https://github.com/eedcd/hoj-tool/blob/main/module/auto_solver.py"
click node_ban "https://github.com/eedcd/hoj-tool/blob/main/module/ban_account.py"
click node_statistics "https://github.com/eedcd/hoj-tool/blob/main/module/statistics.py"
click node_cli_main "https://github.com/eedcd/hoj-tool/blob/main/cli/main.py"
click node_cli_config "https://github.com/eedcd/hoj-tool/blob/main/cli/lib/config.py"
click node_cli_interaction "https://github.com/eedcd/hoj-tool/blob/main/cli/lib/interaction.py"
click node_cli_api "https://github.com/eedcd/hoj-tool/blob/main/cli/lib/api.py"
click node_rank "https://github.com/eedcd/hoj-tool/blob/main/cli/module/rank.py"
click node_tools "https://github.com/eedcd/hoj-tool/blob/main/cli/module/tools.py"
click node_port "https://github.com/eedcd/hoj-tool/blob/main/lib/port_utils.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_webview,node_server,node_pages,node_settings,node_solveui,node_banui,node_statsui,node_api,node_port,node_user toneBlue
class node_solver,node_oj,node_ai toneAmber
class node_ban,node_statistics toneMint
class node_cli_main,node_cli_config,node_cli_interaction,node_cli_api,node_rank,node_tools toneRose
```

## Components

### Web application

- [Desktop WebView](https://github.com/eedcd/hoj-tool/blob/main/main.py): `main.py`
- [Web server](https://github.com/eedcd/hoj-tool/blob/main/server.py): `server.py`
- [Page routes](https://github.com/eedcd/hoj-tool/blob/main/routers/pages.py): `routers/pages.py`
- [Settings UI](https://github.com/eedcd/hoj-tool/blob/main/static/settings/index.js): `static/settings/index.js`
- [Solver UI](https://github.com/eedcd/hoj-tool/blob/main/static/auto_solver/index.js): `static/auto_solver/index.js`
- [Ban UI](https://github.com/eedcd/hoj-tool/blob/main/static/ban_account/index.js): `static/ban_account/index.js`
- [Statistics UI](https://github.com/eedcd/hoj-tool/blob/main/static/statistics/index.js): `static/statistics/index.js`
- [Web API](https://github.com/eedcd/hoj-tool/blob/main/routers/api.py): `routers/api.py`
- [Port selection](https://github.com/eedcd/hoj-tool/blob/main/lib/port_utils.py): `lib/port_utils.py`

### Auto solving

- [Problem solver](https://github.com/eedcd/hoj-tool/blob/main/module/auto_solver.py): `module/auto_solver.py`
- **HOJ judge**
- **360bot AI**

### Account and analytics

- [Account banning](https://github.com/eedcd/hoj-tool/blob/main/module/ban_account.py): `module/ban_account.py`
- [Submission statistics](https://github.com/eedcd/hoj-tool/blob/main/module/statistics.py): `module/statistics.py`

### Legacy CLI

- [CLI entry](https://github.com/eedcd/hoj-tool/blob/main/cli/main.py): `cli/main.py`
- [CLI configuration](https://github.com/eedcd/hoj-tool/blob/main/cli/lib/config.py): `cli/lib/config.py`
- [CLI interaction](https://github.com/eedcd/hoj-tool/blob/main/cli/lib/interaction.py): `cli/lib/interaction.py`
- [HOJ client API](https://github.com/eedcd/hoj-tool/blob/main/cli/lib/api.py): `cli/lib/api.py`
- [Rank browser](https://github.com/eedcd/hoj-tool/blob/main/cli/module/rank.py): `cli/module/rank.py`
- [CLI toolbox](https://github.com/eedcd/hoj-tool/blob/main/cli/module/tools.py): `cli/module/tools.py`

### Other components

- **User**

## Connections

- User → Desktop WebView: launches (evidence: `README.md`)
- Desktop WebView → Web server: opens server URL (evidence: `main.py`)
- Web server → Port selection: selects port (evidence: `server.py`)
- Web server → Page routes: registers routes (evidence: `server.py`)
- Web server → Web API: registers API (evidence: `server.py`)
- User → Settings UI: configures (evidence: `README.md`)
- Settings UI → Web API: uses configuration API
- User → Solver UI: chooses solve mode (evidence: `README.md`)
- Solver UI → Web API: starts solver
- Web API → Problem solver: starts training task (evidence: `routers/api.py`)
- Problem solver → HOJ judge: fetches problems and submits (evidence: `module/auto_solver.py`)
- Problem solver → 360bot AI: requests solutions (evidence: `README.md`)
- User → Ban UI: requests account ban (evidence: `README.md`)
- Ban UI → Web API: uses ban API
- Web API → Account banning: dispatches ban work (evidence: `routers/api.py`)
- User → Statistics UI: views analytics
- Statistics UI → Web API: requests statistics
- Web API → Submission statistics: gets statistics (evidence: `routers/api.py`)
- Submission statistics → HOJ judge: fetches submissions (evidence: `module/statistics.py`)
- User → CLI entry: runs legacy mode (evidence: `README.md`)
- CLI entry → CLI configuration: loads settings (evidence: `cli/main.py`)
- CLI entry → CLI interaction: prompts user (evidence: `cli/main.py`)
- CLI entry → HOJ client API: creates client (evidence: `cli/main.py`)
- CLI entry → Rank browser: dispatches ranking (evidence: `cli/main.py`)
- Rank browser → HOJ client API: fetches rankings (evidence: `cli/module/rank.py`)
- Rank browser → CLI interaction: renders ranking (evidence: `cli/module/rank.py`)
- CLI entry → CLI toolbox: dispatches toolbox (evidence: `cli/main.py`)
- CLI toolbox → HOJ client API: uses HOJ client (evidence: `cli/module/tools.py`)
