# zomarrd/databaseapi_nukkit architecture

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

- Interactive diagram: https://gitdiagram.com/zomarrd/databaseapi_nukkit
- Repository: https://github.com/zomarrd/databaseapi_nukkit

## Overview

Database API is a NukkitX-facing library for configuring MariaDB/MySQL connections and issuing asynchronous SQL operations with optional callbacks. The principal workflow is plugin code selecting a database type and connection details, initializing the matching implementation, connecting, then querying and handling completion. The core Database class also provides select/insert/update operations. Source excerpts establish the execution and driver behavior; broader behavior is summarized from the README, and no relationships are inferred solely from module names.

Main entry points: [`src/main/java/dev/zomarrd/dbapi/DatabaseLib.kt`](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/DatabaseLib.kt) (Database factory), [`src/main/java/dev/zomarrd/dbapi/Database.kt`](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/Database.kt) (Database operations), [`src/main/java/dev/zomarrd/dbapi/SQLConnectionInfo.java`](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/SQLConnectionInfo.java) (Connection contract), [`src/main/java/dev/zomarrd/dbapi/mariadb/MariaDB.kt`](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/mariadb/MariaDB.kt) (MariaDB driver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Connection setup"]
  node_factory["Database factory<br/>[DatabaseLib.kt]"]
  node_sqltype["Database type<br/>[SQLType.java]"]
  node_connection_contract["Connection contract"]
  node_maria_config["MariaDB config<br/>[ConnectionInfo.kt]"]
  node_mysql_config["MySQL config<br/>[ConnectionInfo.kt]"]
end

subgraph group_runtime["Database runtime"]
  node_mariadb["MariaDB driver<br/>[MariaDB.kt]"]
  node_mysql["MySQL driver<br/>[MySQL.kt]"]
  node_database["Database operations<br/>[Database.kt]"]
  node_pair["Column-value pair<br/>[Pair.kt]"]
end

subgraph group_results["Query results"]
  node_callback["Callback results<br/>[ResultCallback.kt]"]
end

node_plugin(("Plugin code"))
node_sql_server[("SQL server")]

node_plugin -->|"initializes"| node_factory
node_factory -->|"selects type"| node_sqltype
node_factory -->|"creates"| node_mariadb
node_factory -->|"creates"| node_mysql
node_plugin -->|"configures"| node_maria_config
node_plugin -.->|"configures"| node_mysql_config
node_maria_config -->|"implements"| node_connection_contract
node_mysql_config -->|"implements"| node_connection_contract
node_factory -->|"accepts info"| node_connection_contract
node_plugin -->|"connects"| node_database
node_plugin -->|"queries"| node_database
node_mariadb -->|"reads URL"| node_connection_contract
node_mysql -->|"reads URL"| node_connection_contract
node_mariadb -->|"connects"| node_sql_server
node_mysql -->|"connects"| node_sql_server
node_database -->|"executes SQL"| node_sql_server
node_database -->|"uses values"| node_pair
node_database -->|"notifies"| node_callback
node_callback -->|"returns result"| node_plugin

click node_factory "https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/DatabaseLib.kt"
click node_sqltype "https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/SQLType.java"
click node_connection_contract "https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/SQLConnectionInfo.java"
click node_maria_config "https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/mariadb/ConnectionInfo.kt"
click node_mysql_config "https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/mysql/ConnectionInfo.kt"
click node_mariadb "https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/mariadb/MariaDB.kt"
click node_mysql "https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/mysql/MySQL.kt"
click node_database "https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/Database.kt"
click node_pair "https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/utils/Pair.kt"
click node_callback "https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/utils/ResultCallback.kt"

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_factory,node_sqltype,node_connection_contract,node_maria_config,node_mysql_config toneBlue
class node_mariadb,node_mysql,node_database,node_pair,node_sql_server toneAmber
class node_callback toneMint
class node_plugin toneIndigo
```

## Components

### Connection setup

- [Database factory](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/DatabaseLib.kt): `src/main/java/dev/zomarrd/dbapi/DatabaseLib.kt`
- [Database type](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/SQLType.java): `src/main/java/dev/zomarrd/dbapi/SQLType.java`
- [Connection contract](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/SQLConnectionInfo.java): `src/main/java/dev/zomarrd/dbapi/SQLConnectionInfo.java`
- [MariaDB config](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/mariadb/ConnectionInfo.kt): `src/main/java/dev/zomarrd/dbapi/mariadb/ConnectionInfo.kt`
- [MySQL config](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/mysql/ConnectionInfo.kt): `src/main/java/dev/zomarrd/dbapi/mysql/ConnectionInfo.kt`

### Database runtime

- [MariaDB driver](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/mariadb/MariaDB.kt): `src/main/java/dev/zomarrd/dbapi/mariadb/MariaDB.kt`
- [MySQL driver](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/mysql/MySQL.kt): `src/main/java/dev/zomarrd/dbapi/mysql/MySQL.kt`
- [Database operations](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/Database.kt): `src/main/java/dev/zomarrd/dbapi/Database.kt`
- [Column-value pair](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/utils/Pair.kt): `src/main/java/dev/zomarrd/dbapi/utils/Pair.kt`

### Query results

- [Callback results](https://github.com/zomarrd/databaseapi_nukkit/blob/development/src/main/java/dev/zomarrd/dbapi/utils/ResultCallback.kt): `src/main/java/dev/zomarrd/dbapi/utils/ResultCallback.kt`

### Other components

- **Plugin code**
- **SQL server**

## Connections

- Plugin code → Database factory: initializes (evidence: `README.md`)
- Database factory → Database type: selects type (evidence: `src/main/java/dev/zomarrd/dbapi/DatabaseLib.kt`)
- Database factory → MariaDB driver: creates (evidence: `src/main/java/dev/zomarrd/dbapi/DatabaseLib.kt`)
- Database factory → MySQL driver: creates (evidence: `src/main/java/dev/zomarrd/dbapi/DatabaseLib.kt`)
- Plugin code → MariaDB config: configures (evidence: `README.md`)
- Plugin code → MySQL config: configures
- MariaDB config → Connection contract: implements (evidence: `src/main/java/dev/zomarrd/dbapi/mariadb/ConnectionInfo.kt`)
- MySQL config → Connection contract: implements (evidence: `src/main/java/dev/zomarrd/dbapi/mysql/ConnectionInfo.kt`)
- Database factory → Connection contract: accepts info (evidence: `src/main/java/dev/zomarrd/dbapi/DatabaseLib.kt`)
- Plugin code → Database operations: connects (evidence: `README.md`)
- Plugin code → Database operations: queries (evidence: `README.md`)
- MariaDB driver → Connection contract: reads URL (evidence: `src/main/java/dev/zomarrd/dbapi/mariadb/MariaDB.kt`)
- MySQL driver → Connection contract: reads URL (evidence: `src/main/java/dev/zomarrd/dbapi/mysql/MySQL.kt`)
- MariaDB driver → SQL server: connects (evidence: `src/main/java/dev/zomarrd/dbapi/mariadb/MariaDB.kt`)
- MySQL driver → SQL server: connects (evidence: `src/main/java/dev/zomarrd/dbapi/mysql/MySQL.kt`)
- Database operations → SQL server: executes SQL (evidence: `src/main/java/dev/zomarrd/dbapi/Database.kt`)
- Database operations → Column-value pair: uses values (evidence: `src/main/java/dev/zomarrd/dbapi/Database.kt`)
- Database operations → Callback results: notifies (evidence: `src/main/java/dev/zomarrd/dbapi/Database.kt`)
- Callback results → Plugin code: returns result (evidence: `README.md`)
