# ajdgg/nonebot-plugin-calc24 architecture

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

- Interactive diagram: https://gitdiagram.com/ajdgg/nonebot-plugin-calc24
- Repository: https://github.com/ajdgg/nonebot-plugin-calc24

## Overview

This is a small NoneBot 24-point game plugin. A user starts a round or changes continuous-mode settings through the command handler; the plugin generates a puzzle, accepts replies, validates answers, and either ends the round or starts another. It also supports puzzle replacement, explicit exit, help, and a five-minute inactivity timeout. The graph follows relationships visible in the excerpts and README; it does not infer additional routing or storage behavior from unsampled code.

Main entry points: [`nonebot_plugin_calc24/__init__.py`](https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/__init__.py) (Command and session handlers), [`nonebot_plugin_calc24/file_handle.py`](https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/file_handle.py) (JSON file access), [`nonebot_plugin_calc24/xj_calc24.py`](https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/xj_calc24.py) (Puzzle generation and validation), [`nonebot_plugin_calc24/calc24-data.json`](https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/calc24-data.json) (Puzzle and mode data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Chat interaction"]
  node_command["Command and session handlers<br/>[__init__.py]"]
  node_timeout["Inactivity timeout<br/>[__init__.py]"]
end

subgraph group_game["Game logic"]
  node_game_logic["Puzzle generation and validation<br/>[xj_calc24.py]"]
end

subgraph group_state["State and persistence"]
  node_file_handle["JSON file access<br/>[file_handle.py]"]
  node_game_data["Puzzle and mode data<br/>[calc24-data.json]"]
end

node_user(("Chat user"))
node_nonebot{{"NoneBot runtime"}}

node_user -->|"sends commands"| node_nonebot
node_nonebot -->|"dispatches events"| node_command
node_command -->|"sends replies"| node_nonebot
node_command -->|"generates and checks"| node_game_logic
node_command -->|"schedules timeout"| node_timeout
node_command -->|"reads and changes mode"| node_file_handle
node_game_logic -->|"reads puzzle data"| node_file_handle
node_file_handle -->|"reads and writes JSON"| node_game_data

click node_command "https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/__init__.py"
click node_timeout "https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/__init__.py"
click node_game_logic "https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/xj_calc24.py"
click node_file_handle "https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/file_handle.py"
click node_game_data "https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/calc24-data.json"

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_command,node_timeout,node_user toneBlue
class node_game_logic toneAmber
class node_file_handle,node_game_data toneMint
class node_nonebot toneIndigo
```

## Components

### Chat interaction

- [Command and session handlers](https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/__init__.py): `nonebot_plugin_calc24/__init__.py`
- [Inactivity timeout](https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/__init__.py): `nonebot_plugin_calc24/__init__.py`

### Game logic

- [Puzzle generation and validation](https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/xj_calc24.py): `nonebot_plugin_calc24/xj_calc24.py`

### State and persistence

- [JSON file access](https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/file_handle.py): `nonebot_plugin_calc24/file_handle.py`
- [Puzzle and mode data](https://github.com/ajdgg/nonebot-plugin-calc24/blob/main/nonebot_plugin_calc24/calc24-data.json): `nonebot_plugin_calc24/calc24-data.json`

### Other components

- **Chat user**
- **NoneBot runtime**

## Connections

- Chat user → NoneBot runtime: sends commands (evidence: `README.md`)
- NoneBot runtime → Command and session handlers: dispatches events (evidence: `nonebot_plugin_calc24/__init__.py`)
- Command and session handlers → NoneBot runtime: sends replies (evidence: `nonebot_plugin_calc24/__init__.py`)
- Command and session handlers → Puzzle generation and validation: generates and checks (evidence: `nonebot_plugin_calc24/__init__.py`)
- Command and session handlers → Inactivity timeout: schedules timeout (evidence: `nonebot_plugin_calc24/__init__.py`)
- Command and session handlers → JSON file access: reads and changes mode (evidence: `nonebot_plugin_calc24/__init__.py`)
- Puzzle generation and validation → JSON file access: reads puzzle data (evidence: `nonebot_plugin_calc24/xj_calc24.py`)
- JSON file access → Puzzle and mode data: reads and writes JSON (evidence: `nonebot_plugin_calc24/file_handle.py`)
