# denzuko/podcast-mgr architecture

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

- Interactive diagram: https://gitdiagram.com/denzuko/podcast-mgr
- Repository: https://github.com/denzuko/podcast-mgr

## Overview

1. This repository contains two intentionally separate subsystems built around the same data file: a FastCGI/CGI subscription manager and a cron-driven downloader. The shared boundary between them is `feeds.xml`, which acts as the persistent state for the whole project.

2. The primary runtime component is `main.c`, a single-user FastCGI SPA. It serves the podcast management UI and handles all subscription CRUD-style interactions against the XML database. The README says it uses htmx for partial updates, so the browser talks to the CGI worker incrementally rather than as a full-page traditional app.

3. The server-side web stack is the BCHS ecosystem: `kcgi` for FastCGI and request handling, `khtml` for HTML generation, and `kcgixml` for XML-related support. In architectural terms, `main.c` is both the HTTP endpoint and the application controller for the subscription list.

4. Persistence is file-based, not database-based. `feeds.xml` is the canonical store, and `feeds.xsd` defines the schema used to validate that file’s structure. That makes the XML document the key state boundary: the CGI writes/manages it, while the downloader reads it.

5. `podcast.sh` is a separate tcsh cron job that consumes `feeds.xml` and downloads episodes according to the schedule stored there. It does not depend on the web UI at runtime, which means the architecture cleanly splits “manage subscriptions” from “execute downloads.”

6. The repository is designed for a single-user deployment model rather than a multi-tenant service. That is reinforced by the configuration path under `$XDG_CONFIG_HOME/podcasts/feeds.xml` with a home-directory fallback, and by the focus on a local cron-based workflow.

7. `sandbox.h` provides a portability layer for privilege reduction and syscall confinement. The README mentions seccomp, Capsicum, and pledge, so the CGI worker is intended to run with reduced privileges depending on platform support. That is a security boundary around the request-processing process.

8. `nob.c` is the build entry point, using tsoding’s `nob` as a minimal build system. The post-clone git hook automates building the project, so the repo’s build story is intentionally lightweight and source-driven rather than using a heavy external build framework.

9. `index.cgi.8` is the operator-facing documentation for the CGI service, while the `.7` manpages and changelog support packaging and release management. These files indicate the project is meant to be deployed and maintained like a small Unix service, not as an application with a separate admin console.

10. `sbom.json` and `podcast_mgr.sarif` are supply-chain and static-analysis artifacts. They do not affect the runtime architecture, but they show that the project tracks dependency composition and security findings alongside the codebase.

11. The main data flow is: user edits subscriptions in the CGI UI -> `main.c` updates `feeds.xml` -> cron later reads the same file -> `podcast.sh` downloads episodes. Any architecture diagram should draw `feeds.xml` in the center, with the web worker on one side and the scheduled downloader on the other.

12. The key architectural boundary is therefore not between “frontend” and “backend,” but between “interactive management” and “automated execution.” The web app owns the configuration lifecycle; the cron script owns content retrieval, and both are coupled only through the XML file and its schema.

