# silvaleal/rotyphp architecture

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

- Interactive diagram: https://gitdiagram.com/silvaleal/rotyphp
- Repository: https://github.com/silvaleal/rotyphp

## Overview

RotyPHP is a small PHP micro-ORM and query builder that wraps PDO, with MySQL and SQLite driver support and dialect-aware table-schema generation. Its main runtime path is application code configuring a connection, using Model operations to build and execute queries, and receiving rows or write results. The excerpts show model-to-connection access and driver selection, but do not show how applications pass a selected driver into the connection holder; that wiring is therefore omitted. The README also notes that date filtering is not yet supported.

Main entry points: [`src/Model.php`](https://github.com/silvaleal/rotyphp/blob/main/src/Model.php) (Model Operations), [`src/MySQL/MySQLDriver.php`](https://github.com/silvaleal/rotyphp/blob/main/src/MySQL/MySQLDriver.php) (MySQL Driver), [`src/SQLite3/SQLiteDriver.php`](https://github.com/silvaleal/rotyphp/blob/main/src/SQLite3/SQLiteDriver.php) (SQLite Driver), [`src/Schema.php`](https://github.com/silvaleal/rotyphp/blob/main/src/Schema.php) (Schema Builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orm["ORM and Queries"]
  node_model["Model Operations<br/>[Model.php]"]
  node_querylib["RotyQuery Base"]
end

subgraph group_connections["Connections"]
  node_connection["Connection Holder<br/>[RotyDatabase.php]"]
  node_selector["Driver Selector<br/>[RotyDriver.php]"]
  node_driverbase["Driver Base<br/>[Driver.php]"]
  node_mysql["MySQL Driver<br/>[MySQLDriver.php]"]
  node_sqlite["SQLite Driver<br/>[SQLiteDriver.php]"]
end

subgraph group_schema["Schema Definition"]
  node_schema["Schema Builder<br/>[Schema.php]"]
  node_mysql_schema["MySQL Schema<br/>[MySQLSchema.php]"]
  node_sqlite_schema["SQLite Schema<br/>[SQLiteSchema.php]"]
end

node_app(("Application"))
node_pdo["PDO"]
node_mysql_db[("MySQL Database")]
node_sqlite_db[("SQLite Database")]

node_app -->|"uses"| node_model
node_model -->|"gets connection"| node_connection
node_model -->|"delegates query building"| node_querylib
node_connection -->|"stores and returns"| node_pdo
node_selector -->|"selects"| node_mysql
node_selector -->|"selects"| node_sqlite
node_mysql -->|"extends"| node_driverbase
node_sqlite -->|"extends"| node_driverbase
node_mysql -->|"creates connection"| node_pdo
node_sqlite -->|"creates connection"| node_pdo
node_pdo -->|"connects to"| node_mysql_db
node_pdo -->|"connects to"| node_sqlite_db
node_model -->|"executes queries"| node_pdo
node_mysql_schema -->|"extends"| node_schema
node_sqlite_schema -->|"extends"| node_schema
node_app -->|"defines tables"| node_schema

click node_model "https://github.com/silvaleal/rotyphp/blob/main/src/Model.php"
click node_connection "https://github.com/silvaleal/rotyphp/blob/main/src/RotyDatabase.php"
click node_selector "https://github.com/silvaleal/rotyphp/blob/main/src/RotyDriver.php"
click node_driverbase "https://github.com/silvaleal/rotyphp/blob/main/src/Driver.php"
click node_mysql "https://github.com/silvaleal/rotyphp/blob/main/src/MySQL/MySQLDriver.php"
click node_sqlite "https://github.com/silvaleal/rotyphp/blob/main/src/SQLite3/SQLiteDriver.php"
click node_schema "https://github.com/silvaleal/rotyphp/blob/main/src/Schema.php"
click node_mysql_schema "https://github.com/silvaleal/rotyphp/blob/main/src/MySQL/MySQLSchema.php"
click node_sqlite_schema "https://github.com/silvaleal/rotyphp/blob/main/src/SQLite3/SQLiteSchema.php"

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_model,node_querylib toneBlue
class node_connection,node_selector,node_driverbase,node_mysql,node_sqlite,node_mysql_db,node_sqlite_db toneAmber
class node_schema,node_mysql_schema,node_sqlite_schema toneMint
class node_app,node_pdo toneIndigo
```

## Components

### ORM and Queries

- [Model Operations](https://github.com/silvaleal/rotyphp/blob/main/src/Model.php): `src/Model.php`
- **RotyQuery Base**

### Connections

- [Connection Holder](https://github.com/silvaleal/rotyphp/blob/main/src/RotyDatabase.php): `src/RotyDatabase.php`
- [Driver Selector](https://github.com/silvaleal/rotyphp/blob/main/src/RotyDriver.php): `src/RotyDriver.php`
- [Driver Base](https://github.com/silvaleal/rotyphp/blob/main/src/Driver.php): `src/Driver.php`
- [MySQL Driver](https://github.com/silvaleal/rotyphp/blob/main/src/MySQL/MySQLDriver.php): `src/MySQL/MySQLDriver.php`
- [SQLite Driver](https://github.com/silvaleal/rotyphp/blob/main/src/SQLite3/SQLiteDriver.php): `src/SQLite3/SQLiteDriver.php`

### Schema Definition

- [Schema Builder](https://github.com/silvaleal/rotyphp/blob/main/src/Schema.php): `src/Schema.php`
- [MySQL Schema](https://github.com/silvaleal/rotyphp/blob/main/src/MySQL/MySQLSchema.php): `src/MySQL/MySQLSchema.php`
- [SQLite Schema](https://github.com/silvaleal/rotyphp/blob/main/src/SQLite3/SQLiteSchema.php): `src/SQLite3/SQLiteSchema.php`

### Other components

- **Application**
- **PDO**
- **MySQL Database**
- **SQLite Database**

## Connections

- Application → Model Operations: uses (evidence: `README.md`)
- Model Operations → Connection Holder: gets connection (evidence: `src/Model.php`)
- Model Operations → RotyQuery Base: delegates query building (evidence: `src/Model.php`)
- Connection Holder → PDO: stores and returns (evidence: `src/RotyDatabase.php`)
- Driver Selector → MySQL Driver: selects (evidence: `src/RotyDriver.php`)
- Driver Selector → SQLite Driver: selects (evidence: `src/RotyDriver.php`)
- MySQL Driver → Driver Base: extends (evidence: `src/MySQL/MySQLDriver.php`)
- SQLite Driver → Driver Base: extends (evidence: `src/SQLite3/SQLiteDriver.php`)
- MySQL Driver → PDO: creates connection (evidence: `src/MySQL/MySQLDriver.php`)
- SQLite Driver → PDO: creates connection (evidence: `src/SQLite3/SQLiteDriver.php`)
- PDO → MySQL Database: connects to
- PDO → SQLite Database: connects to
- Model Operations → PDO: executes queries (evidence: `src/Model.php`)
- MySQL Schema → Schema Builder: extends (evidence: `src/MySQL/MySQLSchema.php`)
- SQLite Schema → Schema Builder: extends (evidence: `src/SQLite3/SQLiteSchema.php`)
- Application → Schema Builder: defines tables (evidence: `README.md`)
