# jashhh0908/strataproxy architecture

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

- Interactive diagram: https://gitdiagram.com/jashhh0908/strataproxy
- Repository: https://github.com/jashhh0908/strataproxy

## Overview

StrataProxy is a Node.js Layer 7 reverse proxy and API gateway. Client requests enter the gateway, which applies per-IP rate limiting and, for GETs, checks the response cache and coalesces concurrent misses. The gateway selects a healthy upstream and delegates forwarding to the streaming proxy, which sanitizes headers and can store cacheable responses. A background health checker probes upstreams and updates pool availability. The graph follows the sampled gateway code and README; upstream services are external, and their implementation is not part of the runtime map.

Main entry points: [`src/server.ts`](https://github.com/jashhh0908/strataproxy/blob/main/src/server.ts) (Request Gateway), [`src/proxy/StreamPipe.ts`](https://github.com/jashhh0908/strataproxy/blob/main/src/proxy/StreamPipe.ts) (Stream Forwarder), [`src/balancer/HealthChecker.ts`](https://github.com/jashhh0908/strataproxy/blob/main/src/balancer/HealthChecker.ts) (Health Checker), [`src/cache/LruCache.ts`](https://github.com/jashhh0908/strataproxy/blob/main/src/cache/LruCache.ts) (LRU Cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway"]
  node_gateway["Request Gateway<br/>[server.ts]"]
  node_config["Proxy Config<br/>[config.ts]"]
end

subgraph group_controls["Request Controls"]
  node_rate_limiter["Rate Limiter<br/>[RateLimiter.ts]"]
  node_ring_buffer["Timestamp Ring<br/>[RingBuffer.ts]"]
  node_lru_cache[("LRU Cache<br/>[LruCache.ts]")]
  node_linked_list["Cache List"]
  node_coalescer["Request Coalescer<br/>[Coalescer.ts]"]
end

subgraph group_balancing["Upstream Balancing"]
  node_upstream_pool["Upstream Pool<br/>[UpstreamPool.ts]"]
  node_health_checker["Health Checker<br/>[HealthChecker.ts]"]
end

subgraph group_transport["Proxy Transport"]
  node_stream_pipe["Stream Forwarder<br/>[StreamPipe.ts]"]
  node_header_parser["Header Sanitizer<br/>[HeaderParser.ts]"]
end

node_client(("Client"))
node_upstreams["Upstream Services"]

node_client -->|"sends requests"| node_gateway
node_gateway -->|"reads settings"| node_config
node_gateway -->|"checks client"| node_rate_limiter
node_rate_limiter -->|"records timestamps"| node_ring_buffer
node_gateway -->|"checks and stores"| node_lru_cache
node_lru_cache -->|"updates recency"| node_linked_list
node_gateway -->|"coalesces misses"| node_coalescer
node_gateway -->|"selects target"| node_upstream_pool
node_gateway -->|"starts and stops"| node_health_checker
node_health_checker -->|"updates health"| node_upstream_pool
node_health_checker -->|"probes health"| node_upstreams
node_gateway -->|"forwards request"| node_stream_pipe
node_stream_pipe -->|"sanitizes headers"| node_header_parser
node_stream_pipe -->|"streams request"| node_upstreams
node_stream_pipe -->|"stores response"| node_lru_cache

click node_gateway "https://github.com/jashhh0908/strataproxy/blob/main/src/server.ts"
click node_config "https://github.com/jashhh0908/strataproxy/blob/main/src/config.ts"
click node_rate_limiter "https://github.com/jashhh0908/strataproxy/blob/main/src/limiter/RateLimiter.ts"
click node_ring_buffer "https://github.com/jashhh0908/strataproxy/blob/main/src/limiter/RingBuffer.ts"
click node_lru_cache "https://github.com/jashhh0908/strataproxy/blob/main/src/cache/LruCache.ts"
click node_linked_list "https://github.com/jashhh0908/strataproxy/blob/main/src/cache/DoublyLinkedList.ts"
click node_coalescer "https://github.com/jashhh0908/strataproxy/blob/main/src/cache/Coalescer.ts"
click node_upstream_pool "https://github.com/jashhh0908/strataproxy/blob/main/src/balancer/UpstreamPool.ts"
click node_health_checker "https://github.com/jashhh0908/strataproxy/blob/main/src/balancer/HealthChecker.ts"
click node_stream_pipe "https://github.com/jashhh0908/strataproxy/blob/main/src/proxy/StreamPipe.ts"
click node_header_parser "https://github.com/jashhh0908/strataproxy/blob/main/src/proxy/HeaderParser.ts"

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_gateway,node_config,node_client toneBlue
class node_rate_limiter,node_ring_buffer,node_lru_cache,node_linked_list,node_coalescer toneAmber
class node_upstream_pool,node_health_checker toneMint
class node_stream_pipe,node_header_parser toneRose
class node_upstreams toneIndigo
```

## Components

### Gateway

- [Request Gateway](https://github.com/jashhh0908/strataproxy/blob/main/src/server.ts): `src/server.ts`
- [Proxy Config](https://github.com/jashhh0908/strataproxy/blob/main/src/config.ts): `src/config.ts`

### Request Controls

- [Rate Limiter](https://github.com/jashhh0908/strataproxy/blob/main/src/limiter/RateLimiter.ts): `src/limiter/RateLimiter.ts`
- [Timestamp Ring](https://github.com/jashhh0908/strataproxy/blob/main/src/limiter/RingBuffer.ts): `src/limiter/RingBuffer.ts`
- [LRU Cache](https://github.com/jashhh0908/strataproxy/blob/main/src/cache/LruCache.ts): `src/cache/LruCache.ts`
- [Cache List](https://github.com/jashhh0908/strataproxy/blob/main/src/cache/DoublyLinkedList.ts): `src/cache/DoublyLinkedList.ts`
- [Request Coalescer](https://github.com/jashhh0908/strataproxy/blob/main/src/cache/Coalescer.ts): `src/cache/Coalescer.ts`

### Upstream Balancing

- [Upstream Pool](https://github.com/jashhh0908/strataproxy/blob/main/src/balancer/UpstreamPool.ts): `src/balancer/UpstreamPool.ts`
- [Health Checker](https://github.com/jashhh0908/strataproxy/blob/main/src/balancer/HealthChecker.ts): `src/balancer/HealthChecker.ts`

### Proxy Transport

- [Stream Forwarder](https://github.com/jashhh0908/strataproxy/blob/main/src/proxy/StreamPipe.ts): `src/proxy/StreamPipe.ts`
- [Header Sanitizer](https://github.com/jashhh0908/strataproxy/blob/main/src/proxy/HeaderParser.ts): `src/proxy/HeaderParser.ts`

### Other components

- **Client**
- **Upstream Services**

## Connections

- Client → Request Gateway: sends requests (evidence: `README.md`)
- Request Gateway → Proxy Config: reads settings (evidence: `src/server.ts`)
- Request Gateway → Rate Limiter: checks client (evidence: `src/server.ts`)
- Rate Limiter → Timestamp Ring: records timestamps (evidence: `src/limiter/RateLimiter.ts`)
- Request Gateway → LRU Cache: checks and stores (evidence: `src/server.ts`)
- LRU Cache → Cache List: updates recency (evidence: `src/cache/LruCache.ts`)
- Request Gateway → Request Coalescer: coalesces misses (evidence: `src/server.ts`)
- Request Gateway → Upstream Pool: selects target (evidence: `src/server.ts`)
- Request Gateway → Health Checker: starts and stops (evidence: `src/server.ts`)
- Health Checker → Upstream Pool: updates health (evidence: `src/balancer/HealthChecker.ts`)
- Health Checker → Upstream Services: probes health (evidence: `src/balancer/HealthChecker.ts`)
- Request Gateway → Stream Forwarder: forwards request (evidence: `src/server.ts`)
- Stream Forwarder → Header Sanitizer: sanitizes headers (evidence: `src/proxy/StreamPipe.ts`)
- Stream Forwarder → Upstream Services: streams request (evidence: `src/proxy/StreamPipe.ts`)
- Stream Forwarder → LRU Cache: stores response (evidence: `src/server.ts`)