Main entry points: [`main.c`](https://github.com/denzuko/podcast-mgr/blob/main/main.c) (main.c), [`podcast.sh`](https://github.com/denzuko/podcast-mgr/blob/main/podcast.sh) (podcast.sh), [`nob.c`](https://github.com/denzuko/podcast-mgr/blob/main/nob.c) (nob.c), [`sbom.json`](https://github.com/denzuko/podcast-mgr/blob/main/sbom.json) (sbom/sarif)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime_web["Interactive management"]
  node_main_c["main.c<br/>cgi app<br/>[main.c]"]
  node_htmx_ui["HTMX UI<br/>browser flow"]
  node_kcgi_stack["kcgi stack<br/>request layer"]
  node_khtml_gen["khtml<br/>html gen"]
  node_kcgixml_support["kcgixml<br/>xml support"]
end

subgraph group_runtime_cron["Scheduled downloads"]
  node_podcast_sh["podcast.sh<br/>cron script<br/>[podcast.sh]"]
  node_cron_env["cron job<br/>scheduler"]
  node_download_exec["downloads<br/>retrieval flow"]
end

subgraph group_shared_state["Shared state"]
  node_feeds_xml["feeds.xml<br/>xml state"]
  node_feeds_xsd["feeds.xsd<br/>schema<br/>[feeds.xsd]"]
end

subgraph group_build_ops["Build and ops"]
  node_sandbox_h["sandbox.h<br/>security layer<br/>[sandbox.h]"]
  node_nob_c["nob.c<br/>build entry<br/>[nob.c]"]
  node_git_hooks["githooks<br/>automation<br/>[post-checkout]"]
  node_docs_index["index.cgi.8<br/>man page<br/>[index.cgi.8]"]
  node_docs_policy["policy docs<br/>man pages"]
  node_supply_chain["sbom/sarif<br/>artifacts<br/>[sbom.json]"]
end

node_main_c -->|"uses"| node_kcgi_stack
node_main_c -->|"renders"| node_khtml_gen
node_main_c -->|"parses"| node_kcgixml_support
node_main_c -->|"drives"| node_htmx_ui
node_main_c -->|"reads/writes"| node_feeds_xml
node_main_c -->|"validates"| node_feeds_xsd
node_main_c -->|"constrains"| node_sandbox_h
node_podcast_sh -->|"triggered by"| node_cron_env
node_podcast_sh -->|"reads"| node_feeds_xml
node_podcast_sh -->|"executes"| node_download_exec
node_feeds_xml -->|"constrained by"| node_feeds_xsd
node_nob_c -->|"builds"| node_main_c
node_nob_c -->|"packages"| node_podcast_sh
node_git_hooks -->|"automates"| node_nob_c
node_docs_index -->|"documents"| node_main_c
node_docs_policy -->|"supports"| node_nob_c
node_supply_chain -->|"tracks"| node_main_c
node_supply_chain -->|"tracks"| node_podcast_sh

click node_main_c "https://github.com/denzuko/podcast-mgr/blob/main/main.c"
click node_feeds_xsd "https://github.com/denzuko/podcast-mgr/blob/main/feeds.xsd"
click node_podcast_sh "https://github.com/denzuko/podcast-mgr/blob/main/podcast.sh"
click node_sandbox_h "https://github.com/denzuko/podcast-mgr/blob/main/sandbox.h"
click node_nob_c "https://github.com/denzuko/podcast-mgr/blob/main/nob.c"
click node_git_hooks "https://github.com/denzuko/podcast-mgr/blob/main/.githooks/post-checkout"
click node_docs_index "https://github.com/denzuko/podcast-mgr/blob/main/index.cgi.8"
click node_docs_policy "https://github.com/denzuko/podcast-mgr/blob/main/podcast-mgr.ieee829.7"
click node_supply_chain "https://github.com/denzuko/podcast-mgr/blob/main/sbom.json"

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_main_c,node_htmx_ui,node_kcgi_stack,node_khtml_gen,node_kcgixml_support toneBlue
class node_podcast_sh,node_cron_env,node_download_exec toneAmber
class node_feeds_xml,node_feeds_xsd toneMint
class node_sandbox_h,node_nob_c,node_git_hooks,node_docs_index,node_docs_policy,node_supply_chain toneRose
```

## Components

### Interactive management

FastCGI/CGI subscription manager and its request-processing stack

- [main.c](https://github.com/denzuko/podcast-mgr/blob/main/main.c): cgi app · FastCGI/CGI subscription manager and UI controller · `main.c`
- **HTMX UI**: browser flow · Incremental browser interaction pattern used by the CGI app
- **kcgi stack**: request layer · FastCGI request handling and HTTP plumbing used by the web worker
- **khtml**: html gen · HTML generation support for the management UI
- **kcgixml**: xml support · XML-related support used by the CGI application

### Scheduled downloads

Cron-driven retrieval pipeline that consumes the shared feed state

- [podcast.sh](https://github.com/denzuko/podcast-mgr/blob/main/podcast.sh): cron script · Scheduled downloader that reads the shared XML state · `podcast.sh`
- **cron job**: scheduler · External scheduler that triggers the downloader on a timetable
- **downloads**: retrieval flow · Episode fetching and file retrieval performed by the cron worker

### Shared state

Canonical XML configuration and schema boundary used by both runtimes

- **feeds.xml**: xml state · Canonical persistent store for subscriptions and download schedule
- [feeds.xsd](https://github.com/denzuko/podcast-mgr/blob/main/feeds.xsd): schema · XML schema defining the structure of the shared state · `feeds.xsd`

### Build and ops

Build entrypoint, portability layer, packaging docs, and repository automation

- [sandbox.h](https://github.com/denzuko/podcast-mgr/blob/main/sandbox.h): security layer · Portability layer for privilege reduction and syscall confinement · `sandbox.h`
- [nob.c](https://github.com/denzuko/podcast-mgr/blob/main/nob.c): build entry · Minimal build system entrypoint used to compile the project · `nob.c`
- [githooks](https://github.com/denzuko/podcast-mgr/blob/main/.githooks/post-checkout): automation · Repository hook automation that builds after checkout · `.githooks/post-checkout`
- [index.cgi.8](https://github.com/denzuko/podcast-mgr/blob/main/index.cgi.8): man page · Operator documentation for the CGI service · `index.cgi.8`
- [policy docs](https://github.com/denzuko/podcast-mgr/blob/main/podcast-mgr.ieee829.7): man pages · Process and release documentation for packaging and maintenance · `podcast-mgr.ieee829.7`
- [sbom/sarif](https://github.com/denzuko/podcast-mgr/blob/main/sbom.json): artifacts · Supply-chain and static-analysis outputs tracked in the repository · `sbom.json`

## Connections

- main.c → kcgi stack: uses · Handles FastCGI requests through the BCHS request layer
- main.c → khtml: renders · Generates the management UI markup
- main.c → kcgixml: parses · Uses XML helpers for feed state handling
- main.c → HTMX UI: drives · Serves partial updates to the browser UI
- main.c → feeds.xml: reads/writes · Manages subscriptions in the shared XML store
- main.c → feeds.xsd: validates · Relies on the schema as the structure contract
- main.c → sandbox.h: constrains · Runs under reduced privileges and confinement where supported
- podcast.sh → cron job: triggered by · Runs as a scheduled cron job
- podcast.sh → feeds.xml: reads · Consumes the shared schedule and subscription state
- podcast.sh → downloads: executes · Performs episode retrieval and download actions
- feeds.xml → feeds.xsd: constrained by · The persistent XML file follows the declared schema
- nob.c → main.c: builds · Compiles the CGI application
- nob.c → podcast.sh: packages · Supports project build/release assembly
- githooks → nob.c: automates · Post-checkout hook builds the project
- index.cgi.8 → main.c: documents · Operator guidance for the CGI service
- policy docs → nob.c: supports · Describes maintenance and release process
- sbom/sarif → main.c: tracks · Captures security and dependency metadata for the codebase
- sbom/sarif → podcast.sh: tracks · Captures analysis and artifact metadata for the downloader side
