# nqdev-fork/diegosouzapw-omniroute architecture

> Architecture diagram of the GitHub repository nqdev-fork/diegosouzapw-omniroute, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nqdev-fork/diegosouzapw-omniroute
- Repository: https://github.com/nqdev-fork/diegosouzapw-omniroute

## Overview

OmniRoute is an AI gateway and management application: clients send compatible API requests, the gateway selects a provider/executor, translates formats, streams the response, and records usage. Its documented product surface also includes multimodal and search APIs, routing/compression features, a dashboard, MCP tools, and A2A. The graph uses sampled calls and SOURCE INDEX references for internal edges; README-only capability links are documented relationships, not claims that unsampled modules were inspected.

Main entry points: [`open-sse/handlers/chatCore.ts`](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/handlers/chatCore.ts) (Chat handler), [`open-sse/index.ts`](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/index.ts) (API entry), [`open-sse/utils/stream.ts`](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/utils/stream.ts) (SSE response stream), [`open-sse/executors/index.ts`](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/executors/index.ts) (Executor dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway runtime"]
  node_entry["API entry<br/>[index.ts]"]
  node_chat["Chat handler<br/>[chatCore.ts]"]
  node_translation["Format translation<br/>[index.ts]"]
  node_formats["Format identifiers<br/>[formats.ts]"]
  node_stream["SSE response stream<br/>[stream.ts]"]
end

subgraph group_routing["Routing and policy"]
  node_provider["Provider setup<br/>[provider.ts]"]
  node_registry["Provider registry"]
  node_executor["Executor dispatch<br/>[index.ts]"]
  node_codex["Codex executor<br/>[codex.ts]"]
  node_base["Executor base<br/>[base.ts]"]
  node_fallback["Account fallback<br/>[accountFallback.ts]"]
  node_policy["Request policies<br/>[policyEngine.ts]"]
end

subgraph group_capabilities["AI capabilities"]
  node_multimodal["Multimodal and search APIs"]
  node_compression["Prompt compression"]
  node_auto_combo["Auto-combo routing<br/>[engine.ts]"]
end

subgraph group_management["Management and agents"]
  node_dashboard["Web dashboard<br/>[page.tsx]"]
  node_mcp["MCP server<br/>[server.ts]"]
  node_a2a["A2A protocol<br/>[route.ts]"]
end

subgraph group_state["State and accounting"]
  node_usage["Usage tracking<br/>[usageTracking.ts]"]
  node_usage_db[("Usage records<br/>[usageDb.ts]")]
  node_db[("Application database<br/>[core.ts]")]
end

node_client(("API client"))
node_upstream["AI providers"]

node_client -->|"submits request"| node_entry
node_entry -->|"routes chat"| node_chat
node_chat -->|"resolves provider"| node_provider
node_chat -->|"translates formats"| node_translation
node_translation -->|"uses identifiers"| node_formats
node_chat -.->|"selects executor"| node_executor
node_executor -->|"dispatches Codex"| node_codex
node_codex -->|"extends"| node_base
node_provider -->|"reads provider config"| node_registry
node_entry -->|"uses fallback"| node_fallback
node_client -.->|"request evaluated"| node_policy
node_executor -.->|"sends provider request"| node_upstream
node_chat -->|"creates response stream"| node_stream
node_stream -->|"translates stream events"| node_translation
node_stream -->|"extracts usage"| node_usage
node_usage -->|"records usage"| node_usage_db
node_dashboard -.->|"configures gateway"| node_client
node_client -->|"requests AI features"| node_multimodal
node_client -->|"uses compression"| node_compression
node_client -->|"uses auto routing"| node_auto_combo
node_client -->|"invokes tools"| node_mcp
node_mcp -->|"accesses application data"| node_db
node_client -->|"uses A2A protocol"| node_a2a

click node_entry "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/index.ts"
click node_chat "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/handlers/chatCore.ts"
click node_translation "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/translator/index.ts"
click node_formats "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/translator/formats.ts"
click node_provider "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/services/provider.ts"
click node_registry "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/config/providerRegistry.ts"
click node_executor "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/executors/index.ts"
click node_codex "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/executors/codex.ts"
click node_base "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/executors/base.ts"
click node_fallback "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/services/accountFallback.ts"
click node_policy "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/src/domain/policyEngine.ts"
click node_stream "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/utils/stream.ts"
click node_usage "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/utils/usageTracking.ts"
click node_usage_db "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/src/lib/usageDb.ts"
click node_db "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/src/lib/db/core.ts"
click node_dashboard "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/src/app/(dashboard)/dashboard/page.tsx"
click node_multimodal "https://github.com/nqdev-fork/diegosouzapw-omniroute/tree/main/open-sse/handlers"
click node_compression "https://github.com/nqdev-fork/diegosouzapw-omniroute/tree/main/open-sse/services/compression"
click node_auto_combo "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/services/autoCombo/engine.ts"
click node_mcp "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/mcp-server/server.ts"
click node_a2a "https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/src/app/a2a/route.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_entry,node_chat,node_translation,node_formats,node_stream,node_client toneBlue
class node_provider,node_registry,node_executor,node_codex,node_base,node_fallback,node_policy toneAmber
class node_multimodal,node_compression,node_auto_combo toneMint
class node_dashboard,node_mcp,node_a2a toneRose
class node_usage,node_usage_db,node_db,node_upstream toneIndigo
```

## Components

### Gateway runtime

- [API entry](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/index.ts): `open-sse/index.ts`
- [Chat handler](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/handlers/chatCore.ts): `open-sse/handlers/chatCore.ts`
- [Format translation](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/translator/index.ts): `open-sse/translator/index.ts`
- [Format identifiers](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/translator/formats.ts): `open-sse/translator/formats.ts`
- [SSE response stream](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/utils/stream.ts): `open-sse/utils/stream.ts`

### Routing and policy

- [Provider setup](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/services/provider.ts): `open-sse/services/provider.ts`
- [Provider registry](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/config/providerRegistry.ts): `open-sse/config/providerRegistry.ts`
- [Executor dispatch](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/executors/index.ts): `open-sse/executors/index.ts`
- [Codex executor](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/executors/codex.ts): `open-sse/executors/codex.ts`
- [Executor base](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/executors/base.ts): `open-sse/executors/base.ts`
- [Account fallback](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/services/accountFallback.ts): `open-sse/services/accountFallback.ts`
- [Request policies](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/src/domain/policyEngine.ts): `src/domain/policyEngine.ts`

### AI capabilities

- [Multimodal and search APIs](https://github.com/nqdev-fork/diegosouzapw-omniroute/tree/main/open-sse/handlers): `open-sse/handlers`
- [Prompt compression](https://github.com/nqdev-fork/diegosouzapw-omniroute/tree/main/open-sse/services/compression): `open-sse/services/compression`
- [Auto-combo routing](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/services/autoCombo/engine.ts): `open-sse/services/autoCombo/engine.ts`

### Management and agents

- [Web dashboard](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/src/app/(dashboard)/dashboard/page.tsx): `src/app/(dashboard)/dashboard/page.tsx`
- [MCP server](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/mcp-server/server.ts): `open-sse/mcp-server/server.ts`
- [A2A protocol](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/src/app/a2a/route.ts): `src/app/a2a/route.ts`

### State and accounting

- [Usage tracking](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/open-sse/utils/usageTracking.ts): `open-sse/utils/usageTracking.ts`
- [Usage records](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/src/lib/usageDb.ts): `src/lib/usageDb.ts`
- [Application database](https://github.com/nqdev-fork/diegosouzapw-omniroute/blob/main/src/lib/db/core.ts): `src/lib/db/core.ts`

### Other components

- **API client**
- **AI providers**

## Connections

- API client → API entry: submits request (evidence: `README.md`)
- API entry → Chat handler: routes chat (evidence: `open-sse/index.ts`)
- Chat handler → Provider setup: resolves provider (evidence: `open-sse/handlers/chatCore.ts`)
- Chat handler → Format translation: translates formats (evidence: `open-sse/handlers/chatCore.ts`)
- Format translation → Format identifiers: uses identifiers (evidence: `open-sse/translator/index.ts`)
- Chat handler → Executor dispatch: selects executor (evidence: `open-sse/handlers/chatCore.ts`)
- Executor dispatch → Codex executor: dispatches Codex (evidence: `open-sse/executors/index.ts`)
- Codex executor → Executor base: extends (evidence: `open-sse/executors/codex.ts`)
- Provider setup → Provider registry: reads provider config (evidence: `open-sse/services/provider.ts`)
- API entry → Account fallback: uses fallback (evidence: `open-sse/index.ts`)
- API client → Request policies: request evaluated
- Executor dispatch → AI providers: sends provider request
- Chat handler → SSE response stream: creates response stream (evidence: `open-sse/handlers/chatCore.ts`)
- SSE response stream → Format translation: translates stream events (evidence: `open-sse/utils/stream.ts`)
- SSE response stream → Usage tracking: extracts usage (evidence: `open-sse/utils/stream.ts`)
- Usage tracking → Usage records: records usage (evidence: `open-sse/utils/stream.ts`)
- Web dashboard → API client: configures gateway
- API client → Multimodal and search APIs: requests AI features (evidence: `README.md`)
- API client → Prompt compression: uses compression (evidence: `README.md`)
- API client → Auto-combo routing: uses auto routing (evidence: `README.md`)
- API client → MCP server: invokes tools (evidence: `README.md`)
- MCP server → Application database: accesses application data (evidence: `open-sse/mcp-server/server.ts`)
- API client → A2A protocol: uses A2A protocol (evidence: `README.md`)
