# arsbelkin/lukoil-boiler-project architecture

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

- Interactive diagram: https://gitdiagram.com/arsbelkin/lukoil-boiler-project
- Repository: https://github.com/arsbelkin/lukoil-boiler-project

## Overview

This is a boiler simulation with OPC UA, temperature control, a REST API/UI, and historical logging. The main workflow models tank and valve behavior, exposes process values through OPC UA, and lets a PID controller adjust the inlet valves; the API serves live data and history graphs. History is stored through interchangeable SQLite/PostgreSQL strategies. Dashed links mark runtime relationships suggested by the documented architecture or module references where the relevant call sites were not excerpted.

Main entry points: [`src/api/controllers.py`](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/api/controllers.py) (API routes), [`src/opc/opc_client.py`](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/opc/opc_client.py) (OPC client), [`src/db/fabric.py`](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/fabric.py) (DB strategy factory), [`src/db/db_repository.py`](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/db_repository.py) (DB repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Boiler simulation"]
  node_model_runner["Model runner<br/>[run_model.py]"]
  node_boiler["Boiler model<br/>[model.py]"]
  node_valves["Valve model<br/>[valve.py]"]
  node_boiler_options["Boiler options<br/>[optionsBoiler.py]"]
end

subgraph group_control["OPC and control"]
  node_opc_server["OPC UA server<br/>[opc_server.py]"]
  node_opc_tags["OPC tags<br/>[opc_tags.py]"]
  node_opc_client["OPC client<br/>[opc_client.py]"]
  node_pid["PID controller<br/>[pid_controller.py]"]
end

subgraph group_interface["API and UI"]
  node_browser["Browser UI<br/>[script.js]"]
  node_ui_page["UI page<br/>[index.html]"]
  node_api_routes["API routes<br/>[controllers.py]"]
  node_api_server["API server<br/>[api_server.py]"]
  node_api_dto["Value DTO<br/>[api_model.py]"]
  node_graphing["History graphs<br/>[graph.py]"]
end

subgraph group_history["History storage"]
  node_history_logger["History logger<br/>[history_logger.py]"]
  node_repository["DB repository<br/>[db_repository.py]"]
  node_db_config["DB config<br/>[config.py]"]
  node_db_factory["DB strategy factory<br/>[fabric.py]"]
  node_db_contract["DB strategy contract<br/>[abs_strategy.py]"]
  node_sqlite[("SQLite strategy<br/>[sqlite_strategy.py]")]
  node_postgres[("PostgreSQL strategy<br/>[pg_stategy.py]")]
end

node_operator(("Operator"))

node_operator -.->|"uses"| node_browser
node_browser -.->|"requests data"| node_api_routes
node_api_routes -->|"serves page"| node_ui_page
node_api_server -.->|"registers routes"| node_api_routes
node_api_routes -->|"accepts values"| node_api_dto
node_api_routes -->|"reads and writes"| node_opc_client
node_api_routes -->|"requests graph"| node_graphing
node_graphing -->|"reads history"| node_repository
node_model_runner -.->|"steps simulation"| node_boiler
node_boiler -->|"uses options"| node_boiler_options
node_boiler -->|"steps valves"| node_valves
node_model_runner -.->|"updates process values"| node_opc_client
node_opc_server -->|"defines variables"| node_opc_tags
node_opc_client -.->|"reads and writes tags"| node_opc_server
node_pid -->|"reads and sets values"| node_opc_client
node_history_logger -.->|"reads process data"| node_opc_client
node_history_logger -.->|"logs readings"| node_repository
node_repository -->|"selects database"| node_db_config
node_repository -->|"creates strategy"| node_db_factory
node_db_factory -->|"loads settings"| node_db_config
node_db_factory -->|"creates SQLite"| node_sqlite
node_db_factory -->|"creates PostgreSQL"| node_postgres
node_sqlite -.->|"implements"| node_db_contract
node_postgres -->|"implements"| node_db_contract

click node_browser "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/ui/js/script.js"
click node_ui_page "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/ui/template/index.html"
click node_api_routes "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/api/controllers.py"
click node_api_server "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/api/api_server.py"
click node_api_dto "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/api/api_model.py"
click node_graphing "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/api/graph.py"
click node_model_runner "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/model/run_model.py"
click node_boiler "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/model/model.py"
click node_valves "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/model/valve.py"
click node_boiler_options "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/model/optionsBoiler.py"
click node_opc_server "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/opc/opc_server.py"
click node_opc_tags "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/opc/opc_tags.py"
click node_opc_client "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/opc/opc_client.py"
click node_pid "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/pid/pid_controller.py"
click node_history_logger "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/history_logger.py"
click node_repository "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/db_repository.py"
click node_db_config "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/config.py"
click node_db_factory "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/fabric.py"
click node_db_contract "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/strategies/abs_strategy.py"
click node_sqlite "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/strategies/sqlite_strategy.py"
click node_postgres "https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/strategies/pg_stategy.py"

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_runner,node_boiler,node_valves,node_boiler_options toneBlue
class node_opc_server,node_opc_tags,node_opc_client,node_pid toneAmber
class node_browser,node_ui_page,node_api_routes,node_api_server,node_api_dto,node_graphing toneMint
class node_history_logger,node_repository,node_db_config,node_db_factory,node_db_contract,node_sqlite,node_postgres toneRose
class node_operator toneIndigo
```

## Components

### Boiler simulation

- [Model runner](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/model/run_model.py): `src/model/run_model.py`
- [Boiler model](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/model/model.py): `src/model/model.py`
- [Valve model](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/model/valve.py): `src/model/valve.py`
- [Boiler options](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/model/optionsBoiler.py): `src/model/optionsBoiler.py`

### OPC and control

- [OPC UA server](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/opc/opc_server.py): `src/opc/opc_server.py`
- [OPC tags](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/opc/opc_tags.py): `src/opc/opc_tags.py`
- [OPC client](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/opc/opc_client.py): `src/opc/opc_client.py`
- [PID controller](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/pid/pid_controller.py): `src/pid/pid_controller.py`

### API and UI

- [Browser UI](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/ui/js/script.js): `src/ui/js/script.js`
- [UI page](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/ui/template/index.html): `src/ui/template/index.html`
- [API routes](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/api/controllers.py): `src/api/controllers.py`
- [API server](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/api/api_server.py): `src/api/api_server.py`
- [Value DTO](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/api/api_model.py): `src/api/api_model.py`
- [History graphs](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/api/graph.py): `src/api/graph.py`

### History storage

- [History logger](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/history_logger.py): `src/db/history_logger.py`
- [DB repository](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/db_repository.py): `src/db/db_repository.py`
- [DB config](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/config.py): `src/db/config.py`
- [DB strategy factory](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/fabric.py): `src/db/fabric.py`
- [DB strategy contract](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/strategies/abs_strategy.py): `src/db/strategies/abs_strategy.py`
- [SQLite strategy](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/strategies/sqlite_strategy.py): `src/db/strategies/sqlite_strategy.py`
- [PostgreSQL strategy](https://github.com/arsbelkin/lukoil-boiler-project/blob/main/src/db/strategies/pg_stategy.py): `src/db/strategies/pg_stategy.py`

### Other components

- **Operator**

## Connections

- Operator → Browser UI: uses
- Browser UI → API routes: requests data
- API routes → UI page: serves page (evidence: `src/api/controllers.py`)
- API server → API routes: registers routes (evidence: `src/api/api_server.py`)
- API routes → Value DTO: accepts values (evidence: `src/api/controllers.py`)
- API routes → OPC client: reads and writes (evidence: `src/api/controllers.py`)
- API routes → History graphs: requests graph (evidence: `src/api/controllers.py`)
- History graphs → DB repository: reads history (evidence: `src/api/graph.py`)
- Model runner → Boiler model: steps simulation (evidence: `src/model/run_model.py`)
- Boiler model → Boiler options: uses options (evidence: `src/model/model.py`)
- Boiler model → Valve model: steps valves (evidence: `src/model/model.py`)
- Model runner → OPC client: updates process values
- OPC UA server → OPC tags: defines variables (evidence: `src/opc/opc_server.py`)
- OPC client → OPC UA server: reads and writes tags
- PID controller → OPC client: reads and sets values (evidence: `src/pid/pid_controller.py`)
- History logger → OPC client: reads process data (evidence: `src/db/history_logger.py`)
- History logger → DB repository: logs readings (evidence: `src/db/history_logger.py`)
- DB repository → DB config: selects database (evidence: `src/db/db_repository.py`)
- DB repository → DB strategy factory: creates strategy (evidence: `src/db/db_repository.py`)
- DB strategy factory → DB config: loads settings (evidence: `src/db/fabric.py`)
- DB strategy factory → SQLite strategy: creates SQLite (evidence: `src/db/fabric.py`)
- DB strategy factory → PostgreSQL strategy: creates PostgreSQL (evidence: `src/db/fabric.py`)
- SQLite strategy → DB strategy contract: implements (evidence: `src/db/strategies/sqlite_strategy.py`)
- PostgreSQL strategy → DB strategy contract: implements (evidence: `src/db/strategies/pg_stategy.py`)
