# alaskaforever/mssql2csv architecture

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

- Interactive diagram: https://gitdiagram.com/alaskaforever/mssql2csv
- Repository: https://github.com/alaskaforever/mssql2csv

## Overview

mssql2csv is a small Go command-line utility: it loads database settings from `.env`, accepts SQL files as arguments, runs each query against SQL Server, and writes a same-basename CSV. The runtime is concentrated in `main.go`; the SQL files are selectable query inputs rather than separately orchestrated stages. The README documents the multi-file workflow. The sampled source does not show the contents of individual SQL files.

Main entry points: [`main.go`](https://github.com/alaskaforever/mssql2csv/blob/main/main.go) (Query Exporter), [`.env`](https://github.com/alaskaforever/mssql2csv/blob/main/.env) (DB Configuration), [`ADkasutajad.sql`](https://github.com/alaskaforever/mssql2csv/blob/main/ADkasutajad.sql) (AD Users Query), [`WinInstSoftware.sql`](https://github.com/alaskaforever/mssql2csv/blob/main/WinInstSoftware.sql) (Installed Software Query)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_app["Query Exporter<br/>[main.go]"]
  node_config["DB Configuration<br/>[.env]"]
  node_csv["CSV Output"]
end

subgraph group_queries["SQL Queries"]
  node_adkasutajad["AD Users Query<br/>[ADkasutajad.sql]"]
  node_software["Installed Software Query"]
  node_assets["Assets Query<br/>[assets.sql]"]
  node_printers["Printers Query"]
  node_networks["Networks Query<br/>[networks.sql]"]
  node_switchports["Switch Ports Query<br/>[switchports.sql]"]
  node_guests["VM Guests Query<br/>[vm_guests.sql]"]
  node_network_assets["Network Assets Query<br/>[vorguvarad.sql]"]
end

node_user(("CLI User"))
node_sqlserver[("SQL Server")]

node_user -->|"runs with files"| node_app
node_app -->|"loads settings"| node_config
node_app -->|"queries"| node_sqlserver
node_app -->|"writes results"| node_csv
node_app -->|"reads if supplied"| node_adkasutajad
node_app -->|"reads if supplied"| node_software
node_app -->|"reads if supplied"| node_assets
node_app -->|"reads if supplied"| node_printers
node_app -->|"reads if supplied"| node_networks
node_app -->|"reads if supplied"| node_switchports
node_app -->|"reads if supplied"| node_guests
node_app -->|"reads if supplied"| node_network_assets

click node_app "https://github.com/alaskaforever/mssql2csv/blob/main/main.go"
click node_config "https://github.com/alaskaforever/mssql2csv/blob/main/.env"
click node_adkasutajad "https://github.com/alaskaforever/mssql2csv/blob/main/ADkasutajad.sql"
click node_software "https://github.com/alaskaforever/mssql2csv/blob/main/WinInstSoftware.sql"
click node_assets "https://github.com/alaskaforever/mssql2csv/blob/main/assets.sql"
click node_printers "https://github.com/alaskaforever/mssql2csv/blob/main/local-printerid.sql"
click node_networks "https://github.com/alaskaforever/mssql2csv/blob/main/networks.sql"
click node_switchports "https://github.com/alaskaforever/mssql2csv/blob/main/switchports.sql"
click node_guests "https://github.com/alaskaforever/mssql2csv/blob/main/vm_guests.sql"
click node_network_assets "https://github.com/alaskaforever/mssql2csv/blob/main/vorguvarad.sql"

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_config,node_csv,node_user toneBlue
class node_adkasutajad,node_software,node_assets,node_printers,node_networks,node_switchports,node_guests,node_network_assets,node_sqlserver toneAmber
```

## Components

### Runtime

- [Query Exporter](https://github.com/alaskaforever/mssql2csv/blob/main/main.go): `main.go`
- [DB Configuration](https://github.com/alaskaforever/mssql2csv/blob/main/.env): `.env`
- **CSV Output**

### SQL Queries

- [AD Users Query](https://github.com/alaskaforever/mssql2csv/blob/main/ADkasutajad.sql): `ADkasutajad.sql`
- [Installed Software Query](https://github.com/alaskaforever/mssql2csv/blob/main/WinInstSoftware.sql): `WinInstSoftware.sql`
- [Assets Query](https://github.com/alaskaforever/mssql2csv/blob/main/assets.sql): `assets.sql`
- [Printers Query](https://github.com/alaskaforever/mssql2csv/blob/main/local-printerid.sql): `local-printerid.sql`
- [Networks Query](https://github.com/alaskaforever/mssql2csv/blob/main/networks.sql): `networks.sql`
- [Switch Ports Query](https://github.com/alaskaforever/mssql2csv/blob/main/switchports.sql): `switchports.sql`
- [VM Guests Query](https://github.com/alaskaforever/mssql2csv/blob/main/vm_guests.sql): `vm_guests.sql`
- [Network Assets Query](https://github.com/alaskaforever/mssql2csv/blob/main/vorguvarad.sql): `vorguvarad.sql`

### Other components

- **CLI User**
- **SQL Server**

## Connections

- CLI User → Query Exporter: runs with files (evidence: `README.md`)
- Query Exporter → DB Configuration: loads settings (evidence: `main.go`)
- Query Exporter → SQL Server: queries (evidence: `main.go`)
- Query Exporter → CSV Output: writes results (evidence: `main.go`)
- Query Exporter → AD Users Query: reads if supplied (evidence: `README.md`)
- Query Exporter → Installed Software Query: reads if supplied (evidence: `README.md`)
- Query Exporter → Assets Query: reads if supplied (evidence: `README.md`)
- Query Exporter → Printers Query: reads if supplied (evidence: `README.md`)
- Query Exporter → Networks Query: reads if supplied (evidence: `README.md`)
- Query Exporter → Switch Ports Query: reads if supplied (evidence: `README.md`)
- Query Exporter → VM Guests Query: reads if supplied (evidence: `README.md`)
- Query Exporter → Network Assets Query: reads if supplied (evidence: `README.md`)
