# arthurg-tech/homebroker architecture

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

- Interactive diagram: https://gitdiagram.com/arthurg-tech/homebroker
- Repository: https://github.com/arthurg-tech/homebroker

## Overview

Home Broker is a small order-entry application: users enter asset, side, quantity and price in the React form, which validates and submits a new order to the ASP.NET API. The API validates the request, applies the full order value subject to a per-asset exposure limit, and returns the current exposure or an error for display. Exposure is held in process memory, not a persistent order store. The map follows the shown calls and documented HTTP contract; optional OpenAPI and development CORS are included, while unsampled implementation details are not inferred.

Main entry points: [`backend/OrderAccumulator/Endpoints/OrderEndpoints.cs`](https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Endpoints/OrderEndpoints.cs) (Order endpoint), [`frontend/OrderGenerator/src/orderApi.ts`](https://github.com/arthurg-tech/homebroker/blob/main/frontend/OrderGenerator/src/orderApi.ts) (API client), [`backend/OrderAccumulator/Services/ExposureService.cs`](https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Services/ExposureService.cs) (Exposure service), [`frontend/OrderGenerator/src/App.tsx`](https://github.com/arthurg-tech/homebroker/blob/main/frontend/OrderGenerator/src/App.tsx) (Order form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Order entry UI"]
  node_app["Order form<br/>[App.tsx]"]
  node_validation_ui["Form validation<br/>[orderValidation.ts]"]
  node_api_client["API client<br/>[orderApi.ts]"]
end

subgraph group_backend["Order processing"]
  node_api["Order endpoint<br/>[OrderEndpoints.cs]"]
  node_validator["Request validation"]
  node_exposure["Exposure service<br/>[ExposureService.cs]"]
  node_memory[("In-memory exposure<br/>[ExposureService.cs]")]
  node_host["API host<br/>[Program.cs]"]
end

subgraph group_contracts["Order contracts"]
  node_request["Order request<br/>[OrderRequest.cs]"]
  node_response["Order response<br/>[OrderResponse.cs]"]
end

node_user(("Trader"))
node_browser(("Browser"))

node_user -->|"enters order"| node_app
node_app -->|"validates form"| node_validation_ui
node_app -->|"submits order"| node_api_client
node_api_client -->|"POST order"| node_api
node_api_client -->|"serializes"| node_request
node_api_client -->|"checks response"| node_response
node_host -->|"maps endpoint"| node_api
node_api -->|"classifies errors"| node_validator
node_api -->|"processes order"| node_exposure
node_exposure -->|"validates request"| node_validator
node_exposure -->|"updates exposure"| node_memory
node_exposure -->|"creates result"| node_response
node_api -->|"deserializes"| node_request
node_api -->|"returns JSON"| node_response
node_api -.->|"allows dev CORS"| node_browser
node_browser -->|"renders UI"| node_app

click node_app "https://github.com/arthurg-tech/homebroker/blob/main/frontend/OrderGenerator/src/App.tsx"
click node_validation_ui "https://github.com/arthurg-tech/homebroker/blob/main/frontend/OrderGenerator/src/orderValidation.ts"
click node_api_client "https://github.com/arthurg-tech/homebroker/blob/main/frontend/OrderGenerator/src/orderApi.ts"
click node_api "https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Endpoints/OrderEndpoints.cs"
click node_validator "https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Validation/OrderRequestValidator.cs"
click node_exposure "https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Services/ExposureService.cs"
click node_memory "https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Services/ExposureService.cs"
click node_host "https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Program.cs"
click node_request "https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Contracts/OrderRequest.cs"
click node_response "https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Contracts/OrderResponse.cs"

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_app,node_validation_ui,node_api_client,node_browser toneBlue
class node_api,node_validator,node_exposure,node_memory,node_host toneAmber
class node_request,node_response toneMint
class node_user toneIndigo
```

## Components

### Order entry UI

- [Order form](https://github.com/arthurg-tech/homebroker/blob/main/frontend/OrderGenerator/src/App.tsx): `frontend/OrderGenerator/src/App.tsx`
- [Form validation](https://github.com/arthurg-tech/homebroker/blob/main/frontend/OrderGenerator/src/orderValidation.ts): `frontend/OrderGenerator/src/orderValidation.ts`
- [API client](https://github.com/arthurg-tech/homebroker/blob/main/frontend/OrderGenerator/src/orderApi.ts): `frontend/OrderGenerator/src/orderApi.ts`

### Order processing

- [Order endpoint](https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Endpoints/OrderEndpoints.cs): `backend/OrderAccumulator/Endpoints/OrderEndpoints.cs`
- [Request validation](https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Validation/OrderRequestValidator.cs): `backend/OrderAccumulator/Validation/OrderRequestValidator.cs`
- [Exposure service](https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Services/ExposureService.cs): `backend/OrderAccumulator/Services/ExposureService.cs`
- [In-memory exposure](https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Services/ExposureService.cs): `backend/OrderAccumulator/Services/ExposureService.cs`
- [API host](https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Program.cs): `backend/OrderAccumulator/Program.cs`

### Order contracts

- [Order request](https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Contracts/OrderRequest.cs): `backend/OrderAccumulator/Contracts/OrderRequest.cs`
- [Order response](https://github.com/arthurg-tech/homebroker/blob/main/backend/OrderAccumulator/Contracts/OrderResponse.cs): `backend/OrderAccumulator/Contracts/OrderResponse.cs`

### Other components

- **Trader**
- **Browser**

## Connections

- Trader → Order form: enters order (evidence: `frontend/OrderGenerator/src/App.tsx`)
- Order form → Form validation: validates form (evidence: `frontend/OrderGenerator/src/App.tsx`)
- Order form → API client: submits order (evidence: `frontend/OrderGenerator/src/App.tsx`)
- API client → Order endpoint: POST order (evidence: `frontend/OrderGenerator/src/orderApi.ts`)
- API client → Order request: serializes (evidence: `frontend/OrderGenerator/src/orderApi.ts`)
- API client → Order response: checks response (evidence: `frontend/OrderGenerator/src/orderApi.ts`)
- API host → Order endpoint: maps endpoint (evidence: `backend/OrderAccumulator/Program.cs`)
- Order endpoint → Request validation: classifies errors (evidence: `backend/OrderAccumulator/Endpoints/OrderEndpoints.cs`)
- Order endpoint → Exposure service: processes order (evidence: `backend/OrderAccumulator/Endpoints/OrderEndpoints.cs`)
- Exposure service → Request validation: validates request (evidence: `backend/OrderAccumulator/Services/ExposureService.cs`)
- Exposure service → In-memory exposure: updates exposure (evidence: `backend/OrderAccumulator/Services/ExposureService.cs`)
- Exposure service → Order response: creates result (evidence: `backend/OrderAccumulator/Services/ExposureService.cs`)
- Order endpoint → Order request: deserializes (evidence: `backend/OrderAccumulator/Endpoints/OrderEndpoints.cs`)
- Order endpoint → Order response: returns JSON (evidence: `backend/OrderAccumulator/Endpoints/OrderEndpoints.cs`)
- Order endpoint → Browser: allows dev CORS
- Browser → Order form: renders UI
