# mellonelay/nexi architecture

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

- Interactive diagram: https://gitdiagram.com/mellonelay/nexi
- Repository: https://github.com/mellonelay/nexi

## Overview

NEXI is a trading and financial-services platform with public, backend, and admin surfaces. The public workflow covers account access and trading experiences; backend services provide authentication, market data, and financial operations, while the admin surface supports operational controls. Market ingestion and historical recovery are distinct from client-facing market queries. The graph emphasizes relationships evidenced by the provided excerpts and source index; where frontend-to-backend HTTP wiring or unsampled domain flows are not shown, links are omitted or marked unverified.

Main entry points: [`backend/src/market/market-provider-router.service.ts`](https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-provider-router.service.ts) (Provider routing), [`backend/src/d1/d1-prisma.service.ts`](https://github.com/mellonelay/nexi/blob/main/backend/src/d1/d1-prisma.service.ts) (D1 persistence), [`backend/src/market/market-kline.service.ts`](https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-kline.service.ts) (Kline storage), [`frontend/app/lib/api.ts`](https://github.com/mellonelay/nexi/blob/main/frontend/app/lib/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public experience"]
  node_trading["Spot trading<br/>[SpotPageClient.tsx]"]
  node_binary["Binary trading"]
  node_marketclient["Market client data<br/>[market-data.ts]"]
  node_publicapi["API client<br/>[api.ts]"]
end

subgraph group_admin["Admin operations"]
  node_adminui["Admin console"]
  node_adminroutes["Admin API"]
  node_adminservice["Admin controls<br/>[admin.service.ts]"]
end

subgraph group_identity["Identity and API"]
  node_authapi["Auth endpoints<br/>[auth.controller.ts]"]
  node_authservice["Authentication<br/>[auth.service.ts]"]
  node_surfaceguard["Surface authorization"]
  node_users["User profiles<br/>[users.service.ts]"]
  node_database[("D1 persistence")]
end

subgraph group_market["Market data"]
  node_marketapi["Market endpoints"]
  node_providerrouter["Provider routing"]
  node_marketingest["Market ingestion"]
  node_klines["Kline storage"]
  node_sourcepolicy["Source registry"]
end

subgraph group_finance["Financial services"]
  node_financialapi["Financial operations API"]
  node_financialservice["Financial operations"]
end

node_customer(("Customer"))

node_customer -.->|"uses"| node_trading
node_customer -.->|"uses"| node_binary
node_trading -->|"calls"| node_publicapi
node_binary -->|"calls"| node_publicapi
node_marketclient -->|"uses"| node_publicapi
node_adminui -.->|"calls"| node_adminroutes
node_adminroutes -->|"delegates"| node_adminservice
node_authapi -->|"delegates"| node_authservice
node_authapi -->|"guards"| node_surfaceguard
node_authservice -->|"uses"| node_users
node_marketapi -->|"queries"| node_klines
node_marketapi -->|"recovers history"| node_providerrouter
node_providerrouter -->|"loads policy"| node_sourcepolicy
node_providerrouter -->|"reads"| node_database
node_marketingest -->|"receives provider events"| node_providerrouter
node_marketingest -->|"persists candles"| node_klines
node_klines -->|"reads and writes"| node_database
node_financialapi -->|"delegates"| node_financialservice
node_adminservice -.->|"uses"| node_database
node_financialservice -.->|"uses"| node_database

click node_trading "https://github.com/mellonelay/nexi/blob/main/frontend/app/dashboard/spot/SpotPageClient.tsx"
click node_binary "https://github.com/mellonelay/nexi/blob/main/frontend/app/dashboard/binary/BinaryPageClient.tsx"
click node_marketclient "https://github.com/mellonelay/nexi/blob/main/frontend/app/lib/market-data.ts"
click node_publicapi "https://github.com/mellonelay/nexi/blob/main/frontend/app/lib/api.ts"
click node_adminui "https://github.com/mellonelay/nexi/tree/main/Admin/src/routes"
click node_adminroutes "https://github.com/mellonelay/nexi/blob/main/backend/src/admin/admin.controller.ts"
click node_adminservice "https://github.com/mellonelay/nexi/blob/main/backend/src/admin/admin.service.ts"
click node_authapi "https://github.com/mellonelay/nexi/blob/main/backend/src/auth/auth.controller.ts"
click node_authservice "https://github.com/mellonelay/nexi/blob/main/backend/src/auth/auth.service.ts"
click node_surfaceguard "https://github.com/mellonelay/nexi/blob/main/backend/src/auth/auth-surface.guard.ts"
click node_users "https://github.com/mellonelay/nexi/blob/main/backend/src/users/users.service.ts"
click node_database "https://github.com/mellonelay/nexi/blob/main/backend/src/d1/d1-prisma.service.ts"
click node_marketapi "https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-kline-query.service.ts"
click node_providerrouter "https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-provider-router.service.ts"
click node_marketingest "https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-ingest.service.ts"
click node_klines "https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-kline.service.ts"
click node_sourcepolicy "https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-source-registry.ts"
click node_financialapi "https://github.com/mellonelay/nexi/blob/main/backend/src/financial/financial-operations.controller.ts"
click node_financialservice "https://github.com/mellonelay/nexi/blob/main/backend/src/financial/financial-operations.service.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_trading,node_binary,node_marketclient,node_publicapi toneBlue
class node_adminui,node_adminroutes,node_adminservice toneAmber
class node_authapi,node_authservice,node_surfaceguard,node_users,node_database toneMint
class node_marketapi,node_providerrouter,node_marketingest,node_klines,node_sourcepolicy toneRose
class node_financialapi,node_financialservice,node_customer toneIndigo
```

## Components

### Public experience

- [Spot trading](https://github.com/mellonelay/nexi/blob/main/frontend/app/dashboard/spot/SpotPageClient.tsx): `frontend/app/dashboard/spot/SpotPageClient.tsx`
- [Binary trading](https://github.com/mellonelay/nexi/blob/main/frontend/app/dashboard/binary/BinaryPageClient.tsx): `frontend/app/dashboard/binary/BinaryPageClient.tsx`
- [Market client data](https://github.com/mellonelay/nexi/blob/main/frontend/app/lib/market-data.ts): `frontend/app/lib/market-data.ts`
- [API client](https://github.com/mellonelay/nexi/blob/main/frontend/app/lib/api.ts): `frontend/app/lib/api.ts`

### Admin operations

- [Admin console](https://github.com/mellonelay/nexi/tree/main/Admin/src/routes): `Admin/src/routes`
- [Admin API](https://github.com/mellonelay/nexi/blob/main/backend/src/admin/admin.controller.ts): `backend/src/admin/admin.controller.ts`
- [Admin controls](https://github.com/mellonelay/nexi/blob/main/backend/src/admin/admin.service.ts): `backend/src/admin/admin.service.ts`

### Identity and API

- [Auth endpoints](https://github.com/mellonelay/nexi/blob/main/backend/src/auth/auth.controller.ts): `backend/src/auth/auth.controller.ts`
- [Authentication](https://github.com/mellonelay/nexi/blob/main/backend/src/auth/auth.service.ts): `backend/src/auth/auth.service.ts`
- [Surface authorization](https://github.com/mellonelay/nexi/blob/main/backend/src/auth/auth-surface.guard.ts): `backend/src/auth/auth-surface.guard.ts`
- [User profiles](https://github.com/mellonelay/nexi/blob/main/backend/src/users/users.service.ts): `backend/src/users/users.service.ts`
- [D1 persistence](https://github.com/mellonelay/nexi/blob/main/backend/src/d1/d1-prisma.service.ts): `backend/src/d1/d1-prisma.service.ts`

### Market data

- [Market endpoints](https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-kline-query.service.ts): `backend/src/market/market-kline-query.service.ts`
- [Provider routing](https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-provider-router.service.ts): `backend/src/market/market-provider-router.service.ts`
- [Market ingestion](https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-ingest.service.ts): `backend/src/market/market-ingest.service.ts`
- [Kline storage](https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-kline.service.ts): `backend/src/market/market-kline.service.ts`
- [Source registry](https://github.com/mellonelay/nexi/blob/main/backend/src/market/market-source-registry.ts): `backend/src/market/market-source-registry.ts`

### Financial services

- [Financial operations API](https://github.com/mellonelay/nexi/blob/main/backend/src/financial/financial-operations.controller.ts): `backend/src/financial/financial-operations.controller.ts`
- [Financial operations](https://github.com/mellonelay/nexi/blob/main/backend/src/financial/financial-operations.service.ts): `backend/src/financial/financial-operations.service.ts`

### Other components

- **Customer**

## Connections

- Customer → Spot trading: uses
- Customer → Binary trading: uses
- Spot trading → API client: calls (evidence: `frontend/app/dashboard/spot/SpotPageClient.tsx`)
- Binary trading → API client: calls (evidence: `frontend/app/dashboard/binary/BinaryPageClient.tsx`)
- Market client data → API client: uses (evidence: `frontend/app/hooks/useRealtimeMarket.ts`)
- Admin console → Admin API: calls
- Admin API → Admin controls: delegates (evidence: `backend/src/admin/admin.controller.ts`)
- Auth endpoints → Authentication: delegates (evidence: `backend/src/auth/auth.controller.ts`)
- Auth endpoints → Surface authorization: guards (evidence: `backend/src/auth/auth.controller.ts`)
- Authentication → User profiles: uses (evidence: `backend/src/auth/auth.service.ts`)
- Market endpoints → Kline storage: queries (evidence: `backend/src/market/market-kline-query.service.ts`)
- Market endpoints → Provider routing: recovers history (evidence: `backend/src/market/market-kline-query.service.ts`)
- Provider routing → Source registry: loads policy (evidence: `backend/src/market/market-provider-router.service.ts`)
- Provider routing → D1 persistence: reads (evidence: `backend/src/market/market-provider-router.service.ts`)
- Market ingestion → Provider routing: receives provider events (evidence: `backend/src/market/market-ingest.service.ts`)
- Market ingestion → Kline storage: persists candles (evidence: `backend/src/market/market-ingest.service.ts`)
- Kline storage → D1 persistence: reads and writes (evidence: `backend/src/market/market-kline.service.ts`)
- Financial operations API → Financial operations: delegates (evidence: `backend/src/financial/financial-operations.controller.ts`)
- Admin controls → D1 persistence: uses
- Financial operations → D1 persistence: uses
