# carlostiago11/jev-gateway architecture

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

- Interactive diagram: https://gitdiagram.com/carlostiago11/jev-gateway
- Repository: https://github.com/carlostiago11/jev-gateway

## Overview

jev-gateway wraps coding-agent APIs with a local proxy: launchers start the gateway and then run the selected client; the gateway normalizes supported requests, asks Jev to choose a tool, rewrites eligible requests, and forwards traffic to the client’s usual LLM. The README also documents provider setup, fail-open routing, baseline metering, and a multi-gateway dashboard. Source excerpts show the central routing calls; some dashboard and adapter internals were not sampled, so uncertain links are omitted.

Main entry points: [`src/app.ts`](https://github.com/carlostiago11/jev-gateway/blob/main/src/app.ts) (HTTP gateway), [`bin/launcher.mjs`](https://github.com/carlostiago11/jev-gateway/blob/main/bin/launcher.mjs) (Agent launchers), [`src/decide.ts`](https://github.com/carlostiago11/jev-gateway/blob/main/src/decide.ts) (Tool decision), [`src/dashboard.ts`](https://github.com/carlostiago11/jev-gateway/blob/main/src/dashboard.ts) (Monitoring dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_launch["Launch and setup"]
  node_launchers["Agent launchers<br/>[launcher.mjs]"]
  node_client_specs["Client integration<br/>[clients.mjs]"]
  node_setup["Provider setup<br/>[setup.mjs]"]
end

subgraph group_gateway["Gateway APIs"]
  node_gateway_app["HTTP gateway<br/>[app.ts]"]
  node_chat_adapter["Chat adapter<br/>[chat.ts]"]
  node_messages_adapter["Messages adapter<br/>[messages.ts]"]
  node_responses_adapter["Responses adapter<br/>[responses.ts]"]
  node_gemini_adapter["Gemini adapter<br/>[gemini.ts]"]
  node_exa_adapter["Exa adapter<br/>[exa.ts]"]
  node_neutral_types["Neutral request model<br/>[types.ts]"]
end

subgraph group_routing["Tool routing"]
  node_jev_decision["Tool decision<br/>[decide.ts]"]
  node_question_builder["Decision questions<br/>[questions.ts]"]
  node_conversation_state["Conversation state<br/>[state.ts]"]
  node_jev_client["Jev API client<br/>[jev.ts]"]
end

subgraph group_ops["Monitoring and usage"]
  node_configuration["Gateway configuration<br/>[config.ts]"]
  node_event_log["Request event log<br/>[events.ts]"]
  node_usage_reader["Token usage reader<br/>[usage.ts]"]
  node_dashboard["Monitoring dashboard<br/>[dashboard.ts]"]
end

node_user(("Developer"))
node_agents["Coding agents"]
node_jev_providers["Jev providers"]
node_upstream["LLM upstream"]
node_browser(("Dashboard browser"))

node_user -->|"starts session"| node_launchers
node_launchers -->|"configures provider"| node_setup
node_launchers -->|"starts agent"| node_agents
node_launchers -->|"starts gateway"| node_gateway_app
node_client_specs -.->|"configures client"| node_agents
node_agents -->|"sends API requests"| node_gateway_app
node_gateway_app -->|"routes requests"| node_chat_adapter
node_gateway_app -->|"routes requests"| node_messages_adapter
node_gateway_app -->|"routes requests"| node_responses_adapter
node_gateway_app -->|"routes requests"| node_gemini_adapter
node_gateway_app -->|"routes requests"| node_exa_adapter
node_gateway_app -->|"requests decision"| node_jev_decision
node_gateway_app -->|"forwards requests"| node_upstream
node_gateway_app -->|"records events"| node_event_log
node_gateway_app -->|"reads usage"| node_usage_reader
node_jev_decision -->|"builds questions"| node_question_builder
node_jev_decision -->|"asks Jev"| node_jev_client
node_jev_decision -.->|"builds state"| node_conversation_state
node_jev_client -->|"calls provider"| node_jev_providers
node_gateway_app -->|"serves dashboard"| node_dashboard
node_browser -->|"views metrics"| node_dashboard
node_dashboard -.->|"reads events"| node_event_log

click node_launchers "https://github.com/carlostiago11/jev-gateway/blob/main/bin/launcher.mjs"
click node_client_specs "https://github.com/carlostiago11/jev-gateway/blob/main/bin/clients.mjs"
click node_setup "https://github.com/carlostiago11/jev-gateway/blob/main/bin/setup.mjs"
click node_gateway_app "https://github.com/carlostiago11/jev-gateway/blob/main/src/app.ts"
click node_chat_adapter "https://github.com/carlostiago11/jev-gateway/blob/main/src/adapters/chat.ts"
click node_messages_adapter "https://github.com/carlostiago11/jev-gateway/blob/main/src/adapters/messages.ts"
click node_responses_adapter "https://github.com/carlostiago11/jev-gateway/blob/main/src/adapters/responses.ts"
click node_gemini_adapter "https://github.com/carlostiago11/jev-gateway/blob/main/src/adapters/gemini.ts"
click node_exa_adapter "https://github.com/carlostiago11/jev-gateway/blob/main/src/adapters/exa.ts"
click node_neutral_types "https://github.com/carlostiago11/jev-gateway/blob/main/src/types.ts"
click node_jev_decision "https://github.com/carlostiago11/jev-gateway/blob/main/src/decide.ts"
click node_question_builder "https://github.com/carlostiago11/jev-gateway/blob/main/src/questions.ts"
click node_conversation_state "https://github.com/carlostiago11/jev-gateway/blob/main/src/state.ts"
click node_jev_client "https://github.com/carlostiago11/jev-gateway/blob/main/src/jev.ts"
click node_configuration "https://github.com/carlostiago11/jev-gateway/blob/main/src/config.ts"
click node_event_log "https://github.com/carlostiago11/jev-gateway/blob/main/src/events.ts"
click node_usage_reader "https://github.com/carlostiago11/jev-gateway/blob/main/src/usage.ts"
click node_dashboard "https://github.com/carlostiago11/jev-gateway/blob/main/src/dashboard.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_launchers,node_client_specs,node_setup,node_browser toneBlue
class node_gateway_app,node_chat_adapter,node_messages_adapter,node_responses_adapter,node_gemini_adapter,node_exa_adapter,node_neutral_types toneAmber
class node_jev_decision,node_question_builder,node_conversation_state,node_jev_client toneMint
class node_configuration,node_event_log,node_usage_reader,node_dashboard toneRose
class node_user,node_agents,node_jev_providers,node_upstream toneIndigo
```

## Components

### Launch and setup

- [Agent launchers](https://github.com/carlostiago11/jev-gateway/blob/main/bin/launcher.mjs): `bin/launcher.mjs`
- [Client integration](https://github.com/carlostiago11/jev-gateway/blob/main/bin/clients.mjs): `bin/clients.mjs`
- [Provider setup](https://github.com/carlostiago11/jev-gateway/blob/main/bin/setup.mjs): `bin/setup.mjs`

### Gateway APIs

- [HTTP gateway](https://github.com/carlostiago11/jev-gateway/blob/main/src/app.ts): `src/app.ts`
- [Chat adapter](https://github.com/carlostiago11/jev-gateway/blob/main/src/adapters/chat.ts): `src/adapters/chat.ts`
- [Messages adapter](https://github.com/carlostiago11/jev-gateway/blob/main/src/adapters/messages.ts): `src/adapters/messages.ts`
- [Responses adapter](https://github.com/carlostiago11/jev-gateway/blob/main/src/adapters/responses.ts): `src/adapters/responses.ts`
- [Gemini adapter](https://github.com/carlostiago11/jev-gateway/blob/main/src/adapters/gemini.ts): `src/adapters/gemini.ts`
- [Exa adapter](https://github.com/carlostiago11/jev-gateway/blob/main/src/adapters/exa.ts): `src/adapters/exa.ts`
- [Neutral request model](https://github.com/carlostiago11/jev-gateway/blob/main/src/types.ts): `src/types.ts`

### Tool routing

- [Tool decision](https://github.com/carlostiago11/jev-gateway/blob/main/src/decide.ts): `src/decide.ts`
- [Decision questions](https://github.com/carlostiago11/jev-gateway/blob/main/src/questions.ts): `src/questions.ts`
- [Conversation state](https://github.com/carlostiago11/jev-gateway/blob/main/src/state.ts): `src/state.ts`
- [Jev API client](https://github.com/carlostiago11/jev-gateway/blob/main/src/jev.ts): `src/jev.ts`

### Monitoring and usage

- [Gateway configuration](https://github.com/carlostiago11/jev-gateway/blob/main/src/config.ts): `src/config.ts`
- [Request event log](https://github.com/carlostiago11/jev-gateway/blob/main/src/events.ts): `src/events.ts`
- [Token usage reader](https://github.com/carlostiago11/jev-gateway/blob/main/src/usage.ts): `src/usage.ts`
- [Monitoring dashboard](https://github.com/carlostiago11/jev-gateway/blob/main/src/dashboard.ts): `src/dashboard.ts`

### Other components

- **Developer**
- **Coding agents**
- **Jev providers**
- **LLM upstream**
- **Dashboard browser**

## Connections

- Developer → Agent launchers: starts session (evidence: `README.md`)
- Agent launchers → Provider setup: configures provider (evidence: `bin/launcher.mjs`)
- Agent launchers → Coding agents: starts agent (evidence: `README.md`)
- Agent launchers → HTTP gateway: starts gateway (evidence: `README.md`)
- Client integration → Coding agents: configures client
- Coding agents → HTTP gateway: sends API requests (evidence: `README.md`)
- HTTP gateway → Chat adapter: routes requests (evidence: `src/app.ts`)
- HTTP gateway → Messages adapter: routes requests (evidence: `src/app.ts`)
- HTTP gateway → Responses adapter: routes requests (evidence: `src/app.ts`)
- HTTP gateway → Gemini adapter: routes requests (evidence: `src/app.ts`)
- HTTP gateway → Exa adapter: routes requests (evidence: `src/app.ts`)
- HTTP gateway → Tool decision: requests decision (evidence: `src/app.ts`)
- HTTP gateway → LLM upstream: forwards requests (evidence: `src/app.ts`)
- HTTP gateway → Request event log: records events (evidence: `src/app.ts`)
- HTTP gateway → Token usage reader: reads usage (evidence: `src/app.ts`)
- Tool decision → Decision questions: builds questions (evidence: `src/decide.ts`)
- Tool decision → Jev API client: asks Jev (evidence: `src/decide.ts`)
- Tool decision → Conversation state: builds state (evidence: `src/decide.ts`)
- Jev API client → Jev providers: calls provider (evidence: `README.md`)
- HTTP gateway → Monitoring dashboard: serves dashboard (evidence: `README.md`)
- Dashboard browser → Monitoring dashboard: views metrics (evidence: `README.md`)
- Monitoring dashboard → Request event log: reads events (evidence: `src/dashboard.ts`)
