# bob6664569/loyverse architecture

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

- Interactive diagram: https://gitdiagram.com/bob6664569/loyverse
- Repository: https://github.com/bob6664569/loyverse

## Overview

Loyverse API Client is a Node.js/TypeScript wrapper around the Loyverse REST API. A consumer creates a token-authenticated client, calls a resource method (or bulkOperation), and receives API data or a structured error; listAll paginates through the shared resource layer. The sampled code shows categories, customers, inventory, and items, plus retry handling and resource models. The README documents additional resources, but their implementations are not shown, so they are not mapped as verified client components.

Main entry points: [`src/client.ts`](https://github.com/bob6664569/loyverse/blob/main/src/client.ts) (Loyverse Client), [`src/resources/base.ts`](https://github.com/bob6664569/loyverse/blob/main/src/resources/base.ts) (Resource Base), [`src/resources/categories.ts`](https://github.com/bob6664569/loyverse/blob/main/src/resources/categories.ts) (Categories), [`src/resources/customers.ts`](https://github.com/bob6664569/loyverse/blob/main/src/resources/customers.ts) (Customers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Client API"]
  node_client["Loyverse Client<br/>[client.ts]"]
  node_public_entry["Package Entry<br/>[index.ts]"]
end

subgraph group_resources["Resource Operations"]
  node_categories["Categories<br/>[categories.ts]"]
  node_customers["Customers<br/>[customers.ts]"]
  node_inventory["Inventory<br/>[inventory.ts]"]
  node_items["Items<br/>[items.ts]"]
  node_resource_base["Resource Base<br/>[base.ts]"]
end

subgraph group_transport["HTTP Transport"]
  node_retry_config["Retry Config<br/>[retry.ts]"]
end

subgraph group_models["Types And Errors"]
  node_error_model["API Error<br/>[index.ts]"]
  node_resource_types["Resource Models<br/>[resources.ts]"]
  node_category_types["Category Models<br/>[categories.ts]"]
  node_shared_types["Request Types<br/>[index.ts]"]
end

node_consumer(("SDK Consumer"))
node_loyverse_api{{"Loyverse REST API"}}

node_consumer -->|"imports"| node_public_entry
node_consumer -->|"creates and uses"| node_client
node_client -->|"constructs"| node_categories
node_client -->|"constructs"| node_customers
node_client -->|"constructs"| node_inventory
node_client -->|"constructs"| node_items
node_categories -->|"extends"| node_resource_base
node_customers -->|"extends"| node_resource_base
node_inventory -->|"extends"| node_resource_base
node_items -->|"extends"| node_resource_base
node_resource_base -->|"sends requests"| node_client
node_client -->|"sends HTTP requests"| node_loyverse_api
node_client -->|"gets retry delays"| node_retry_config
node_client -->|"throws"| node_error_model
node_items -->|"uses models"| node_resource_types
node_customers -->|"uses models"| node_resource_types
node_inventory -->|"uses models"| node_resource_types
node_categories -->|"uses models"| node_category_types
node_resource_base -->|"uses request types"| node_shared_types

click node_client "https://github.com/bob6664569/loyverse/blob/main/src/client.ts"
click node_public_entry "https://github.com/bob6664569/loyverse/blob/main/src/index.ts"
click node_categories "https://github.com/bob6664569/loyverse/blob/main/src/resources/categories.ts"
click node_customers "https://github.com/bob6664569/loyverse/blob/main/src/resources/customers.ts"
click node_inventory "https://github.com/bob6664569/loyverse/blob/main/src/resources/inventory.ts"
click node_items "https://github.com/bob6664569/loyverse/blob/main/src/resources/items.ts"
click node_resource_base "https://github.com/bob6664569/loyverse/blob/main/src/resources/base.ts"
click node_retry_config "https://github.com/bob6664569/loyverse/blob/main/src/config/retry.ts"
click node_error_model "https://github.com/bob6664569/loyverse/blob/main/src/errors/index.ts"
click node_resource_types "https://github.com/bob6664569/loyverse/blob/main/src/types/resources.ts"
click node_category_types "https://github.com/bob6664569/loyverse/blob/main/src/types/categories.ts"
click node_shared_types "https://github.com/bob6664569/loyverse/blob/main/src/types/index.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_client,node_public_entry toneBlue
class node_categories,node_customers,node_inventory,node_items,node_resource_base toneAmber
class node_retry_config,node_loyverse_api toneMint
class node_error_model,node_resource_types,node_category_types,node_shared_types toneRose
class node_consumer toneIndigo
```

## Components

### Client API

- [Loyverse Client](https://github.com/bob6664569/loyverse/blob/main/src/client.ts): `src/client.ts`
- [Package Entry](https://github.com/bob6664569/loyverse/blob/main/src/index.ts): `src/index.ts`

### Resource Operations

- [Categories](https://github.com/bob6664569/loyverse/blob/main/src/resources/categories.ts): `src/resources/categories.ts`
- [Customers](https://github.com/bob6664569/loyverse/blob/main/src/resources/customers.ts): `src/resources/customers.ts`
- [Inventory](https://github.com/bob6664569/loyverse/blob/main/src/resources/inventory.ts): `src/resources/inventory.ts`
- [Items](https://github.com/bob6664569/loyverse/blob/main/src/resources/items.ts): `src/resources/items.ts`
- [Resource Base](https://github.com/bob6664569/loyverse/blob/main/src/resources/base.ts): `src/resources/base.ts`

### HTTP Transport

- [Retry Config](https://github.com/bob6664569/loyverse/blob/main/src/config/retry.ts): `src/config/retry.ts`

### Types And Errors

- [API Error](https://github.com/bob6664569/loyverse/blob/main/src/errors/index.ts): `src/errors/index.ts`
- [Resource Models](https://github.com/bob6664569/loyverse/blob/main/src/types/resources.ts): `src/types/resources.ts`
- [Category Models](https://github.com/bob6664569/loyverse/blob/main/src/types/categories.ts): `src/types/categories.ts`
- [Request Types](https://github.com/bob6664569/loyverse/blob/main/src/types/index.ts): `src/types/index.ts`

### Other components

- **SDK Consumer**
- **Loyverse REST API**

## Connections

- SDK Consumer → Package Entry: imports (evidence: `README.md`)
- SDK Consumer → Loyverse Client: creates and uses (evidence: `README.md`)
- Loyverse Client → Categories: constructs (evidence: `src/client.ts`)
- Loyverse Client → Customers: constructs (evidence: `src/client.ts`)
- Loyverse Client → Inventory: constructs (evidence: `src/client.ts`)
- Loyverse Client → Items: constructs (evidence: `src/client.ts`)
- Categories → Resource Base: extends (evidence: `src/resources/categories.ts`)
- Customers → Resource Base: extends (evidence: `src/resources/customers.ts`)
- Inventory → Resource Base: extends (evidence: `src/resources/inventory.ts`)
- Items → Resource Base: extends (evidence: `src/resources/items.ts`)
- Resource Base → Loyverse Client: sends requests (evidence: `src/resources/base.ts`)
- Loyverse Client → Loyverse REST API: sends HTTP requests (evidence: `src/client.ts`)
- Loyverse Client → Retry Config: gets retry delays (evidence: `src/client.ts`)
- Loyverse Client → API Error: throws (evidence: `src/client.ts`)
- Items → Resource Models: uses models (evidence: `src/resources/items.ts`)
- Customers → Resource Models: uses models (evidence: `src/resources/customers.ts`)
- Inventory → Resource Models: uses models (evidence: `src/resources/inventory.ts`)
- Categories → Category Models: uses models (evidence: `src/resources/categories.ts`)
- Resource Base → Request Types: uses request types (evidence: `src/resources/base.ts`)
