# loncadev/lonca architecture

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

- Interactive diagram: https://gitdiagram.com/loncadev/lonca
- Repository: https://github.com/loncadev/lonca

## Overview

Lonca is a TypeScript SDK suite for integrating with Turkish e-commerce marketplaces. The main workflow is an application creating a marketplace client, invoking a typed resource operation, and having that resource send an authenticated request through its transport to Trendyol or Hepsiburada. The SDKs also cover inbound webhook parsing and subscription management; shared core utilities provide request handling and common primitives. Resource coverage follows the README and source index, while some internal links are omitted where excerpts do not establish a call.

Main entry points: [`sdks/trendyol/src/transport.ts`](https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/transport.ts) (Trendyol transport), [`sdks/hepsiburada/src/transport.ts`](https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/transport.ts) (Hepsiburada transport), [`sdks/hepsiburada/src/client.ts`](https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/client.ts) (Hepsiburada client), [`sdks/trendyol/src/client.ts`](https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/client.ts) (Trendyol client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Shared core"]
  node_coretransport["Request engine<br/>[transport.ts]"]
  node_coreerrors["Errors and retry<br/>[errors.ts]"]
  node_coreprimitives["Shared primitives"]
end

subgraph group_trendyol["Trendyol SDK"]
  node_tyclient["Trendyol client<br/>[client.ts]"]
  node_tyresources["Marketplace resources"]
  node_tyorders["Order operations<br/>[orders.ts]"]
  node_tywebhooks["Webhook subscriptions<br/>[webhooks.ts]"]
  node_tytransport["Trendyol transport<br/>[transport.ts]"]
end

subgraph group_hepsi["Hepsiburada SDK"]
  node_hbclient["Hepsiburada client<br/>[client.ts]"]
  node_hbcatalog["Catalog and listings<br/>[catalog.ts]"]
  node_hborders["Order operations<br/>[orders.ts]"]
  node_hbresources["Other resources"]
  node_hbtypes["Domain types"]
  node_hbtransport["Hepsiburada transport<br/>[transport.ts]"]
end

subgraph group_webhooks["Webhook handling"]
  node_hbparser["Event parser"]
  node_tyeventtypes["Event payload types<br/>[webhook-event.ts]"]
end

node_app(("Integrating app"))
node_trendyolapi{{"Trendyol API"}}
node_hepsiburadaapi{{"Hepsiburada API"}}
node_webhookreceiver(("Merchant webhook endpoint"))

node_app -->|"creates client"| node_tyclient
node_app -->|"creates client"| node_hbclient
node_tyclient -->|"instantiates resources"| node_tyresources
node_tyclient -->|"configures transport"| node_tytransport
node_tyresources -.->|"sends requests"| node_tytransport
node_tyorders -->|"sends requests"| node_tytransport
node_tywebhooks -->|"sends requests"| node_tytransport
node_tytransport -.->|"calls API"| node_trendyolapi
node_hbclient -->|"instantiates resource"| node_hbcatalog
node_hbclient -->|"instantiates resource"| node_hborders
node_hbclient -->|"instantiates resources"| node_hbresources
node_hbclient -->|"configures transport"| node_hbtransport
node_hbcatalog -->|"sends requests"| node_hbtransport
node_hborders -->|"sends requests"| node_hbtransport
node_hbresources -.->|"sends requests"| node_hbtransport
node_hbtransport -.->|"calls API"| node_hepsiburadaapi
node_tytransport -.->|"uses request engine"| node_coretransport
node_hbtransport -->|"uses request engine"| node_coretransport
node_coretransport -->|"uses errors and retry"| node_coreerrors
node_app -->|"parses inbound event"| node_hbparser
node_webhookreceiver -->|"provides event body"| node_hbparser
node_tyeventtypes -.->|"types received payload"| node_webhookreceiver

click node_coretransport "https://github.com/loncadev/lonca/blob/main/packages/core/src/transport.ts"
click node_coreerrors "https://github.com/loncadev/lonca/blob/main/packages/core/src/errors.ts"
click node_coreprimitives "https://github.com/loncadev/lonca/tree/main/packages/core/src"
click node_tyclient "https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/client.ts"
click node_tyresources "https://github.com/loncadev/lonca/tree/main/sdks/trendyol/src/resources"
click node_tyorders "https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/resources/orders.ts"
click node_tywebhooks "https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/resources/webhooks.ts"
click node_tytransport "https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/transport.ts"
click node_hbclient "https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/client.ts"
click node_hbcatalog "https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/resources/catalog.ts"
click node_hborders "https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/resources/orders.ts"
click node_hbresources "https://github.com/loncadev/lonca/tree/main/sdks/hepsiburada/src/resources"
click node_hbtypes "https://github.com/loncadev/lonca/tree/main/sdks/hepsiburada/src/types"
click node_hbtransport "https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/transport.ts"
click node_hbparser "https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/parse-webhook-event.ts"
click node_tyeventtypes "https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/types/webhook-event.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_coretransport,node_coreerrors,node_coreprimitives toneBlue
class node_tyclient,node_tyresources,node_tyorders,node_tywebhooks,node_tytransport toneAmber
class node_hbclient,node_hbcatalog,node_hborders,node_hbresources,node_hbtypes,node_hbtransport,node_trendyolapi,node_hepsiburadaapi,node_webhookreceiver toneMint
class node_hbparser,node_tyeventtypes toneRose
class node_app toneIndigo
```

## Components

### Shared core

- [Request engine](https://github.com/loncadev/lonca/blob/main/packages/core/src/transport.ts): `packages/core/src/transport.ts`
- [Errors and retry](https://github.com/loncadev/lonca/blob/main/packages/core/src/errors.ts): `packages/core/src/errors.ts`
- [Shared primitives](https://github.com/loncadev/lonca/tree/main/packages/core/src): `packages/core/src`

### Trendyol SDK

- [Trendyol client](https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/client.ts): `sdks/trendyol/src/client.ts`
- [Marketplace resources](https://github.com/loncadev/lonca/tree/main/sdks/trendyol/src/resources): `sdks/trendyol/src/resources`
- [Order operations](https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/resources/orders.ts): `sdks/trendyol/src/resources/orders.ts`
- [Webhook subscriptions](https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/resources/webhooks.ts): `sdks/trendyol/src/resources/webhooks.ts`
- [Trendyol transport](https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/transport.ts): `sdks/trendyol/src/transport.ts`

### Hepsiburada SDK

- [Hepsiburada client](https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/client.ts): `sdks/hepsiburada/src/client.ts`
- [Catalog and listings](https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/resources/catalog.ts): `sdks/hepsiburada/src/resources/catalog.ts`
- [Order operations](https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/resources/orders.ts): `sdks/hepsiburada/src/resources/orders.ts`
- [Other resources](https://github.com/loncadev/lonca/tree/main/sdks/hepsiburada/src/resources): `sdks/hepsiburada/src/resources`
- [Domain types](https://github.com/loncadev/lonca/tree/main/sdks/hepsiburada/src/types): `sdks/hepsiburada/src/types`
- [Hepsiburada transport](https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/transport.ts): `sdks/hepsiburada/src/transport.ts`

### Webhook handling

- [Event parser](https://github.com/loncadev/lonca/blob/main/sdks/hepsiburada/src/parse-webhook-event.ts): `sdks/hepsiburada/src/parse-webhook-event.ts`
- [Event payload types](https://github.com/loncadev/lonca/blob/main/sdks/trendyol/src/types/webhook-event.ts): `sdks/trendyol/src/types/webhook-event.ts`

### Other components

- **Integrating app**
- **Trendyol API**
- **Hepsiburada API**
- **Merchant webhook endpoint**

## Connections

- Integrating app → Trendyol client: creates client
- Integrating app → Hepsiburada client: creates client
- Trendyol client → Marketplace resources: instantiates resources (evidence: `sdks/trendyol/src/client.ts`)
- Trendyol client → Trendyol transport: configures transport (evidence: `sdks/trendyol/src/client.ts`)
- Marketplace resources → Trendyol transport: sends requests (evidence: `sdks/trendyol/src/resources/webhooks.ts`)
- Order operations → Trendyol transport: sends requests (evidence: `sdks/trendyol/src/resources/orders.ts`)
- Webhook subscriptions → Trendyol transport: sends requests (evidence: `sdks/trendyol/src/resources/webhooks.ts`)
- Trendyol transport → Trendyol API: calls API
- Hepsiburada client → Catalog and listings: instantiates resource (evidence: `sdks/hepsiburada/src/client.ts`)
- Hepsiburada client → Order operations: instantiates resource (evidence: `sdks/hepsiburada/src/client.ts`)
- Hepsiburada client → Other resources: instantiates resources (evidence: `sdks/hepsiburada/src/client.ts`)
- Hepsiburada client → Hepsiburada transport: configures transport (evidence: `sdks/hepsiburada/src/client.ts`)
- Catalog and listings → Hepsiburada transport: sends requests (evidence: `sdks/hepsiburada/src/resources/catalog.ts`)
- Order operations → Hepsiburada transport: sends requests (evidence: `sdks/hepsiburada/src/resources/orders.ts`)
- Other resources → Hepsiburada transport: sends requests (evidence: `sdks/hepsiburada/src/resources/orders.ts`)
- Hepsiburada transport → Hepsiburada API: calls API
- Trendyol transport → Request engine: uses request engine
- Hepsiburada transport → Request engine: uses request engine (evidence: `sdks/hepsiburada/src/transport.ts`)
- Request engine → Errors and retry: uses errors and retry (evidence: `packages/core/src/transport.ts`)
- Integrating app → Event parser: parses inbound event (evidence: `sdks/hepsiburada/src/parse-webhook-event.ts`)
- Merchant webhook endpoint → Event parser: provides event body (evidence: `sdks/hepsiburada/src/parse-webhook-event.ts`)
- Event payload types → Merchant webhook endpoint: types received payload
