# tanasoft1/testkit architecture

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

- Interactive diagram: https://gitdiagram.com/tanasoft1/testkit
- Repository: https://github.com/tanasoft1/testkit

## Overview

testkit is a shared Go test harness for exercising real service HTTP handlers against isolated, migrated Postgres databases, while also recording outbound HTTP calls. The principal workflow is a test obtaining a fresh database, wiring its application to that database, issuing in-process requests through a framework adapter, then checking responses and assertions. Separate capabilities cover Postgres server discovery and container fallback, schema migration, outbound-call recording, and Fiber or net/http integration. The source excerpts show the core runtime paths; links among unsampled service wiring and outbound clients are documented in the README rather than verified in service code.

Main entry points: [`pgkit/server.go`](https://github.com/tanasoft1/testkit/blob/main/pgkit/server.go) (Server resolver), [`doer.go`](https://github.com/tanasoft1/testkit/blob/main/doer.go) (Doer seam), [`fiberkit/fiberkit.go`](https://github.com/tanasoft1/testkit/blob/main/fiberkit/fiberkit.go) (Fiber adapter), [`httpkit/httpkit.go`](https://github.com/tanasoft1/testkit/blob/main/httpkit/httpkit.go) (net/http adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_database["Database harness"]
  node_pgserver["Server resolver<br/>[server.go]"]
  node_pgmigrator["Schema migrator<br/>[migrator.go]"]
end

subgraph group_http["HTTP testing"]
  node_client["HTTP client<br/>[client.go]"]
  node_doer["Doer seam<br/>[doer.go]"]
  node_fiber["Fiber adapter<br/>[fiberkit.go]"]
  node_httpadapter["net/http adapter<br/>[httpkit.go]"]
end

subgraph group_observability["Test verification"]
  node_recorder["TLS recorder<br/>[recorder.go]"]
  node_assert["Assertions<br/>[assert.go]"]
end

node_test(("Service test"))
node_app["Real application"]
node_postgres[("Postgres server")]
node_docker["Docker fallback"]
node_outbound["Outbound endpoint"]

node_test -->|"requests database"| node_pgserver
node_pgserver -->|"resolves server"| node_postgres
node_pgserver -->|"boots fallback"| node_docker
node_pgserver -->|"uses migrator"| node_pgmigrator
node_pgmigrator -->|"migrates template"| node_postgres
node_test -->|"wires with DSN"| node_app
node_test -->|"issues requests"| node_client
node_client -->|"dispatches request"| node_doer
node_fiber -->|"wraps Fiber app"| node_app
node_httpadapter -->|"serves handler"| node_app
node_fiber -->|"implements seam"| node_doer
node_httpadapter -->|"implements seam"| node_doer
node_app -->|"calls endpoint"| node_outbound
node_test -->|"configures recorder"| node_recorder
node_test -->|"checks results"| node_assert

click node_pgserver "https://github.com/tanasoft1/testkit/blob/main/pgkit/server.go"
click node_pgmigrator "https://github.com/tanasoft1/testkit/blob/main/pgkit/migrator.go"
click node_client "https://github.com/tanasoft1/testkit/blob/main/client.go"
click node_doer "https://github.com/tanasoft1/testkit/blob/main/doer.go"
click node_fiber "https://github.com/tanasoft1/testkit/blob/main/fiberkit/fiberkit.go"
click node_httpadapter "https://github.com/tanasoft1/testkit/blob/main/httpkit/httpkit.go"
click node_recorder "https://github.com/tanasoft1/testkit/blob/main/recorder.go"
click node_assert "https://github.com/tanasoft1/testkit/blob/main/assert/assert.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_pgserver,node_pgmigrator toneBlue
class node_client,node_doer,node_fiber,node_httpadapter,node_postgres toneAmber
class node_recorder,node_assert toneMint
class node_test,node_app,node_docker,node_outbound toneIndigo
```

## Components

### Database harness

- [Server resolver](https://github.com/tanasoft1/testkit/blob/main/pgkit/server.go): `pgkit/server.go`
- [Schema migrator](https://github.com/tanasoft1/testkit/blob/main/pgkit/migrator.go): `pgkit/migrator.go`

### HTTP testing

- [HTTP client](https://github.com/tanasoft1/testkit/blob/main/client.go): `client.go`
- [Doer seam](https://github.com/tanasoft1/testkit/blob/main/doer.go): `doer.go`
- [Fiber adapter](https://github.com/tanasoft1/testkit/blob/main/fiberkit/fiberkit.go): `fiberkit/fiberkit.go`
- [net/http adapter](https://github.com/tanasoft1/testkit/blob/main/httpkit/httpkit.go): `httpkit/httpkit.go`

### Test verification

- [TLS recorder](https://github.com/tanasoft1/testkit/blob/main/recorder.go): `recorder.go`
- [Assertions](https://github.com/tanasoft1/testkit/blob/main/assert/assert.go): `assert/assert.go`

### Other components

- **Service test**
- **Real application**
- **Postgres server**
- **Docker fallback**
- **Outbound endpoint**

## Connections

- Service test → Server resolver: requests database (evidence: `README.md`)
- Server resolver → Postgres server: resolves server (evidence: `pgkit/server.go`)
- Server resolver → Docker fallback: boots fallback (evidence: `pgkit/server.go`)
- Server resolver → Schema migrator: uses migrator (evidence: `pgkit/server.go`)
- Schema migrator → Postgres server: migrates template (evidence: `pgkit/migrator.go`)
- Service test → Real application: wires with DSN (evidence: `README.md`)
- Service test → HTTP client: issues requests (evidence: `README.md`)
- HTTP client → Doer seam: dispatches request (evidence: `client.go`)
- Fiber adapter → Real application: wraps Fiber app (evidence: `fiberkit/fiberkit.go`)
- net/http adapter → Real application: serves handler (evidence: `httpkit/httpkit.go`)
- Fiber adapter → Doer seam: implements seam (evidence: `fiberkit/fiberkit.go`)
- net/http adapter → Doer seam: implements seam (evidence: `httpkit/httpkit.go`)
- Real application → Outbound endpoint: calls endpoint (evidence: `README.md`)
- Service test → TLS recorder: configures recorder (evidence: `README.md`)
- Service test → Assertions: checks results (evidence: `README.md`)
