# johnson-phillips/httplibrary architecture

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

- Interactive diagram: https://gitdiagram.com/johnson-phillips/httplibrary
- Repository: https://github.com/johnson-phillips/httplibrary

## Overview

#### Purpose and Entry Points
A Java HTTP client library for GET/POST requests with two request-signing options: AWS Signature Version 4 and OAuth 1.0a. The consumer-facing request abstraction is `src/main/java/http/HTTPRequest.java`; OAuth usage is implemented through `src/main/java/http/SimpleOauth10.java`.

#### Request Orchestration
`HTTPRequest` is the primary control point: it represents an outbound HTTP request and likely owns method, URL, headers, body, connection execution, and response handling. Authorization logic should decorate or supply headers before this execution boundary. Paths: `src/main/java/http/HTTPRequest.java`, `src/main/java/http/SimpleOauth10.java`.

#### AWS SigV4 Signing Pipeline
AWS signing is separated into a reusable base plus an Authorization-header-specific signer. The pipeline constructs canonical request material, derives signing keys, calculates the signature, and emits an AWS Authorization header for the HTTP layer. Paths: `src/main/java/awsauth/AWS4SignerBase.java`, `src/main/java/awsauth/AWS4SignerForAuthorizationHeader.java`.

#### AWS Canonicalization Boundary
AWS-specific URL/query/header normalization is isolated from the generic HTTP client. `HttpUtils` handles HTTP-oriented canonicalization/encoding support, while `BinaryUtils` supports byte-level hashing or hex encoding used by signature generation. Paths: `src/main/java/awsauth/HttpUtils.java`, `src/main/java/awsauth/BinaryUtils.java`, `src/main/java/awsauth/AWS4SignerBase.java`.

#### OAuth 1.0a Flow
`SimpleOauth10` provides the alternative authorization path: it generates OAuth request parameters and signature data, then integrates those values into the outbound request. This is a distinct credential/signature model from AWS SigV4 but shares the same HTTP transport boundary. Paths: `src/main/java/http/SimpleOauth10.java`, `src/main/java/http/HTTPRequest.java`.

#### Runtime and External Boundaries
The library runs on the JVM and is Maven-packaged as `HttpLibrary` version `1.0-SNAPSHOT`. Its external boundary is arbitrary HTTP endpoints, including AWS services that accept SigV4 Authorization headers and OAuth 1.0a-protected APIs. Published Maven-style outputs, including a dependency-bundled JAR, are present under `artifact/HttpLibrary/HttpLibrary/1.0-SNAPSHOT/`.

#### Validation and Distribution
The available test entry point is `src/test/java/HttpTest.java`. Maven package metadata and distributable artifacts are tracked in `pom.xml` and `artifact/HttpLibrary/HttpLibrary/1.0-SNAPSHOT/`, indicating the project is intended for library consumption rather than as a standalone service.

Main entry points: [`src/main/java/http/HTTPRequest.java`](https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/http/HTTPRequest.java) (HTTPRequest), [`src/main/java/awsauth/AWS4SignerBase.java`](https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/awsauth/AWS4SignerBase.java) (AWS4SignerBase), [`src/main/java/awsauth/AWS4SignerForAuthorizationHeader.java`](https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/awsauth/AWS4SignerForAuthorizationHeader.java) (AWS4SignerForAuthorizationHeader), [`src/main/java/http/SimpleOauth10.java`](https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/http/SimpleOauth10.java) (SimpleOauth10)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP Client"]
  node_http_request["HTTPRequest<br/>request orchestration<br/>[HTTPRequest.java]"]
end

subgraph group_aws["AWS SigV4"]
  node_aws_base["AWS4SignerBase<br/>SigV4 core"]
  node_aws_auth_signer["AWS4SignerForAuthorizationHeader<br/>SigV4 header signer"]
  node_http_utils["HttpUtils<br/>canonicalization utility<br/>[HttpUtils.java]"]
  node_binary_utils["BinaryUtils<br/>binary utility<br/>[BinaryUtils.java]"]
end

subgraph group_oauth["OAuth 1.0a"]
  node_oauth_client["SimpleOauth10<br/>OAuth signer<br/>[SimpleOauth10.java]"]
end

subgraph group_distribution["Build &amp; Distribution"]
  node_maven_project["Maven project<br/>package definition<br/>[pom.xml]"]
  node_published_artifacts["Published artifacts<br/>Maven output"]
end

