# 22wink/vite-enhanced-proxy architecture

> Architecture diagram of the GitHub repository 22wink/vite-enhanced-proxy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/22wink/vite-enhanced-proxy
- Repository: https://github.com/22wink/vite-enhanced-proxy

## Overview

vite-enhanced-proxy is a development-time Vite proxy plugin. A Vite user configures and registers the plugin; at startup it can load external proxy settings, resolve target routes, and install Vite proxy handlers. Those handlers forward HTTP, SSE, and WebSocket traffic to selected backends, with filtering, rewrites, middleware, and logging. The plugin and logger implementations are sampled; README capabilities such as detailed request/response logging are included, but their exact internal wiring is not fully shown.

Main entry points: [`modules/plugin.ts`](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts) (Proxy plugin), [`modules/logger.ts`](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/logger.ts) (Proxy logger), [`index.ts`](https://github.com/22wink/vite-enhanced-proxy/blob/main/index.ts) (Public API), [`modules/config-loader.ts`](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/config-loader.ts) (External config loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Plugin entry"]
  node_api["Public API<br/>[index.ts]"]
  node_plugin["Proxy plugin<br/>[plugin.ts]"]
  node_types["Options and types<br/>[types.ts]"]
end

subgraph group_routing["Config and routing"]
  node_external["External config loader<br/>[config-loader.ts]"]
  node_route["Target and rewrite selection<br/>[plugin.ts]"]
end

subgraph group_traffic["Proxy traffic"]
  node_http["HTTP proxy handling<br/>[plugin.ts]"]
  node_sse["SSE proxy handling<br/>[plugin.ts]"]
  node_ws["WebSocket proxy handling<br/>[plugin.ts]"]
  node_middleware["Request middleware and filters<br/>[plugin.ts]"]
end

subgraph group_observability["Logging"]
  node_logger["Proxy logger<br/>[logger.ts]"]
end

node_user(("Vite user"))
node_vite["Vite dev server"]
node_backend(("Configured backends"))
node_console(("Console"))

node_user -->|"configures"| node_api
node_api -->|"creates"| node_plugin
node_api -->|"exports types"| node_types
node_api -->|"exports logger"| node_logger
node_plugin -->|"registers hooks"| node_vite
node_plugin -->|"loads config"| node_external
node_external -->|"returns config"| node_plugin
node_plugin -->|"resolves targets"| node_route
node_route -->|"configures routes"| node_http
node_route -->|"configures routes"| node_sse
node_route -->|"configures routes"| node_ws
node_http -->|"forwards HTTP"| node_backend
node_sse -->|"forwards events"| node_backend
node_ws -->|"forwards sockets"| node_backend
node_http -->|"applies filters"| node_middleware
node_sse -->|"runs middleware"| node_middleware
node_ws -->|"runs middleware"| node_middleware
node_plugin -->|"creates logger"| node_logger
node_http -->|"logs traffic"| node_logger
node_sse -->|"logs events"| node_logger
node_ws -->|"logs connections"| node_logger
node_logger -->|"writes logs"| node_console

click node_api "https://github.com/22wink/vite-enhanced-proxy/blob/main/index.ts"
click node_plugin "https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts"
click node_types "https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/types.ts"
click node_external "https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/config-loader.ts"
click node_route "https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts"
click node_http "https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts"
click node_sse "https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts"
click node_ws "https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts"
click node_middleware "https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts"
click node_logger "https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/logger.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_api,node_plugin,node_types,node_user toneBlue
class node_external,node_route toneAmber
class node_http,node_sse,node_ws,node_middleware,node_vite toneMint
class node_logger toneRose
class node_backend,node_console toneIndigo
```

## Components

### Plugin entry

- [Public API](https://github.com/22wink/vite-enhanced-proxy/blob/main/index.ts): `index.ts`
- [Proxy plugin](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts): `modules/plugin.ts`
- [Options and types](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/types.ts): `modules/types.ts`

### Config and routing

- [External config loader](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/config-loader.ts): `modules/config-loader.ts`
- [Target and rewrite selection](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts): `modules/plugin.ts`

### Proxy traffic

- [HTTP proxy handling](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts): `modules/plugin.ts`
- [SSE proxy handling](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts): `modules/plugin.ts`
- [WebSocket proxy handling](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts): `modules/plugin.ts`
- [Request middleware and filters](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/plugin.ts): `modules/plugin.ts`

### Logging

- [Proxy logger](https://github.com/22wink/vite-enhanced-proxy/blob/main/modules/logger.ts): `modules/logger.ts`

### Other components

- **Vite user**
- **Vite dev server**
- **Configured backends**
- **Console**

## Connections

- Vite user → Public API: configures
- Public API → Proxy plugin: creates
- Public API → Options and types: exports types
- Public API → Proxy logger: exports logger
- Proxy plugin → Vite dev server: registers hooks
- Proxy plugin → External config loader: loads config
- External config loader → Proxy plugin: returns config
- Proxy plugin → Target and rewrite selection: resolves targets
- Target and rewrite selection → HTTP proxy handling: configures routes
- Target and rewrite selection → SSE proxy handling: configures routes
- Target and rewrite selection → WebSocket proxy handling: configures routes
- HTTP proxy handling → Configured backends: forwards HTTP
- SSE proxy handling → Configured backends: forwards events
- WebSocket proxy handling → Configured backends: forwards sockets
- HTTP proxy handling → Request middleware and filters: applies filters
- SSE proxy handling → Request middleware and filters: runs middleware
- WebSocket proxy handling → Request middleware and filters: runs middleware
- Proxy plugin → Proxy logger: creates logger
- HTTP proxy handling → Proxy logger: logs traffic
- SSE proxy handling → Proxy logger: logs events
- WebSocket proxy handling → Proxy logger: logs connections
- Proxy logger → Console: writes logs
