# liyunlong1228/api-encrypt-scaffold architecture

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

- Interactive diagram: https://gitdiagram.com/liyunlong1228/api-encrypt-scaffold
- Repository: https://github.com/liyunlong1228/api-encrypt-scaffold

## Overview

This is a TypeScript client-side API encryption library. Its main workflow is opt-in Axios request encryption: generate a fresh AES key, encrypt the request body with AES, and RSA-encrypt the key for a header; on responses, use the returned encrypted-key header to recover the AES key and decrypt the body. The README also documents direct use of the crypto helpers and configurable RSA keys. Relationships follow the sampled interceptor calls; server-side behavior is shown only as the documented external exchange.

Main entry points: [`src/interceptors/axios.ts`](https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/interceptors/axios.ts) (Axios interceptors), [`src/core/crypto.ts`](https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/core/crypto.ts) (AES helpers), [`src/index.ts`](https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/index.ts) (Library exports), [`src/core/jsencrypt.ts`](https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/core/jsencrypt.ts) (RSA helpers and config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Axios integration"]
  node_interceptor["Axios interceptors<br/>[axios.ts]"]
end

subgraph group_crypto["Cryptography core"]
  node_aes["AES helpers<br/>[crypto.ts]"]
  node_rsa["RSA helpers and config<br/>[jsencrypt.ts]"]
end

subgraph group_public["Public API"]
  node_api["Library exports<br/>[index.ts]"]
  node_types["Type definitions<br/>[index.ts]"]
end

node_consumer(("Application"))
node_api_server(("API server"))

node_consumer -->|"imports"| node_api
node_api -->|"exports setup"| node_interceptor
node_api -->|"exports helpers"| node_aes
node_api -->|"exports helpers"| node_rsa
node_api -->|"exports types"| node_types
node_consumer -->|"configures Axios"| node_interceptor
node_interceptor -->|"initializes keys"| node_rsa
node_interceptor -->|"generates key"| node_aes
node_interceptor -->|"encodes key"| node_aes
node_interceptor -->|"encrypts key"| node_rsa
node_interceptor -->|"encrypts body"| node_aes
node_interceptor -->|"sends body and key header"| node_api_server
node_api_server -->|"returns response and key header"| node_interceptor
node_interceptor -->|"decrypts response key"| node_rsa
node_interceptor -->|"decodes key"| node_aes
node_interceptor -->|"decrypts response body"| node_aes

click node_api "https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/index.ts"
click node_types "https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/types/index.ts"
click node_interceptor "https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/interceptors/axios.ts"
click node_aes "https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/core/crypto.ts"
click node_rsa "https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/core/jsencrypt.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_interceptor toneBlue
class node_aes,node_rsa toneAmber
class node_api,node_types,node_api_server toneMint
class node_consumer toneIndigo
```

## Components

### Axios integration

- [Axios interceptors](https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/interceptors/axios.ts): `src/interceptors/axios.ts`

### Cryptography core

- [AES helpers](https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/core/crypto.ts): `src/core/crypto.ts`
- [RSA helpers and config](https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/core/jsencrypt.ts): `src/core/jsencrypt.ts`

### Public API

- [Library exports](https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/index.ts): `src/index.ts`
- [Type definitions](https://github.com/liyunlong1228/api-encrypt-scaffold/blob/main/src/types/index.ts): `src/types/index.ts`

### Other components

- **Application**
- **API server**

## Connections

- Application → Library exports: imports
- Library exports → Axios interceptors: exports setup
- Library exports → AES helpers: exports helpers
- Library exports → RSA helpers and config: exports helpers
- Library exports → Type definitions: exports types
- Application → Axios interceptors: configures Axios
- Axios interceptors → RSA helpers and config: initializes keys
- Axios interceptors → AES helpers: generates key
- Axios interceptors → AES helpers: encodes key
- Axios interceptors → RSA helpers and config: encrypts key
- Axios interceptors → AES helpers: encrypts body
- Axios interceptors → API server: sends body and key header
- API server → Axios interceptors: returns response and key header
- Axios interceptors → RSA helpers and config: decrypts response key
- Axios interceptors → AES helpers: decodes key
- Axios interceptors → AES helpers: decrypts response body
