# choichoi3227-crypto/cloud-press architecture

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

- Interactive diagram: https://gitdiagram.com/choichoi3227-crypto/cloud-press
- Repository: https://github.com/choichoi3227-crypto/cloud-press

## Overview

The repository contains two independently deployed products: a root-level search, research, and AI-image API, and an AI-model platform exposed through a Cloudflare gateway and inference server, with WordPress-facing account and deployment plugins. The main workflows run from API request through routing and domain processing to results; model text requests additionally fetch research context before inference. Training code is represented as a separate model-development stage. Edges cite README statements or shown source/index references; unsampled details are not inferred.

Main entry points: [`ai-models/workers/api-gateway/src/index.ts`](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/index.ts) (API gateway), [`ai-models/inference-server/main.py`](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/main.py) (Inference server), [`research-handler.js`](https://github.com/choichoi3227-crypto/cloud-press/blob/main/research-handler.js) (Research handler), [`worker-search.js`](https://github.com/choichoi3227-crypto/cloud-press/blob/main/worker-search.js) (Worker router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_search["Search and image API"]
  node_search_worker["Worker router<br/>[worker-search.js]"]
  node_search_functions["Pages endpoints<br/>[search.js]"]
  node_research_function["Research endpoint<br/>[research.js]"]
  node_search_core["Search scraping<br/>[search-core.js]"]
  node_research_handler["Research handler"]
  node_research_core["Research synthesis<br/>[research-core.js]"]
  node_image_core["Image art director<br/>[image-core.js]"]
  node_image_styles["Image style briefs<br/>[image-styles.js]"]
  node_svg_audit["SVG audit<br/>[svg-audit.js]"]
end

subgraph group_gateway["Model API gateway"]
  node_gateway_worker["API gateway<br/>[index.ts]"]
  node_gateway_text["Text route<br/>[text.ts]"]
  node_gateway_image["Image route<br/>[image.ts]"]
  node_gateway_auth["API key auth<br/>[auth.ts]"]
  node_gateway_rate["Rate limiting<br/>[rateLimit.ts]"]
  node_inference_client["Inference client<br/>[inferenceClient.ts]"]
end

subgraph group_inference["Inference serving"]
  node_inference_server["Inference server<br/>[main.py]"]
  node_inference_text["Text generation<br/>[text.py]"]
  node_inference_image["Image generation<br/>[image.py]"]
  node_flash_model["Flash Texter<br/>[flash_texter.py]"]
  node_nano_model["Nano-Tech Artist"]
  node_search_augment["Search augmentation<br/>[search_augment.py]"]
end

subgraph group_training["Model training"]
  node_flash_training["Flash Texter training<br/>[train.py]"]
  node_flash_model_def["Text model definition<br/>[model.py]"]
  node_flash_tokenizer["Text tokenizer<br/>[tokenizer.py]"]
  node_nano_training["Artist training<br/>[train.py]"]
end

subgraph group_wordpress["WordPress experience"]
  node_wp_connector["Account connector"]
  node_wp_auth["Account access<br/>[class-cp-auth.php]"]
  node_wp_deploy["Deploy approvals"]
  node_wp_theme["Site theme<br/>[functions.php]"]
end

node_api_client(("API caller"))
node_search_engines{{"Google and Naver"}}
node_workers_ai{{"Workers AI"}}
node_wp_user(("Site user"))

node_api_client -->|"requests API"| node_search_worker
node_search_worker -->|"routes search"| node_search_core
node_search_worker -->|"routes research"| node_research_handler
node_search_worker -->|"routes image"| node_image_core
node_search_functions -->|"uses search"| node_search_core
node_research_function -->|"handles research"| node_research_handler
node_research_handler -->|"fetches results"| node_search_core
node_research_handler -->|"builds research"| node_research_core
node_search_core -->|"scrapes results"| node_search_engines
node_research_core -.->|"optionally enhances"| node_workers_ai
node_image_core -->|"uses style briefs"| node_image_styles
node_image_core -->|"audits output"| node_svg_audit
node_image_core -->|"generates artwork"| node_workers_ai
node_api_client -->|"calls model API"| node_gateway_worker
node_gateway_worker -->|"routes text"| node_gateway_text
node_gateway_worker -->|"routes image"| node_gateway_image
node_gateway_worker -->|"enforces API keys"| node_gateway_auth
node_gateway_worker -->|"limits model routes"| node_gateway_rate
node_gateway_text -->|"calls inference"| node_inference_client
node_gateway_image -.->|"calls inference"| node_inference_client
node_inference_client -->|"proxies requests"| node_inference_server
node_inference_server -->|"mounts router"| node_inference_text
node_inference_server -->|"mounts router"| node_inference_image
node_inference_server -->|"loads model"| node_flash_model
node_inference_server -->|"loads model"| node_nano_model
node_inference_text -->|"fetches context"| node_search_augment
node_inference_text -->|"generates response"| node_flash_model
node_search_augment -->|"requests research"| node_research_handler
node_inference_image -->|"generates image"| node_nano_model
node_flash_training -->|"trains model"| node_flash_model_def
node_flash_training -->|"uses tokenizer"| node_flash_tokenizer
node_nano_training -->|"imports model module"| node_flash_model_def
node_wp_user -->|"uses account site"| node_wp_connector
node_wp_connector -.->|"provides authentication"| node_wp_auth
node_wp_connector -->|"requests API keys"| node_gateway_worker
node_wp_user -->|"views site"| node_wp_theme
node_wp_deploy -->|"uses deploy proxy"| node_gateway_worker

click node_search_worker "https://github.com/choichoi3227-crypto/cloud-press/blob/main/worker-search.js"
click node_search_functions "https://github.com/choichoi3227-crypto/cloud-press/blob/main/functions/api/search.js"
click node_research_function "https://github.com/choichoi3227-crypto/cloud-press/blob/main/functions/api/research.js"
click node_search_core "https://github.com/choichoi3227-crypto/cloud-press/blob/main/search-core.js"
click node_research_handler "https://github.com/choichoi3227-crypto/cloud-press/blob/main/research-handler.js"
click node_research_core "https://github.com/choichoi3227-crypto/cloud-press/blob/main/research-core.js"
click node_image_core "https://github.com/choichoi3227-crypto/cloud-press/blob/main/image-core.js"
click node_image_styles "https://github.com/choichoi3227-crypto/cloud-press/blob/main/image-styles.js"
click node_svg_audit "https://github.com/choichoi3227-crypto/cloud-press/blob/main/svg-audit.js"
click node_gateway_worker "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/index.ts"
click node_gateway_text "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/routes/text.ts"
click node_gateway_image "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/routes/image.ts"
click node_gateway_auth "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/middleware/auth.ts"
click node_gateway_rate "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/middleware/rateLimit.ts"
click node_inference_client "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/lib/inferenceClient.ts"
click node_inference_server "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/main.py"
click node_inference_text "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/routers/text.py"
click node_inference_image "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/routers/image.py"
click node_flash_model "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/models/flash_texter.py"
click node_nano_model "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/models/nano_tech_artist.py"
click node_search_augment "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/models/search_augment.py"
click node_flash_training "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/training/flash-texter/train.py"
click node_flash_model_def "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/training/flash-texter/model.py"
click node_flash_tokenizer "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/training/flash-texter/tokenizer.py"
click node_nano_training "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/training/nano-tech-artist/train.py"
click node_wp_connector "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/wordpress/cloud-press-connector/cloud-press-connector.php"
click node_wp_auth "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/wordpress/cloud-press-connector/includes/class-cp-auth.php"
click node_wp_deploy "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/wordpress/cloud-press-deploy/includes/class-cp-deploy-approval.php"
click node_wp_theme "https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/wordpress/cloud-press-theme/functions.php"

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_search_worker,node_search_functions,node_research_function,node_search_core,node_research_handler,node_research_core,node_image_core,node_image_styles,node_svg_audit,node_wp_user toneBlue
class node_gateway_worker,node_gateway_text,node_gateway_image,node_gateway_auth,node_gateway_rate,node_inference_client toneAmber
class node_inference_server,node_inference_text,node_inference_image,node_flash_model,node_nano_model,node_search_augment,node_api_client toneMint
class node_flash_training,node_flash_model_def,node_flash_tokenizer,node_nano_training,node_workers_ai toneRose
class node_wp_connector,node_wp_auth,node_wp_deploy,node_wp_theme,node_search_engines toneIndigo
```

## Components

### Search and image API

- [Worker router](https://github.com/choichoi3227-crypto/cloud-press/blob/main/worker-search.js): `worker-search.js`
- [Pages endpoints](https://github.com/choichoi3227-crypto/cloud-press/blob/main/functions/api/search.js): `functions/api/search.js`
- [Research endpoint](https://github.com/choichoi3227-crypto/cloud-press/blob/main/functions/api/research.js): `functions/api/research.js`
- [Search scraping](https://github.com/choichoi3227-crypto/cloud-press/blob/main/search-core.js): `search-core.js`
- [Research handler](https://github.com/choichoi3227-crypto/cloud-press/blob/main/research-handler.js): `research-handler.js`
- [Research synthesis](https://github.com/choichoi3227-crypto/cloud-press/blob/main/research-core.js): `research-core.js`
- [Image art director](https://github.com/choichoi3227-crypto/cloud-press/blob/main/image-core.js): `image-core.js`
- [Image style briefs](https://github.com/choichoi3227-crypto/cloud-press/blob/main/image-styles.js): `image-styles.js`
- [SVG audit](https://github.com/choichoi3227-crypto/cloud-press/blob/main/svg-audit.js): `svg-audit.js`

### Model API gateway

- [API gateway](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/index.ts): `ai-models/workers/api-gateway/src/index.ts`
- [Text route](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/routes/text.ts): `ai-models/workers/api-gateway/src/routes/text.ts`
- [Image route](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/routes/image.ts): `ai-models/workers/api-gateway/src/routes/image.ts`
- [API key auth](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/middleware/auth.ts): `ai-models/workers/api-gateway/src/middleware/auth.ts`
- [Rate limiting](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/middleware/rateLimit.ts): `ai-models/workers/api-gateway/src/middleware/rateLimit.ts`
- [Inference client](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/workers/api-gateway/src/lib/inferenceClient.ts): `ai-models/workers/api-gateway/src/lib/inferenceClient.ts`

### Inference serving

- [Inference server](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/main.py): `ai-models/inference-server/main.py`
- [Text generation](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/routers/text.py): `ai-models/inference-server/routers/text.py`
- [Image generation](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/routers/image.py): `ai-models/inference-server/routers/image.py`
- [Flash Texter](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/models/flash_texter.py): `ai-models/inference-server/models/flash_texter.py`
- [Nano-Tech Artist](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/models/nano_tech_artist.py): `ai-models/inference-server/models/nano_tech_artist.py`
- [Search augmentation](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/inference-server/models/search_augment.py): `ai-models/inference-server/models/search_augment.py`

### Model training

- [Flash Texter training](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/training/flash-texter/train.py): `ai-models/training/flash-texter/train.py`
- [Text model definition](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/training/flash-texter/model.py): `ai-models/training/flash-texter/model.py`
- [Text tokenizer](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/training/flash-texter/tokenizer.py): `ai-models/training/flash-texter/tokenizer.py`
- [Artist training](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/training/nano-tech-artist/train.py): `ai-models/training/nano-tech-artist/train.py`

### WordPress experience

- [Account connector](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/wordpress/cloud-press-connector/cloud-press-connector.php): `ai-models/wordpress/cloud-press-connector/cloud-press-connector.php`
- [Account access](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/wordpress/cloud-press-connector/includes/class-cp-auth.php): `ai-models/wordpress/cloud-press-connector/includes/class-cp-auth.php`
- [Deploy approvals](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/wordpress/cloud-press-deploy/includes/class-cp-deploy-approval.php): `ai-models/wordpress/cloud-press-deploy/includes/class-cp-deploy-approval.php`
- [Site theme](https://github.com/choichoi3227-crypto/cloud-press/blob/main/ai-models/wordpress/cloud-press-theme/functions.php): `ai-models/wordpress/cloud-press-theme/functions.php`

### Other components

- **API caller**
- **Google and Naver**
- **Workers AI**
- **Site user**

## Connections

- API caller → Worker router: requests API
- Worker router → Search scraping: routes search (evidence: `worker-search.js`)
- Worker router → Research handler: routes research (evidence: `worker-search.js`)
- Worker router → Image art director: routes image (evidence: `worker-search.js`)
- Pages endpoints → Search scraping: uses search (evidence: `functions/api/search.js`)
- Research endpoint → Research handler: handles research (evidence: `functions/api/research.js`)
- Research handler → Search scraping: fetches results (evidence: `research-handler.js`)
- Research handler → Research synthesis: builds research (evidence: `research-handler.js`)
- Search scraping → Google and Naver: scrapes results (evidence: `search-core.js`)
- Research synthesis → Workers AI: optionally enhances
- Image art director → Image style briefs: uses style briefs
- Image art director → SVG audit: audits output
- Image art director → Workers AI: generates artwork
- API caller → API gateway: calls model API
- API gateway → Text route: routes text (evidence: `ai-models/workers/api-gateway/src/index.ts`)
- API gateway → Image route: routes image (evidence: `ai-models/workers/api-gateway/src/index.ts`)
- API gateway → API key auth: enforces API keys (evidence: `ai-models/workers/api-gateway/src/index.ts`)
- API gateway → Rate limiting: limits model routes (evidence: `ai-models/workers/api-gateway/src/index.ts`)
- Text route → Inference client: calls inference (evidence: `ai-models/workers/api-gateway/src/routes/text.ts`)
- Image route → Inference client: calls inference
- Inference client → Inference server: proxies requests (evidence: `ai-models/workers/api-gateway/src/lib/inferenceClient.ts`)
- Inference server → Text generation: mounts router (evidence: `ai-models/inference-server/main.py`)
- Inference server → Image generation: mounts router (evidence: `ai-models/inference-server/main.py`)
- Inference server → Flash Texter: loads model (evidence: `ai-models/inference-server/main.py`)
- Inference server → Nano-Tech Artist: loads model (evidence: `ai-models/inference-server/main.py`)
- Text generation → Search augmentation: fetches context (evidence: `ai-models/inference-server/routers/text.py`)
- Text generation → Flash Texter: generates response (evidence: `ai-models/inference-server/routers/text.py`)
- Search augmentation → Research handler: requests research (evidence: `ai-models/inference-server/models/search_augment.py`)
- Image generation → Nano-Tech Artist: generates image (evidence: `ai-models/inference-server/routers/image.py`)
- Flash Texter training → Text model definition: trains model
- Flash Texter training → Text tokenizer: uses tokenizer
- Artist training → Text model definition: imports model module (evidence: `ai-models/training/nano-tech-artist/train.py`)
- Site user → Account connector: uses account site
- Account connector → Account access: provides authentication
- Account connector → API gateway: requests API keys
- Site user → Site theme: views site
- Deploy approvals → API gateway: uses deploy proxy
