# Supermarket transformation plan From a single-purpose "Social Curator" TUI for Federated Computer to a general marketing suite: a local web app, run in Docker, that any company running a Federated Core can install as a CoreDesktop sibling. ## 1. Decisions so far | Topic | Decision | |-------|----------| | Name | **Supermarket** (renamed from Coremarketing on 2026-11-19; the old TUI's data path `~/.local/state/coremarketing` keeps its name) | | Distribution | A CoreDesktop sibling: `sibling add ` installs it, `update` keeps it current | | Interface | A **local web app in Docker** at `http://localhost:8470`, on this machine only | | Scope | **One company** per install. A company can have **several websites** | | Core MCP / EspoCRM | Reached through the **local Hermes agent**, which gets an `mcp_servers` entry for the Core's MCP hub | | Billing data | **Stripe** first, for CAC, CLV and NRR | | Existing content work | **Kept.** The hard-coded app list becomes the **Inventory** of partners and competitors | | Websites and components | The suite builds the company's **websites** from a reusable **component library** | | Publishing | Sites are pushed to a **Gitea repository**. The user sets up the hooks that publish it to the Hugo server | | Contact enrichment | Third-party services allowed, behind a pluggable interface (section 6) | | Suite shape | One repo, one app with modules (Content, Prospects, SEO, Metrics, Sites), plus an MCP endpoint for agents | ## 2. Requirements from the notes | Note | Where it lands | |------|----------------| | Coredesktop sibling | Phase 0: `install.sh` / `update.sh` run Docker Compose and set up Hermes | | Generalize for any company | Phase 0: the company profile replaces everything Federated-specific | | Company description and targets | Company profile: products, ideal customer profile, voice, websites, accounts | | Connect to AI provider | Phase 0: Anthropic, or any OpenAI-compatible server (Ollama, LM Studio, …) | | Create and send content to X, LinkedIn, Reddit | Phase 1: Content module, built on today's pipeline, + Reddit | | Find prospects → EspoCRM via Core MCP | Phase 2: Prospects module; CRM writes go through Hermes | | SEO suggestions, change the Hugo repo | Phase 3: SEO module, with changes opened as PRs on Gitea | | SEO for Google, Brave, DuckDuckGo | Phase 3: Search Console, Bing Webmaster + IndexNow (DuckDuckGo results come mostly from Bing), Brave Search API for rank tracking | | Top-of-funnel lead generation | Content + SEO + prospecting + landing-page forms that create EspoCRM Leads | | Pipeline influence, CAC, CLV, NRR | Phase 4: Metrics module (Stripe + EspoCRM via Hermes + Plausible) | | Website, components | Phase 5: Sites module and component library | | Static file hosting on Core | Phase 5: push to a Gitea repo; the user's hooks deploy it | ## 3. Architecture ### Runtime ``` Browser / GNOME app-grid launcher (CoreDesktop `webapp add`) │ http://localhost:8470 ▼ ┌──────────────── supermarket container ────────────────┐ │ Go server: web UI (HTML + htmx) · JSON API · /mcp │ │ Background jobs: fetch, generate, publish, Stripe sync, │ │ SEO crawls, scheduled posts │ │ Tools in the image: git, hugo │ └───────┬───────────────────────────────▲─────────────────┘ │ bind mount │ /mcp (bearer token) ▼ │ ~/.local/share/supermarket/ ┌──────┴─────── Hermes (sandboxed) ──┐ app.db (SQLite) · secrets │ mcp_servers: │ sites/ · logs/ │ supermarket → localhost:8470 │ ~/.config/coredesktop/core.conf │ mcphub → Core MCP hub ───────────┼──► EspoCRM (read-only: domain, email) │ cron job: run the CRM queue │ (and other └────────────────────────────────────┘ Core apps) ``` - **Go stays.** The fetchers, AI client, X/LinkedIn clients, OAuth flows, X weighted-length counting and the atomic store all carry over. The Bubble Tea UI is replaced by server-rendered pages with htmx: no Node build step, a single small image, and the existing code is reused nearly as is. - **Localhost only.** The port is published as `127.0.0.1:8470:8080`, so other machines can't reach it (it doesn't depend on ufw-docker), and the app needs no login of its own. The `/mcp` endpoint requires a bearer token. - **OAuth** for X, LinkedIn, Reddit, Google and Bing redirects back to `http://localhost:8470/auth//callback`. This replaces today's `supermarket auth` command on `localhost:8080`. Developer apps need the new redirect URI registered. - **Local AI servers.** The container reaches a server on this machine through `host.docker.internal` (`extra_hosts: host-gateway`), and LAN or tailnet servers through the host's routing. The app offers the servers that CoreDesktop's `configure ai-servers` set up. - **Secrets.** The container can't reach GNOME's keyring, so the app's own tokens live in `/data/secrets` (mode 0600, never in the repo or the image). The Core MCP hub credential is **not** held by the app; it lives in Hermes' `~/.hermes/.env`. - **No inbound webhooks.** Nothing on the internet can reach the app, so Stripe and the social platforms are polled. Stripe's Events API makes this cheap. - **Data in SQLite.** That means one file to back up. The existing `posts.json`, `dismissed.json` and `state.json` are imported on first start. ### The Hermes bridge (Core MCP → EspoCRM) Hermes is the only thing that talks to the Core's MCP hub. The app and Hermes meet through the app's own MCP endpoint, so Hermes is configured with **two** MCP servers. **The block `install.sh` adds to `~/.hermes/config.yaml`.** The hub URL comes from `core.conf` and the user confirms it. Each `${…}` reference is resolved from `~/.hermes/.env`, so `config.yaml` holds no secret: ```yaml mcp_servers: mcphub: url: "https://mcphub./sse?as_user=" headers: Authorization: "Basic ${MCPHUB_AUTH}" supermarket: url: "http://127.0.0.1:8470/mcp" headers: Authorization: "Bearer ${SUPERMARKET_MCP_TOKEN}" ``` **`~/.hermes/.env`** (written through `hermes config set`, which routes UPPER_SNAKE names to `.env`): ``` MCPHUB_AUTH=