Architecture
DataPorch
Concepts

Architecture

A modular hexagonal monolith with explicit dependency wiring.

The repository is one Go module and one deployable binary. Its boundaries are intentional:

HTTP / MCP transports


execution capabilities


connector interfaces


PostgreSQL · SQLite · MySQL adapters

Package responsibilities

AreaResponsibility
cmd/dataporchCLI commands, process startup, and local admin client commands.
internal/appComposition root; constructs services and mounts transports.
internal/configReads and validates environment configuration.
internal/executionDiscovery, query validation, authorization, pagination, limits, and error classification.
internal/connectionConsumer-owned connector contracts and source definitions.
internal/connection/postgresPostgreSQL URL parsing, read-only pool behavior, discovery, and query execution.
internal/connection/sqliteRead-only SQLite opening, policy enforcement, discovery, and query execution.
internal/connection/mysqlMySQL URL parsing, read-only pool behavior, discovery, and query execution.
internal/transports/mcpMCP tool schemas, authenticated Streamable HTTP, wire errors, and request bounds.
internal/transports/localmcpAuthenticated local MCP server over an owner-only Unix socket with runtime-lifetime credentials.
internal/transports/mcpstdioStdio proxy used by dataporch mcp to reach the local MCP server.
internal/transports/localadminUnix-socket management for source import and direct HTTP MCP token lifecycle.
internal/transports/httpapiPublic health endpoint.
internal/mcpcontrol/localOwner-only local MCP credential publication and cleanup.
internal/secretLocal master key, encrypted stores, and token verifier storage.

Core capability packages do not import HTTP, MCP, database drivers, or vendor SDKs. Transports and adapters depend inward on execution contracts. This keeps a new transport from creating a second validation path.

Composition root

Dependencies are built explicitly in internal/app. There is no dependency-injection framework, global registry, service locator, or package initialization side effect. Tests provide small fakes through consumer-owned interfaces, and production wiring remains visible and compile-time checked.

Request path

  1. A client reaches the shared MCP handler through direct HTTP bearer auth or the dataporch mcp stdio-to-Unix-socket adapter.
  2. The MCP transport validates the tool input and attaches the authenticated caller.
  3. Execution resolves the source, checks capability and authorization, and validates identifiers.
  4. The adapter opens the configured source under its own read-only policy.
  5. Execution applies timeout, row, and response-byte bounds.
  6. The transport serializes a stable result or a categorized failure.