# jurjans/ksj-wp-func architecture

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

- Interactive diagram: https://gitdiagram.com/jurjans/ksj-wp-func
- Repository: https://github.com/jurjans/ksj-wp-func

## Overview

This is an Azure Functions service that turns SharePoint content-plan metadata into SEO articles and related marketing assets. The main workflow is SharePoint → Power Automate → article generation → WordPress tag resolution and result storage; Power Automate then retrieves results and publishes them. Separate branches generate monthly Latvian and English plans, Facebook copy, images, and SEO keywords. The graph combines README-documented routes and integrations with sampled source and SOURCE INDEX references; some route-to-module details and unsampled subsystems are therefore documented rather than independently verified in excerpts.

Main entry points: [`function_app.py`](https://github.com/jurjans/ksj-wp-func/blob/main/function_app.py) (HTTP endpoints), [`article_worker.py`](https://github.com/jurjans/ksj-wp-func/blob/main/article_worker.py) (Tick worker), [`storage.py`](https://github.com/jurjans/ksj-wp-func/blob/main/storage.py) (Storage helpers), [`article_gen.py`](https://github.com/jurjans/ksj-wp-func/blob/main/article_gen.py) (Latvian articles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and jobs"]
  node_function_app["HTTP endpoints<br/>[function_app.py]"]
  node_worker["Tick worker<br/>[article_worker.py]"]
end

subgraph group_articles["Article generation"]
  node_article_gen["Latvian articles<br/>[article_gen.py]"]
  node_en_article["English articles<br/>[en_article_gen.py]"]
end

subgraph group_content["Content tools"]
  node_content_plan["Latvian content plans<br/>[content_plan.py]"]
  node_content_plan_en["English content plans<br/>[content_plan_en.py]"]
  node_fb_gen["Facebook copy<br/>[fb_gen.py]"]
  node_image_gen["Social images<br/>[image_gen.py]"]
  node_keyword["SEO keywords<br/>[article_gen.py]"]
end

subgraph group_infra["Integrations and state"]
  node_wp["WordPress REST"]
  node_polylang["Polylang language API"]
  node_storage["Storage helpers<br/>[storage.py]"]
  node_blob[("Azure Blob Storage")]
  node_table[("Azure Table Storage")]
  node_queue["Azure Queue Storage"]
  node_ai["OpenAI / Azure OpenAI"]
  node_redis[("Redis cache")]
  node_serp["SerpApi"]
end

node_sharepoint(("SharePoint plan"))
node_power_automate(("Power Automate"))

node_sharepoint -->|"supplies metadata"| node_power_automate
node_power_automate -->|"calls endpoints"| node_function_app
node_function_app -->|"advances jobs"| node_worker
node_function_app -->|"generates articles"| node_article_gen
node_worker -->|"generates LV article"| node_article_gen
node_worker -->|"generates EN article"| node_en_article
node_article_gen -->|"requests text"| node_ai
node_en_article -->|"requests text"| node_ai
node_worker -->|"resolves tag IDs"| node_wp
node_worker -->|"persists job state"| node_storage
node_storage -->|"reads and writes"| node_blob
node_storage -->|"tracks status"| node_table
node_storage -.->|"enqueues jobs"| node_queue
node_power_automate -->|"downloads results"| node_blob
node_power_automate -->|"publishes articles"| node_wp
node_function_app -->|"generates LV plan"| node_content_plan
node_function_app -->|"generates EN plan"| node_content_plan_en
node_function_app -->|"generates copy"| node_fb_gen
node_function_app -->|"generates images"| node_image_gen
node_function_app -->|"extracts keywords"| node_keyword
node_content_plan -->|"requests titles"| node_ai
node_content_plan_en -->|"requests titles"| node_ai
node_fb_gen -->|"requests post copy"| node_ai
node_image_gen -->|"requests images"| node_ai
node_keyword -->|"uses cache"| node_redis
node_redis -->|"fetches on miss"| node_serp
node_function_app -.->|"sets post language"| node_polylang

click node_function_app "https://github.com/jurjans/ksj-wp-func/blob/main/function_app.py"
click node_worker "https://github.com/jurjans/ksj-wp-func/blob/main/article_worker.py"
click node_article_gen "https://github.com/jurjans/ksj-wp-func/blob/main/article_gen.py"
click node_en_article "https://github.com/jurjans/ksj-wp-func/blob/main/en_article_gen.py"
click node_polylang "https://github.com/jurjans/ksj-wp-func/blob/main/wordpress/mu-plugins/ksj-polylang-rest.php"
click node_storage "https://github.com/jurjans/ksj-wp-func/blob/main/storage.py"
click node_content_plan "https://github.com/jurjans/ksj-wp-func/blob/main/content_plan.py"
click node_content_plan_en "https://github.com/jurjans/ksj-wp-func/blob/main/content_plan_en.py"
click node_fb_gen "https://github.com/jurjans/ksj-wp-func/blob/main/fb_gen.py"
click node_image_gen "https://github.com/jurjans/ksj-wp-func/blob/main/image_gen.py"
click node_keyword "https://github.com/jurjans/ksj-wp-func/blob/main/article_gen.py"

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_function_app,node_worker toneBlue
class node_article_gen,node_en_article toneAmber
class node_content_plan,node_content_plan_en,node_fb_gen,node_image_gen,node_keyword toneMint
class node_wp,node_polylang,node_storage,node_blob,node_table,node_queue,node_ai,node_redis,node_serp toneRose
class node_sharepoint,node_power_automate toneIndigo
```

## Components

### API and jobs

- [HTTP endpoints](https://github.com/jurjans/ksj-wp-func/blob/main/function_app.py): `function_app.py`
- [Tick worker](https://github.com/jurjans/ksj-wp-func/blob/main/article_worker.py): `article_worker.py`

### Article generation

- [Latvian articles](https://github.com/jurjans/ksj-wp-func/blob/main/article_gen.py): `article_gen.py`
- [English articles](https://github.com/jurjans/ksj-wp-func/blob/main/en_article_gen.py): `en_article_gen.py`

### Content tools

- [Latvian content plans](https://github.com/jurjans/ksj-wp-func/blob/main/content_plan.py): `content_plan.py`
- [English content plans](https://github.com/jurjans/ksj-wp-func/blob/main/content_plan_en.py): `content_plan_en.py`
- [Facebook copy](https://github.com/jurjans/ksj-wp-func/blob/main/fb_gen.py): `fb_gen.py`
- [Social images](https://github.com/jurjans/ksj-wp-func/blob/main/image_gen.py): `image_gen.py`
- [SEO keywords](https://github.com/jurjans/ksj-wp-func/blob/main/article_gen.py): `article_gen.py`

### Integrations and state

- **WordPress REST**
- [Polylang language API](https://github.com/jurjans/ksj-wp-func/blob/main/wordpress/mu-plugins/ksj-polylang-rest.php): `wordpress/mu-plugins/ksj-polylang-rest.php`
- [Storage helpers](https://github.com/jurjans/ksj-wp-func/blob/main/storage.py): `storage.py`
- **Azure Blob Storage**
- **Azure Table Storage**
- **Azure Queue Storage**
- **OpenAI / Azure OpenAI**
- **Redis cache**
- **SerpApi**

### Other components

- **SharePoint plan**
- **Power Automate**

## Connections

- SharePoint plan → Power Automate: supplies metadata (evidence: `README.md`)
- Power Automate → HTTP endpoints: calls endpoints (evidence: `README.md`)
- HTTP endpoints → Tick worker: advances jobs (evidence: `function_app.py`)
- HTTP endpoints → Latvian articles: generates articles (evidence: `function_app.py`)
- Tick worker → Latvian articles: generates LV article (evidence: `article_worker.py`)
- Tick worker → English articles: generates EN article (evidence: `article_worker.py`)
- Latvian articles → OpenAI / Azure OpenAI: requests text (evidence: `README.md`)
- English articles → OpenAI / Azure OpenAI: requests text (evidence: `README.md`)
- Tick worker → WordPress REST: resolves tag IDs (evidence: `article_worker.py`)
- Tick worker → Storage helpers: persists job state (evidence: `article_worker.py`)
- Storage helpers → Azure Blob Storage: reads and writes (evidence: `storage.py`)
- Storage helpers → Azure Table Storage: tracks status (evidence: `storage.py`)
- Storage helpers → Azure Queue Storage: enqueues jobs
- Power Automate → Azure Blob Storage: downloads results (evidence: `README.md`)
- Power Automate → WordPress REST: publishes articles (evidence: `README.md`)
- HTTP endpoints → Latvian content plans: generates LV plan (evidence: `function_app.py`)
- HTTP endpoints → English content plans: generates EN plan (evidence: `function_app.py`)
- HTTP endpoints → Facebook copy: generates copy (evidence: `function_app.py`)
- HTTP endpoints → Social images: generates images (evidence: `function_app.py`)
- HTTP endpoints → SEO keywords: extracts keywords (evidence: `function_app.py`)
- Latvian content plans → OpenAI / Azure OpenAI: requests titles (evidence: `README.md`)
- English content plans → OpenAI / Azure OpenAI: requests titles (evidence: `content_plan_en.py`)
- Facebook copy → OpenAI / Azure OpenAI: requests post copy (evidence: `fb_gen.py`)
- Social images → OpenAI / Azure OpenAI: requests images (evidence: `README.md`)
- SEO keywords → Redis cache: uses cache (evidence: `README.md`)
- Redis cache → SerpApi: fetches on miss (evidence: `README.md`)
- HTTP endpoints → Polylang language API: sets post language