node_consumer(("Library consumer<br/>caller"))
node_jvm{{"JVM<br/>runtime"}}
node_http_endpoints(("HTTP endpoints<br/>external API"))
node_aws_services(("AWS services<br/>external API"))

node_consumer -->|"creates and executes"| node_http_request
node_consumer -->|"uses OAuth flow"| node_oauth_client
node_oauth_client -->|"supplies OAuth values"| node_http_request
node_aws_auth_signer -->|"supplies Authorization header"| node_http_request
node_aws_auth_signer -->|"extends signing core"| node_aws_base
node_aws_base -->|"canonicalizes HTTP data"| node_http_utils
node_aws_base -->|"hashes and hex-encodes"| node_binary_utils
node_http_request -->|"sends GET/POST"| node_http_endpoints
node_http_request -->|"calls with SigV4 headers"| node_aws_services
node_jvm -->|"runs"| node_http_request
node_maven_project -->|"packages"| node_published_artifacts
node_published_artifacts -.->|"distributed to"| node_consumer

click node_http_request "https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/http/HTTPRequest.java"
click node_oauth_client "https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/http/SimpleOauth10.java"
click node_aws_base "https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/awsauth/AWS4SignerBase.java"
click node_aws_auth_signer "https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/awsauth/AWS4SignerForAuthorizationHeader.java"
click node_http_utils "https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/awsauth/HttpUtils.java"
click node_binary_utils "https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/awsauth/BinaryUtils.java"
click node_maven_project "https://github.com/johnson-phillips/httplibrary/blob/master/pom.xml"

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_http_request toneBlue
class node_aws_base,node_aws_auth_signer,node_http_utils,node_binary_utils toneAmber
class node_oauth_client toneMint
class node_maven_project,node_published_artifacts toneRose
class node_consumer,node_jvm,node_http_endpoints,node_aws_services toneNeutral
```

## Components

### HTTP Client

- [HTTPRequest](https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/http/HTTPRequest.java): request orchestration · Owns outbound request execution and response handling. · `src/main/java/http/HTTPRequest.java`

### AWS SigV4

- [AWS4SignerBase](https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/awsauth/AWS4SignerBase.java): SigV4 core · Builds canonical material, derives keys, and calculates signatures. · `src/main/java/awsauth/AWS4SignerBase.java`
- [AWS4SignerForAuthorizationHeader](https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/awsauth/AWS4SignerForAuthorizationHeader.java): SigV4 header signer · Emits the AWS Authorization header. · `src/main/java/awsauth/AWS4SignerForAuthorizationHeader.java`
- [HttpUtils](https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/awsauth/HttpUtils.java): canonicalization utility · Provides HTTP URL, query, and header encoding support. · `src/main/java/awsauth/HttpUtils.java`
- [BinaryUtils](https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/awsauth/BinaryUtils.java): binary utility · Supports hashing-related byte and hex encoding. · `src/main/java/awsauth/BinaryUtils.java`

### OAuth 1.0a

- [SimpleOauth10](https://github.com/johnson-phillips/httplibrary/blob/master/src/main/java/http/SimpleOauth10.java): OAuth signer · Generates OAuth parameters and signature data. · `src/main/java/http/SimpleOauth10.java`

### Build & Distribution

- [Maven project](https://github.com/johnson-phillips/httplibrary/blob/master/pom.xml): package definition · Packages HttpLibrary 1.0-SNAPSHOT. · `pom.xml`
- **Published artifacts**: Maven output · Includes distributable and dependency-bundled JAR outputs.

### Other components

- **Library consumer**: caller · Creates requests and selects an authorization flow.
- **JVM**: runtime
- **HTTP endpoints**: external API · Arbitrary HTTP services, including OAuth-protected APIs.
- **AWS services**: external API · Accept SigV4 Authorization headers.

## Connections

- Library consumer → HTTPRequest: creates and executes
- Library consumer → SimpleOauth10: uses OAuth flow
- SimpleOauth10 → HTTPRequest: supplies OAuth values
- AWS4SignerForAuthorizationHeader → HTTPRequest: supplies Authorization header
- AWS4SignerForAuthorizationHeader → AWS4SignerBase: extends signing core
- AWS4SignerBase → HttpUtils: canonicalizes HTTP data
- AWS4SignerBase → BinaryUtils: hashes and hex-encodes
- HTTPRequest → HTTP endpoints: sends GET/POST
- HTTPRequest → AWS services: calls with SigV4 headers
- JVM → HTTPRequest: runs
- Maven project → Published artifacts: packages
- Published artifacts → Library consumer: distributed to
