# inspirate789/bmstu-db architecture

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

- Interactive diagram: https://gitdiagram.com/inspirate789/bmstu-db
- Repository: https://github.com/inspirate789/bmstu-db

## Overview

This repository is a collection of database-course labs, not one unified application. Its main product workflow is the Go TCP database sandbox: a client sends a lab/query command, the server dispatches it to a handler, and the handler uses database operations to produce a response. Lab 9 adds Redis-backed database support and a separate benchmark pipeline. Other branches include CSV data generation and standalone SQL/GORM exercises. The tree and excerpts support server dispatch and pipeline wiring; handler-to-query details are not shown, so those links are omitted.

Main entry points: [`labs/lab_09/dblabs/pipeline/main.go`](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/main.go) (Benchmark runner), [`labs/lab_06_07/dblabs/server/server.go`](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/server/server.go) (TCP server), [`labs/lab_09/dblabs/server/server.go`](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/server/server.go) (TCP server), [`labs/lab_09/dblabs/database/database.go`](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/database/database.go) (Database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tcp["TCP database labs"]
  node_client67["TCP client<br/>[client.go]"]
  node_server67["TCP server<br/>[server.go]"]
  node_handlers67["Lab handlers<br/>[handlers.go]"]
  node_db67["Database access<br/>[database.go]"]
  node_sql67["SQL scripts<br/>[sqlscripts.go]"]
  node_client9["TCP client<br/>[client.go]"]
  node_server9["TCP server<br/>[server.go]"]
  node_handlers9["Lab handlers<br/>[handlers.go]"]
  node_db9["Database access<br/>[database.go]"]
  node_sql9["SQL scripts<br/>[sqlscripts.go]"]
end

subgraph group_pipeline["Pipeline benchmark"]
  node_runner["Benchmark runner<br/>[main.go]"]
  node_engine["Pipeline engine<br/>[pipeline.go]"]
  node_steps["Database steps<br/>[main.go]"]
  node_timing["Request timings<br/>[request.go]"]
  node_line_metrics["Timing helpers<br/>[lines.go]"]
  node_benchmark_output["Benchmark JSON<br/>[main.go]"]
end

subgraph group_data["Data generation"]
  node_generator["CSV generator<br/>[main.go]"]
  node_csv["Generated CSV files"]
end

subgraph group_exercises["SQL exercises"]
  node_mct3["SQL and GORM lab<br/>[main.go]"]
  node_mct3prep["SQL and GORM prep<br/>[main.go]"]
  node_mct3scripts["SQL scripts<br/>[sqlscripts.go]"]
  node_prep_scripts["SQL scripts<br/>[sqlscripts.go]"]
end

node_user(("Lab user"))
node_postgres[("PostgreSQL")]
node_redis[("Redis")]

node_user -->|"enters commands"| node_client67
node_client67 -->|"sends TCP"| node_server67
node_server67 -->|"dispatches commands"| node_handlers67
node_server67 -->|"connects database"| node_db67
node_db67 -->|"connects"| node_postgres
node_user -->|"enters commands"| node_client9
node_client9 -->|"sends TCP"| node_server9
node_server9 -->|"dispatches commands"| node_handlers9
node_server9 -->|"connects database"| node_db9
node_db9 -->|"connects"| node_postgres
node_db9 -->|"pings"| node_redis
node_runner -->|"runs modes"| node_engine
node_runner -->|"configures steps"| node_steps
node_engine -->|"records timings"| node_timing
node_engine -->|"executes steps"| node_steps
node_runner -->|"calculates metrics"| node_line_metrics
node_runner -->|"writes results"| node_benchmark_output
node_generator -->|"writes CSV"| node_csv
node_mct3 -->|"loads SQL assets"| node_mct3scripts
node_mct3prep -->|"loads SQL assets"| node_prep_scripts

click node_client67 "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/client/client.go"
click node_server67 "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/server/server.go"
click node_handlers67 "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/server/handlers/handlers.go"
click node_db67 "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/database/database.go"
click node_sql67 "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/database/sqlscripts.go"
click node_client9 "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/client/client.go"
click node_server9 "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/server/server.go"
click node_handlers9 "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/server/handlers/handlers.go"
click node_db9 "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/database/database.go"
click node_sql9 "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/database/sqlscripts.go"
click node_runner "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/main.go"
click node_engine "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/pipeline.go"
click node_steps "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/main.go"
click node_timing "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/request.go"
click node_line_metrics "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/lines.go"
click node_benchmark_output "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/main.go"
click node_generator "https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_01/data_generator/main.go"
click node_mct3 "https://github.com/inspirate789/bmstu-db/blob/main/mct/mct_03/main.go"
click node_mct3prep "https://github.com/inspirate789/bmstu-db/blob/main/mct/mct_03_prep/main.go"
click node_mct3scripts "https://github.com/inspirate789/bmstu-db/blob/main/mct/mct_03/sqlscripts.go"
click node_prep_scripts "https://github.com/inspirate789/bmstu-db/blob/main/mct/mct_03_prep/sqlscripts.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_client67,node_server67,node_handlers67,node_db67,node_sql67,node_client9,node_server9,node_handlers9,node_db9,node_sql9,node_user toneBlue
class node_runner,node_engine,node_steps,node_timing,node_line_metrics,node_benchmark_output,node_postgres,node_redis toneAmber
class node_generator,node_csv toneMint
class node_mct3,node_mct3prep,node_mct3scripts,node_prep_scripts toneRose
```

## Components

### TCP database labs

- [TCP client](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/client/client.go): `labs/lab_06_07/dblabs/client/client.go`
- [TCP server](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/server/server.go): `labs/lab_06_07/dblabs/server/server.go`
- [Lab handlers](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/server/handlers/handlers.go): `labs/lab_06_07/dblabs/server/handlers/handlers.go`
- [Database access](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/database/database.go): `labs/lab_06_07/dblabs/database/database.go`
- [SQL scripts](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_06_07/dblabs/database/sqlscripts.go): `labs/lab_06_07/dblabs/database/sqlscripts.go`
- [TCP client](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/client/client.go): `labs/lab_09/dblabs/client/client.go`
- [TCP server](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/server/server.go): `labs/lab_09/dblabs/server/server.go`
- [Lab handlers](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/server/handlers/handlers.go): `labs/lab_09/dblabs/server/handlers/handlers.go`
- [Database access](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/database/database.go): `labs/lab_09/dblabs/database/database.go`
- [SQL scripts](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/database/sqlscripts.go): `labs/lab_09/dblabs/database/sqlscripts.go`

### Pipeline benchmark

- [Benchmark runner](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/main.go): `labs/lab_09/dblabs/pipeline/main.go`
- [Pipeline engine](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/pipeline.go): `labs/lab_09/dblabs/pipeline/pipeline.go`
- [Database steps](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/main.go): `labs/lab_09/dblabs/pipeline/main.go`
- [Request timings](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/request.go): `labs/lab_09/dblabs/pipeline/request.go`
- [Timing helpers](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/lines.go): `labs/lab_09/dblabs/pipeline/lines.go`
- [Benchmark JSON](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_09/dblabs/pipeline/main.go): `labs/lab_09/dblabs/pipeline/main.go`

### Data generation

- [CSV generator](https://github.com/inspirate789/bmstu-db/blob/main/labs/lab_01/data_generator/main.go): `labs/lab_01/data_generator/main.go`
- **Generated CSV files**

### SQL exercises

- [SQL and GORM lab](https://github.com/inspirate789/bmstu-db/blob/main/mct/mct_03/main.go): `mct/mct_03/main.go`
- [SQL and GORM prep](https://github.com/inspirate789/bmstu-db/blob/main/mct/mct_03_prep/main.go): `mct/mct_03_prep/main.go`
- [SQL scripts](https://github.com/inspirate789/bmstu-db/blob/main/mct/mct_03/sqlscripts.go): `mct/mct_03/sqlscripts.go`
- [SQL scripts](https://github.com/inspirate789/bmstu-db/blob/main/mct/mct_03_prep/sqlscripts.go): `mct/mct_03_prep/sqlscripts.go`

### Other components

- **Lab user**
- **PostgreSQL**
- **Redis**

## Connections

- Lab user → TCP client: enters commands (evidence: `labs/lab_06_07/dblabs/client/client.go`)
- TCP client → TCP server: sends TCP (evidence: `labs/lab_06_07/dblabs/client/client.go`)
- TCP server → Lab handlers: dispatches commands (evidence: `labs/lab_06_07/dblabs/server/server.go`)
- TCP server → Database access: connects database (evidence: `labs/lab_06_07/dblabs/server/server.go`)
- Database access → PostgreSQL: connects (evidence: `labs/lab_06_07/dblabs/database/database.go`)
- Lab user → TCP client: enters commands (evidence: `labs/lab_09/dblabs/client/client.go`)
- TCP client → TCP server: sends TCP (evidence: `labs/lab_09/dblabs/client/client.go`)
- TCP server → Lab handlers: dispatches commands (evidence: `labs/lab_09/dblabs/server/server.go`)
- TCP server → Database access: connects database (evidence: `labs/lab_09/dblabs/server/server.go`)
- Database access → PostgreSQL: connects (evidence: `labs/lab_09/dblabs/database/database.go`)
- Database access → Redis: pings (evidence: `labs/lab_09/dblabs/database/database.go`)
- Benchmark runner → Pipeline engine: runs modes (evidence: `labs/lab_09/dblabs/pipeline/main.go`)
- Benchmark runner → Database steps: configures steps (evidence: `labs/lab_09/dblabs/pipeline/main.go`)
- Pipeline engine → Request timings: records timings (evidence: `labs/lab_09/dblabs/pipeline/pipeline.go`)
- Pipeline engine → Database steps: executes steps (evidence: `labs/lab_09/dblabs/pipeline/main.go`)
- Benchmark runner → Timing helpers: calculates metrics (evidence: `labs/lab_09/dblabs/pipeline/main.go`)
- Benchmark runner → Benchmark JSON: writes results (evidence: `labs/lab_09/dblabs/pipeline/main.go`)
- CSV generator → Generated CSV files: writes CSV (evidence: `labs/lab_01/data_generator/main.go`)
- SQL and GORM lab → SQL scripts: loads SQL assets (evidence: `mct/mct_03/main.go`)
- SQL and GORM prep → SQL scripts: loads SQL assets (evidence: `mct/mct_03_prep/main.go`)
