# danielptv/tap-db2 architecture

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

- Interactive diagram: https://gitdiagram.com/danielptv/tap-db2
- Repository: https://github.com/danielptv/tap-db2

## Overview

Tap-DB2 is a Singer extraction tap for IBM DB2, runnable directly or through Meltano. Its main workflow discovers DB2 tables and views into a Singer catalog, then reads selected streams, applying configured filters and optional query partitioning, and emits records for a Singer consumer. The sampled code shows tap configuration, stream query logic, and connector behavior; SDK internals and the exact runtime dispatch between them are not shown, so those links are limited to explicit class configuration and calls.

Main entry points: [`tap_db2/stream.py`](https://github.com/danielptv/tap-db2/blob/main/tap_db2/stream.py) (DB2 stream), [`tap_db2/connector.py`](https://github.com/danielptv/tap-db2/blob/main/tap_db2/connector.py) (DB2 connector), [`tap_db2/tap.py`](https://github.com/danielptv/tap-db2/blob/main/tap_db2/tap.py) (TapDB2)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tap["Tap runtime"]
  node_tap["TapDB2<br/>[tap.py]"]
  node_maps["Stream maps<br/>[tap.py]"]
end

subgraph group_extract["Discovery and extraction"]
  node_stream["DB2 stream<br/>[stream.py]"]
  node_catalog["Singer catalog<br/>[connector.py]"]
end

subgraph group_connect["DB2 connectivity"]
  node_connector["DB2 connector<br/>[connector.py]"]
  node_sqlalchemy["SQLAlchemy"]
end

node_operator(("Tap operator"))
node_db2[("IBM DB2")]
node_consumer(("Singer consumer"))

node_operator -->|"runs"| node_tap
node_tap -->|"sets default class"| node_stream
node_tap -->|"configures"| node_maps
node_stream -->|"requests table"| node_connector
node_connector -->|"creates engine"| node_sqlalchemy
node_sqlalchemy -->|"connects"| node_db2
node_connector -->|"inspects schema"| node_sqlalchemy
node_connector -->|"builds entries"| node_catalog
node_stream -->|"queries records"| node_db2
node_stream -->|"emits records"| node_consumer

click node_tap "https://github.com/danielptv/tap-db2/blob/main/tap_db2/tap.py"
click node_maps "https://github.com/danielptv/tap-db2/blob/main/tap_db2/tap.py"
click node_stream "https://github.com/danielptv/tap-db2/blob/main/tap_db2/stream.py"
click node_connector "https://github.com/danielptv/tap-db2/blob/main/tap_db2/connector.py"
click node_catalog "https://github.com/danielptv/tap-db2/blob/main/tap_db2/connector.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_tap,node_maps toneBlue
class node_stream,node_catalog,node_db2 toneAmber
class node_connector,node_sqlalchemy toneMint
class node_operator,node_consumer toneIndigo
```

## Components

### Tap runtime

- [TapDB2](https://github.com/danielptv/tap-db2/blob/main/tap_db2/tap.py): `tap_db2/tap.py`
- [Stream maps](https://github.com/danielptv/tap-db2/blob/main/tap_db2/tap.py): `tap_db2/tap.py`

### Discovery and extraction

- [DB2 stream](https://github.com/danielptv/tap-db2/blob/main/tap_db2/stream.py): `tap_db2/stream.py`
- [Singer catalog](https://github.com/danielptv/tap-db2/blob/main/tap_db2/connector.py): `tap_db2/connector.py`

### DB2 connectivity

- [DB2 connector](https://github.com/danielptv/tap-db2/blob/main/tap_db2/connector.py): `tap_db2/connector.py`
- **SQLAlchemy**

### Other components

- **Tap operator**
- **IBM DB2**
- **Singer consumer**

## Connections

- Tap operator → TapDB2: runs
- TapDB2 → DB2 stream: sets default class
- TapDB2 → Stream maps: configures
- DB2 stream → DB2 connector: requests table
- DB2 connector → SQLAlchemy: creates engine
- SQLAlchemy → IBM DB2: connects
- DB2 connector → SQLAlchemy: inspects schema
- DB2 connector → Singer catalog: builds entries
- DB2 stream → IBM DB2: queries records
- DB2 stream → Singer consumer: emits records
