Skip to content

Architecture Overview

GodeX is a gateway that translates OpenAI Responses API requests into Chat Completions API calls for any configured upstream provider. It follows a layered architecture with clear separation of concerns: protocol handling at the boundary, bridge logic in the middle, and provider-specific code isolated in specs and hooks.

This page has two complementary views: the request lifecycle (how a single request flows through the system) and the component model (what the building blocks are and how they depend on each other). Understanding both is essential for debugging compatibility issues, adding new providers, or extending the bridge.

At a Glance

LayerComponentResponsibility
CLIserveBootstraps config, registrar, ApplicationContext, and Bun server
ApplicationApplicationContextHolds config, resolver, registrar, session store, trace recorder
ApplicationApplicationServicesFactory that wires logger, ModelResolver, Registrar, ResponsesBridgeRuntime
ServercreateBuiltinRoutesMaps /health, /v1/models, /v1/responses to handlers
RoutehandleResponsesParses request, creates ResponsesContext, dispatches
ContextResponsesContextPer-request state: resolved model, provider, session, diagnostics
BridgeProviderExchangeBuilds Chat Completion request, calls upstream, records traces
BridgeResponsesBridgeRuntimeSelects sync or stream pipeline
ProviderRegistrarManages ProviderEdge factories and resolved instances
ResolverModelResolverMaps model selectors to (provider, model) pairs

Request Lifecycle

Core Types

Startup Sequence

Request Processing Sequence

Bridge Pipeline Detail

The bridge pipeline inside ProviderExchange follows a fixed sequence. Each step contributes decisions and data that downstream steps consume:

StepFunctionOutput
1planBridgeCompatibilityCompatibility plan with parameter decisions
2planToolsTool declarations, tool_choice, tool decisions
3planOutputContractResponse format plan (native, degraded, or synthetic)
4normalizeCurrentInput + normalizeResponseItemsNormalized ChatCompletionMessageParam[]
5buildChatMessagesMerged assistant messages with tool calls
6applyToolsrequest.tools and request.tool_choice
7applyRequestOptionsstream, temperature, top_p, max_tokens, reasoning

System Components

The full request path connects every layer — from the Bun server routes through the bridge request builder, the provider edge, and the reconstruction layer:

The core domain types and their relationships:

Layer Responsibilities

LayerModuleRole
Serversrc/server/HTTP routing, request parsing, SSE encoding, error handling
Contextsrc/context/ApplicationContext (app-wide services) and ResponsesContext (per-request state)
Bridgesrc/bridge/Provider-agnostic Responses-to-Chat planning and reconstruction
Responsessrc/responses/Sync and stream orchestration pipelines around the bridge
Providersrc/providers/Provider-specific specs, hooks, clients, and registry
Sessionsrc/session/History persistence and previous_response_id chain resolution
Resolversrc/resolver/Model alias and provider/model selector resolution
Configsrc/config/YAML schema, env interpolation, defaults, validation
Errorsrc/error/Structured error hierarchy with domain codes

Dependency Flow

Cross-References

References