# akgta/pydbmng architecture

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

- Interactive diagram: https://gitdiagram.com/akgta/pydbmng
- Repository: https://github.com/akgta/pydbmng

## Overview

This repository is a Python SQLite persistence engine, demonstrated by a small player-data application. The main workflow registers load/save callbacks, turns player state into a table payload, and asks the hook system to persist it; loading routes stored data back through the registered callback. The hook module also provides schema management, table cleanup, and a locked background sync loop. README-described timing and capabilities supplement the partial hook excerpt; encryption is present as a separate utility, but no connection to persistence is shown.

Main entry points: [`Module/hook.py`](https://github.com/akgta/pydbmng/blob/main/Module/hook.py) (Hook API), [`main.py`](https://github.com/akgta/pydbmng/blob/main/main.py) (Player Application), [`database.db`](https://github.com/akgta/pydbmng/blob/main/database.db) (SQLite Database), [`Module/debugger.py`](https://github.com/akgta/pydbmng/blob/main/Module/debugger.py) (Debug Decorators)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application Data"]
  node_app["Player Application<br/>[main.py]"]
  node_player_state["Player State<br/>[main.py]"]
end

subgraph group_persistence["Persistence Engine"]
  node_hook_api["Hook API<br/>[hook.py]"]
  node_hook_registry["Callback Registry<br/>[hook.py]"]
  node_memory_cache["Save Cache<br/>[hook.py]"]
  node_save_router["Save Router<br/>[hook.py]"]
  node_load_router["Load Router<br/>[hook.py]"]
  node_schema["Schema Manager<br/>[hook.py]"]
  node_table_cleanup["Table Cleanup<br/>[hook.py]"]
  node_worker["Background Worker<br/>[hook.py]"]
  node_db_lock["Database Lock<br/>[hook.py]"]
  node_sqlite_engine["SQLite Engine<br/>[hook.py]"]
  node_database[("SQLite Database<br/>[database.db]")]
end

subgraph group_observability["Debugging"]
  node_debugger["Debug Decorators<br/>[debugger.py]"]
end

subgraph group_security["Crypto Utilities"]
  node_crypto["Encryption Utilities<br/>[encrypt.py]"]
end

node_app -->|"registers hooks"| node_hook_api
node_app -->|"requests save"| node_hook_api
node_player_state -->|"provides save data"| node_app
node_hook_api -->|"registers callbacks"| node_hook_registry
node_hook_api -->|"routes saves"| node_save_router
node_hook_api -->|"routes loads"| node_load_router
node_save_router -->|"calls save callback"| node_hook_registry
node_save_router -->|"updates payload"| node_memory_cache
node_save_router -->|"inserts rows"| node_sqlite_engine
node_load_router -->|"queries rows"| node_sqlite_engine
node_load_router -->|"stores results"| node_memory_cache
node_load_router -->|"calls load callback"| node_hook_registry
node_sqlite_engine -->|"ensures columns"| node_schema
node_sqlite_engine -->|"reads and writes"| node_database
node_table_cleanup -->|"drops table"| node_database
node_table_cleanup -->|"clears state"| node_memory_cache
node_worker -->|"locks cycles"| node_db_lock
node_worker -->|"triggers periodic loads"| node_load_router
node_worker -->|"triggers periodic saves"| node_save_router
node_hook_api -->|"decorated by"| node_debugger
node_crypto -->|"uses decorators"| node_debugger

click node_app "https://github.com/akgta/pydbmng/blob/main/main.py"
click node_player_state "https://github.com/akgta/pydbmng/blob/main/main.py"
click node_hook_api "https://github.com/akgta/pydbmng/blob/main/Module/hook.py"
click node_hook_registry "https://github.com/akgta/pydbmng/blob/main/Module/hook.py"
click node_memory_cache "https://github.com/akgta/pydbmng/blob/main/Module/hook.py"
click node_save_router "https://github.com/akgta/pydbmng/blob/main/Module/hook.py"
click node_load_router "https://github.com/akgta/pydbmng/blob/main/Module/hook.py"
click node_schema "https://github.com/akgta/pydbmng/blob/main/Module/hook.py"
click node_table_cleanup "https://github.com/akgta/pydbmng/blob/main/Module/hook.py"
click node_worker "https://github.com/akgta/pydbmng/blob/main/Module/hook.py"
click node_db_lock "https://github.com/akgta/pydbmng/blob/main/Module/hook.py"
click node_sqlite_engine "https://github.com/akgta/pydbmng/blob/main/Module/hook.py"
click node_database "https://github.com/akgta/pydbmng/blob/main/database.db"
click node_debugger "https://github.com/akgta/pydbmng/blob/main/Module/debugger.py"
click node_crypto "https://github.com/akgta/pydbmng/blob/main/Module/encrypt.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_app,node_player_state toneBlue
class node_hook_api,node_hook_registry,node_memory_cache,node_save_router,node_load_router,node_schema,node_table_cleanup,node_worker,node_db_lock,node_sqlite_engine,node_database toneAmber
class node_debugger toneMint
class node_crypto toneRose
```

## Components

### Application Data

- [Player Application](https://github.com/akgta/pydbmng/blob/main/main.py): `main.py`
- [Player State](https://github.com/akgta/pydbmng/blob/main/main.py): `main.py`

### Persistence Engine

- [Hook API](https://github.com/akgta/pydbmng/blob/main/Module/hook.py): `Module/hook.py`
- [Callback Registry](https://github.com/akgta/pydbmng/blob/main/Module/hook.py): `Module/hook.py`
- [Save Cache](https://github.com/akgta/pydbmng/blob/main/Module/hook.py): `Module/hook.py`
- [Save Router](https://github.com/akgta/pydbmng/blob/main/Module/hook.py): `Module/hook.py`
- [Load Router](https://github.com/akgta/pydbmng/blob/main/Module/hook.py): `Module/hook.py`
- [Schema Manager](https://github.com/akgta/pydbmng/blob/main/Module/hook.py): `Module/hook.py`
- [Table Cleanup](https://github.com/akgta/pydbmng/blob/main/Module/hook.py): `Module/hook.py`
- [Background Worker](https://github.com/akgta/pydbmng/blob/main/Module/hook.py): `Module/hook.py`
- [Database Lock](https://github.com/akgta/pydbmng/blob/main/Module/hook.py): `Module/hook.py`
- [SQLite Engine](https://github.com/akgta/pydbmng/blob/main/Module/hook.py): `Module/hook.py`
- [SQLite Database](https://github.com/akgta/pydbmng/blob/main/database.db): `database.db`

### Debugging

- [Debug Decorators](https://github.com/akgta/pydbmng/blob/main/Module/debugger.py): `Module/debugger.py`

### Crypto Utilities

- [Encryption Utilities](https://github.com/akgta/pydbmng/blob/main/Module/encrypt.py): `Module/encrypt.py`

## Connections

- Player Application → Hook API: registers hooks (evidence: `main.py`)
- Player Application → Hook API: requests save (evidence: `main.py`)
- Player State → Player Application: provides save data (evidence: `main.py`)
- Hook API → Callback Registry: registers callbacks (evidence: `README.txt`)
- Hook API → Save Router: routes saves (evidence: `Module/hook.py`)
- Hook API → Load Router: routes loads (evidence: `README.txt`)
- Save Router → Callback Registry: calls save callback (evidence: `Module/hook.py`)
- Save Router → Save Cache: updates payload (evidence: `Module/hook.py`)
- Save Router → SQLite Engine: inserts rows (evidence: `Module/hook.py`)
- Load Router → SQLite Engine: queries rows (evidence: `Module/hook.py`)
- Load Router → Save Cache: stores results (evidence: `Module/hook.py`)
- Load Router → Callback Registry: calls load callback (evidence: `Module/hook.py`)
- SQLite Engine → Schema Manager: ensures columns (evidence: `Module/hook.py`)
- SQLite Engine → SQLite Database: reads and writes (evidence: `README.txt`)
- Table Cleanup → SQLite Database: drops table (evidence: `Module/hook.py`)
- Table Cleanup → Save Cache: clears state (evidence: `Module/hook.py`)
- Background Worker → Database Lock: locks cycles (evidence: `Module/hook.py`)
- Background Worker → Load Router: triggers periodic loads (evidence: `Module/hook.py`)
- Background Worker → Save Router: triggers periodic saves (evidence: `README.txt`)
- Hook API → Debug Decorators: decorated by (evidence: `Module/hook.py`)
- Encryption Utilities → Debug Decorators: uses decorators (evidence: `Module/encrypt.py`)
