# jorgerojas26/lazysql architecture

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

- Interactive diagram: https://gitdiagram.com/jorgerojas26/lazysql
- Repository: https://github.com/jorgerojas26/lazysql

## Overview

LazySQL is a terminal-based SQL database management client. Users start in a connection picker or supply a connection URL, select or open a database, browse data, and use the SQL editor or table views to inspect and modify data; query results can be explored and exported. The repository also includes query history and saved-query workflows, schema browsing, configurable themes, and database-specific drivers. The graph follows documented startup and sampled source references; links for unsampled subsystem internals are omitted rather than inferred.

Main entry points: [`drivers/driver.go`](https://github.com/jorgerojas26/lazysql/blob/main/drivers/driver.go) (Driver interface), [`main.go`](https://github.com/jorgerojas26/lazysql/blob/main/main.go) (CLI startup), [`components/home.go`](https://github.com/jorgerojas26/lazysql/blob/main/components/home.go) (Database workspace), [`components/results_table.go`](https://github.com/jorgerojas26/lazysql/blob/main/components/results_table.go) (Results table)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and configuration"]
  node_main["CLI startup<br/>[main.go]"]
  node_config["App configuration<br/>[config.go]"]
  node_application["TUI runtime<br/>[app.go]"]
end

subgraph group_ui["Database interface"]
  node_connections["Connection picker"]
  node_home["Database workspace<br/>[home.go]"]
  node_schema["Schema browser<br/>[tree.go]"]
  node_results["Results table<br/>[results_table.go]"]
end

subgraph group_query["Query workflows"]
  node_editor["SQL editor<br/>[sql_editor.go]"]
  node_routing["Query routing<br/>[query_routing.go]"]
  node_csv["CSV export"]
  node_historyui["Query history UI"]
  node_querymodal["History and saved tabs"]
  node_preview["Pending change review"]
end

subgraph group_storage["Local persistence"]
  node_history["History persistence<br/>[manager.go]"]
  node_saved["Saved query storage<br/>[manager.go]"]
end

subgraph group_drivers["Database drivers"]
  node_driverapi["Driver interface<br/>[driver.go]"]
  node_postgres["PostgreSQL driver<br/>[postgres.go]"]
  node_mysql["MySQL driver<br/>[mysql.go]"]
  node_sqlite["SQLite driver<br/>[sqlite.go]"]
  node_clickhouse["ClickHouse driver<br/>[clickhouse.go]"]
  node_mssql["SQL Server driver<br/>[mssqql.go]"]
end

node_user(("Terminal user"))

node_user -->|"starts"| node_main
node_main -->|"loads config"| node_config
node_main -->|"opens connection"| node_connections
node_main -->|"runs TUI"| node_application
node_main -->|"creates pages"| node_home
node_config -->|"configures providers"| node_driverapi
node_home -.-> node_schema
node_home -.-> node_results
node_editor -.-> node_routing
node_routing -->|"checks provider"| node_driverapi
node_results -->|"uses driver"| node_driverapi
node_results -->|"records queries"| node_history
node_querymodal -->|"creates history tab"| node_historyui
node_historyui -->|"reads history"| node_history
node_querymodal -.-> node_saved
node_preview -->|"executes changes"| node_driverapi
node_driverapi -.-> node_postgres
node_driverapi -.-> node_mysql
node_driverapi -.-> node_sqlite
node_driverapi -.-> node_clickhouse
node_driverapi -.-> node_mssql

click node_main "https://github.com/jorgerojas26/lazysql/blob/main/main.go"
click node_config "https://github.com/jorgerojas26/lazysql/blob/main/app/config.go"
click node_application "https://github.com/jorgerojas26/lazysql/blob/main/app/app.go"
click node_connections "https://github.com/jorgerojas26/lazysql/blob/main/components/connection_selection.go"
click node_home "https://github.com/jorgerojas26/lazysql/blob/main/components/home.go"
click node_schema "https://github.com/jorgerojas26/lazysql/blob/main/components/tree.go"
click node_results "https://github.com/jorgerojas26/lazysql/blob/main/components/results_table.go"
click node_editor "https://github.com/jorgerojas26/lazysql/blob/main/components/sql_editor.go"
click node_routing "https://github.com/jorgerojas26/lazysql/blob/main/components/query_routing.go"
click node_csv "https://github.com/jorgerojas26/lazysql/blob/main/components/csv_export_query.go"
click node_historyui "https://github.com/jorgerojas26/lazysql/blob/main/components/query_history_component.go"
click node_querymodal "https://github.com/jorgerojas26/lazysql/blob/main/components/query_history_modal.go"
click node_preview "https://github.com/jorgerojas26/lazysql/blob/main/components/query_preview_modal.go"
click node_history "https://github.com/jorgerojas26/lazysql/blob/main/internal/history/manager.go"
click node_saved "https://github.com/jorgerojas26/lazysql/blob/main/internal/saved/manager.go"
click node_driverapi "https://github.com/jorgerojas26/lazysql/blob/main/drivers/driver.go"
click node_postgres "https://github.com/jorgerojas26/lazysql/blob/main/drivers/postgres.go"
click node_mysql "https://github.com/jorgerojas26/lazysql/blob/main/drivers/mysql.go"
click node_sqlite "https://github.com/jorgerojas26/lazysql/blob/main/drivers/sqlite.go"
click node_clickhouse "https://github.com/jorgerojas26/lazysql/blob/main/drivers/clickhouse.go"
click node_mssql "https://github.com/jorgerojas26/lazysql/blob/main/drivers/mssqql.go"

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_main,node_config,node_application,node_user toneBlue
class node_connections,node_home,node_schema,node_results toneAmber
class node_editor,node_routing,node_csv,node_historyui,node_querymodal,node_preview toneMint
class node_history,node_saved toneRose
class node_driverapi,node_postgres,node_mysql,node_sqlite,node_clickhouse,node_mssql toneIndigo
```

## Components

### Startup and configuration

- [CLI startup](https://github.com/jorgerojas26/lazysql/blob/main/main.go): `main.go`
- [App configuration](https://github.com/jorgerojas26/lazysql/blob/main/app/config.go): `app/config.go`
- [TUI runtime](https://github.com/jorgerojas26/lazysql/blob/main/app/app.go): `app/app.go`

### Database interface

- [Connection picker](https://github.com/jorgerojas26/lazysql/blob/main/components/connection_selection.go): `components/connection_selection.go`
- [Database workspace](https://github.com/jorgerojas26/lazysql/blob/main/components/home.go): `components/home.go`
- [Schema browser](https://github.com/jorgerojas26/lazysql/blob/main/components/tree.go): `components/tree.go`
- [Results table](https://github.com/jorgerojas26/lazysql/blob/main/components/results_table.go): `components/results_table.go`

### Query workflows

- [SQL editor](https://github.com/jorgerojas26/lazysql/blob/main/components/sql_editor.go): `components/sql_editor.go`
- [Query routing](https://github.com/jorgerojas26/lazysql/blob/main/components/query_routing.go): `components/query_routing.go`
- [CSV export](https://github.com/jorgerojas26/lazysql/blob/main/components/csv_export_query.go): `components/csv_export_query.go`
- [Query history UI](https://github.com/jorgerojas26/lazysql/blob/main/components/query_history_component.go): `components/query_history_component.go`
- [History and saved tabs](https://github.com/jorgerojas26/lazysql/blob/main/components/query_history_modal.go): `components/query_history_modal.go`
- [Pending change review](https://github.com/jorgerojas26/lazysql/blob/main/components/query_preview_modal.go): `components/query_preview_modal.go`

### Local persistence

- [History persistence](https://github.com/jorgerojas26/lazysql/blob/main/internal/history/manager.go): `internal/history/manager.go`
- [Saved query storage](https://github.com/jorgerojas26/lazysql/blob/main/internal/saved/manager.go): `internal/saved/manager.go`

### Database drivers

- [Driver interface](https://github.com/jorgerojas26/lazysql/blob/main/drivers/driver.go): `drivers/driver.go`
- [PostgreSQL driver](https://github.com/jorgerojas26/lazysql/blob/main/drivers/postgres.go): `drivers/postgres.go`
- [MySQL driver](https://github.com/jorgerojas26/lazysql/blob/main/drivers/mysql.go): `drivers/mysql.go`
- [SQLite driver](https://github.com/jorgerojas26/lazysql/blob/main/drivers/sqlite.go): `drivers/sqlite.go`
- [ClickHouse driver](https://github.com/jorgerojas26/lazysql/blob/main/drivers/clickhouse.go): `drivers/clickhouse.go`
- [SQL Server driver](https://github.com/jorgerojas26/lazysql/blob/main/drivers/mssqql.go): `drivers/mssqql.go`

### Other components

- **Terminal user**

## Connections

- Terminal user → CLI startup: starts (evidence: `main.go`)
- CLI startup → App configuration: loads config (evidence: `main.go`)
- CLI startup → Connection picker: opens connection (evidence: `main.go`)
- CLI startup → TUI runtime: runs TUI (evidence: `main.go`)
- CLI startup → Database workspace: creates pages (evidence: `main.go`)
- App configuration → Driver interface: configures providers (evidence: `app/config.go`)
- Database workspace → Schema browser
- Database workspace → Results table
- SQL editor → Query routing
- Query routing → Driver interface: checks provider (evidence: `components/query_routing.go`)
- Results table → Driver interface: uses driver (evidence: `components/results_table.go`)
- Results table → History persistence: records queries (evidence: `components/results_table.go`)
- History and saved tabs → Query history UI: creates history tab (evidence: `components/query_history_modal.go`)
- Query history UI → History persistence: reads history (evidence: `components/query_history_component.go`)
- History and saved tabs → Saved query storage
- Pending change review → Driver interface: executes changes (evidence: `components/query_preview_modal.go`)
- Driver interface → PostgreSQL driver
- Driver interface → MySQL driver
- Driver interface → SQLite driver
- Driver interface → ClickHouse driver
- Driver interface → SQL Server driver
