# aryaraj76438/order-execution-engine-application architecture

> Architecture diagram of the GitHub repository aryaraj76438/order-execution-engine-application, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aryaraj76438/order-execution-engine-application
- Repository: https://github.com/aryaraj76438/order-execution-engine-application

## Overview

This Spring Boot application accepts market orders through a REST API or its web interface, persists them, and queues them for asynchronous processing. The execution service obtains simulated Raydium and Meteora quotes, selects the better output, simulates a swap, persists lifecycle changes, and publishes status updates over WebSockets. Users can also query order history, individual status, and queue statistics. The README documents retries and slippage protection; sampled source confirms retries, but does not show slippage enforcement. The graph reflects the sampled implementation and documented capabilities without assuming unsampled wiring.

Main entry points: [`src/main/java/com/dex/orderengine/service/OrderExecutionService.java`](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/service/OrderExecutionService.java) (Execution service), [`src/main/java/com/dex/orderengine/controller/OrderController.java`](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/controller/OrderController.java) (Order API), [`src/main/java/com/dex/orderengine/controller/WebController.java`](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/controller/WebController.java) (Web controller), [`src/main/java/com/dex/orderengine/service/WebSocketNotificationService.java`](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/service/WebSocketNotificationService.java) (Notification service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry points"]
  node_order_controller["Order API"]
  node_web_controller["Web controller<br/>[WebController.java]"]
  node_web_page["Order page<br/>[index.html]"]
  node_order_request["Order request<br/>[OrderRequest.java]"]
  node_order_response["Order response<br/>[OrderResponse.java]"]
  node_exception_handler["API error handling"]
end

subgraph group_execution["Order execution"]
  node_execution_service["Execution service"]
  node_order_model["Order lifecycle<br/>[Order.java]"]
end

subgraph group_routing["DEX routing"]
  node_routing_service["Mock DEX router"]
end

subgraph group_state["Persistence and queue"]
  node_queue_service["Order queue"]
  node_order_repository["Order repository"]
end

subgraph group_updates["Live updates"]
  node_notification_service["Notification service"]
  node_websocket_config["WebSocket setup"]
end

node_trader(("Trader"))
node_browser(("Web browser"))
node_postgres[("PostgreSQL")]
node_websocket_client(("WebSocket client"))

node_trader -->|"submits orders"| node_order_controller
node_order_controller -->|"validates input"| node_order_request
node_order_controller -->|"submits or queries"| node_execution_service
node_execution_service -->|"maps results"| node_order_response
node_execution_service -->|"saves and reads"| node_order_repository
node_order_repository -->|"persists orders"| node_postgres
node_execution_service -->|"enqueues and polls"| node_queue_service
node_queue_service -->|"returns order ID"| node_execution_service
node_execution_service -->|"quotes and executes"| node_routing_service
node_execution_service -->|"publishes lifecycle"| node_notification_service
node_web_controller -->|"loads recent orders"| node_execution_service
node_web_controller -->|"reads queue stats"| node_queue_service
node_browser -->|"requests page"| node_web_controller
node_web_controller -->|"renders template"| node_web_page
node_web_page -->|"displays orders"| node_browser
node_browser -->|"subscribes"| node_websocket_client
node_websocket_client -->|"connects"| node_websocket_config
node_notification_service -->|"sends updates"| node_websocket_config
node_notification_service -->|"streams statuses"| node_websocket_client
node_order_controller -->|"delegates API errors"| node_exception_handler

click node_order_controller "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/controller/OrderController.java"
click node_web_controller "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/controller/WebController.java"
click node_web_page "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/resources/templates/index.html"
click node_order_request "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/dto/OrderRequest.java"
click node_order_response "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/dto/OrderResponse.java"
click node_execution_service "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/service/OrderExecutionService.java"
click node_queue_service "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/service/OrderQueueService.java"
click node_routing_service "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/service/MockDexRoutingService.java"
click node_order_model "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/model/Order.java"
click node_order_repository "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/repository/OrderRepository.java"
click node_notification_service "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/service/WebSocketNotificationService.java"
click node_websocket_config "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/config/WebSocketConfig.java"
click node_exception_handler "https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/controller/GlobalExceptionHandler.java"

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_order_controller,node_web_controller,node_web_page,node_order_request,node_order_response,node_exception_handler,node_browser,node_websocket_client toneBlue
class node_execution_service,node_order_model,node_postgres toneAmber
class node_routing_service toneMint
class node_queue_service,node_order_repository toneRose
class node_notification_service,node_websocket_config,node_trader toneIndigo
```

## Components

### User entry points

- [Order API](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/controller/OrderController.java): `src/main/java/com/dex/orderengine/controller/OrderController.java`
- [Web controller](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/controller/WebController.java): `src/main/java/com/dex/orderengine/controller/WebController.java`
- [Order page](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/resources/templates/index.html): `src/main/resources/templates/index.html`
- [Order request](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/dto/OrderRequest.java): `src/main/java/com/dex/orderengine/dto/OrderRequest.java`
- [Order response](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/dto/OrderResponse.java): `src/main/java/com/dex/orderengine/dto/OrderResponse.java`
- [API error handling](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/controller/GlobalExceptionHandler.java): `src/main/java/com/dex/orderengine/controller/GlobalExceptionHandler.java`

### Order execution

- [Execution service](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/service/OrderExecutionService.java): `src/main/java/com/dex/orderengine/service/OrderExecutionService.java`
- [Order lifecycle](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/model/Order.java): `src/main/java/com/dex/orderengine/model/Order.java`

### DEX routing

- [Mock DEX router](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/service/MockDexRoutingService.java): `src/main/java/com/dex/orderengine/service/MockDexRoutingService.java`

### Persistence and queue

- [Order queue](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/service/OrderQueueService.java): `src/main/java/com/dex/orderengine/service/OrderQueueService.java`
- [Order repository](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/repository/OrderRepository.java): `src/main/java/com/dex/orderengine/repository/OrderRepository.java`

### Live updates

- [Notification service](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/service/WebSocketNotificationService.java): `src/main/java/com/dex/orderengine/service/WebSocketNotificationService.java`
- [WebSocket setup](https://github.com/aryaraj76438/order-execution-engine-application/blob/main/src/main/java/com/dex/orderengine/config/WebSocketConfig.java): `src/main/java/com/dex/orderengine/config/WebSocketConfig.java`

### Other components

- **Trader**
- **Web browser**
- **PostgreSQL**
- **WebSocket client**

## Connections

- Trader → Order API: submits orders
- Order API → Order request: validates input
- Order API → Execution service: submits or queries
- Execution service → Order response: maps results
- Execution service → Order repository: saves and reads
- Order repository → PostgreSQL: persists orders
- Execution service → Order queue: enqueues and polls
- Order queue → Execution service: returns order ID
- Execution service → Mock DEX router: quotes and executes
- Execution service → Notification service: publishes lifecycle
- Web controller → Execution service: loads recent orders
- Web controller → Order queue: reads queue stats
- Web browser → Web controller: requests page
- Web controller → Order page: renders template
- Order page → Web browser: displays orders
- Web browser → WebSocket client: subscribes
- WebSocket client → WebSocket setup: connects
- Notification service → WebSocket setup: sends updates
- Notification service → WebSocket client: streams statuses
- Order API → API error handling: delegates API errors
