# pramsey/pgsql-http architecture

> Architecture diagram of the GitHub repository pramsey/pgsql-http, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pramsey/pgsql-http
- Repository: https://github.com/pramsey/pgsql-http

## Overview

##### Main Components
a. Core Extension Components:
- Main function handlers (http.c)
- SQL interface layer (sql/http.sql)
- Version upgrade paths (http--*.sql files)

b. External Dependencies:
- PostgreSQL Database System
- libcurl library
- External HTTP Services (target endpoints)

##### Component Relationships

**[PostgreSQL Database]**
- ↑↓
**[PostgreSQL HTTP Extension]**

- [Version Management]
- (http--*.sql files)

- [SQL Interface Layer]
- (sql/http.sql)

- [Core C Implementation]
- (http.c)

- [libcurl]
- ↓
**[External HTTP Services]**

##### Data Flow Representation

- PostgreSQL function calls → HTTP Extension
- HTTP Extension → libcurl requests
- libcurl → External HTTP Services
- Response data flow in reverse direction

##### Component Details

Specific elements:
a. Data Types:
- http_request
- http_response
- http_header

b. Main Functions:
- http_get()
- http_post()
- http_put()
- http_patch()
- http_delete()
- http_head()

c. Configuration:
- CURL Options
- Keep-Alive settings
- Timeout configurations

##### Technical Details

- Supported PostgreSQL versions (≥ 9.3)
- Required CURL version (≥ 0.7.20)
- Binary content handling
- Header management
- Connection management

##### The version upgrade path management

Keep the abstraction level focused on the architectural components while maintaining enough detail to show the extension's key features and integration points. This will help developers understand both the high-level structure and the specific implementation details that matter for maintenance and enhancement.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph PostgreSQL
        PG[PostgreSQL Database]
    end

    subgraph Extension["PostgreSQL HTTP Extension"]
        Core["Core C Implementation"]
        SQL["SQL Interface Layer"]
        VerMgmt["Version Management"]
        Config["Extension Configuration"]
        
        subgraph Functions["HTTP Functions"]
            GET["http_get()"]
            POST["http_post()"]
            PUT["http_put()"]
            PATCH["http_patch()"]
            DELETE["http_delete()"]
            HEAD["http_head()"]
        end
        
        subgraph DataTypes["Data Types"]
            ReqType["http_request"]
            RespType["http_response"]
            HeaderType["http_header"]
        end
        
        subgraph Config["Configuration"]
            CURL["CURL Options"]
            KA["Keep-Alive Settings"]
            TO["Timeout Config"]
        end
    end

    subgraph External["External Components"]
        CURL["libcurl Library"]
        HTTP["External HTTP Services"]
    end

    %% Relationships
    PG <--> Core
    Core --> SQL
    Core --> VerMgmt
    Core --> Functions
    Core --> DataTypes
    Core --> Config
    Core --> CURL
    CURL --> HTTP

    %% Styling
    classDef postgresql fill:#4479A1,stroke:#333,stroke-width:2px,color:white
    classDef extension fill:#2E8B57,stroke:#333,stroke-width:2px,color:white
    classDef external fill:#FFA500,stroke:#333,stroke-width:2px,color:white
    classDef config fill:#808080,stroke:#333,stroke-width:2px,color:white
    classDef function fill:#98FB98,stroke:#333,stroke-width:2px
    classDef datatype fill:#87CEEB,stroke:#333,stroke-width:2px

    class PG postgresql
    class Core,SQL,VerMgmt extension
    class CURL,HTTP external
    class Config config
    class GET,POST,PUT,PATCH,DELETE,HEAD function
    class ReqType,RespType,HeaderType datatype

    %% Click events
    click Core "https://github.com/pramsey/pgsql-http/blob/master/http.c"
    click SQL "https://github.com/pramsey/pgsql-http/blob/master/sql/http.sql"
    click VerMgmt "https://github.com/pramsey/pgsql-http/blob/master/http--1.6.sql"
    click Config "https://github.com/pramsey/pgsql-http/blob/master/http.control"
    click Build "https://github.com/pramsey/pgsql-http/tree/master/Makefile"
    click Test "https://github.com/pramsey/pgsql-http/blob/master/expected/http.out"
    click CI "https://github.com/pramsey/pgsql-http/blob/master/.github/workflows/ci.yml"
    click DBConfig "https://github.com/pramsey/pgsql-http/blob/master/ci/pg_hba.conf"
    click Meta "https://github.com/pramsey/pgsql-http/blob/master/META.json"

    %% Legend
    subgraph Legend
        L1["PostgreSQL Components"]:::postgresql
        L2["Extension Components"]:::extension
        L3["External Dependencies"]:::external
        L4["Configuration"]:::config
        L5["Functions"]:::function
        L6["Data Types"]:::datatype
    end
```
