626 lines
35 KiB
Markdown
626 lines
35 KiB
Markdown
# 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 <url>` 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) |
|
||
| AI for the app | Uses Hermes' Anthropic key and model when the user agrees (2026-11-20), copied to `hermes-ai.json` by `supermarket hermes` and `update.sh`. It calls the model directly, never through Hermes: post writing reads untrusted web text, which must not reach an agent with tools and CRM access |
|
||
| 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/<provider>/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.<CORE_DOMAIN>/sse?as_user=<CORE_USER>"
|
||
transport: sse
|
||
headers:
|
||
Authorization: "Basic ${MCPHUB_AUTH}"
|
||
supermarket:
|
||
command: socat
|
||
args: ["STDIO", "UNIX-CONNECT:<data folder>/mcp.sock"]
|
||
```
|
||
|
||
**Why a socket, not `http://127.0.0.1:8470/mcp`** (found 2026-11-19).
|
||
CoreDesktop runs Hermes under srt, in its own network namespace. Hermes
|
||
always dials loopback directly, never through the proxy, and finds nothing
|
||
there. srt's proxy, in turn, refuses any name that resolves to loopback.
|
||
Unix sockets are allowed in Hermes' sandbox, so the app serves stdio-style
|
||
MCP on `/data/mcp.sock`, and Hermes runs `socat` as a stdio MCP server. The
|
||
socket is 0600, which is the same protection as the token file beside it.
|
||
The HTTP endpoint with its bearer token stays for unsandboxed agents
|
||
(Claude Code).
|
||
|
||
**`~/.hermes/.env`**:
|
||
|
||
```
|
||
MCPHUB_AUTH=<the user's own hub token from the Core (the part after "Basic "), from a hidden prompt>
|
||
```
|
||
|
||
How `install.sh` does it, safely and idempotently:
|
||
1. It uses `unsandboxed hermes config set mcp_servers.<name>.…`, the way
|
||
CoreDesktop's `configure hermes` calls Hermes. Hermes edits its YAML
|
||
with comment-preserving ruamel, so we never hand-edit its 2,400-line config.
|
||
If an `mcphub` entry already exists, it's left alone.
|
||
2. It asks whether Hermes may reach `mcphub.<CORE_DOMAIN>`. On yes, it adds
|
||
it to `network.allowedDomains` in
|
||
`~/.config/coredesktop/sandbox/hermes.json`. Hermes' sandbox blocks it
|
||
by default, and that file is the one no sandbox can write.
|
||
3. It stops the gateway (`hermes gateway stop`; Hermes starts it on demand) so the
|
||
servers load, then checks that Hermes lists the hub's tools.
|
||
4. The README documents the same block, with placeholders, for anyone setting
|
||
it up by hand.
|
||
|
||
How work flows through Hermes:
|
||
- **Writes (the CRM queue).** The app never calls EspoCRM itself. Approved
|
||
actions (create Lead, update Lead, add note, link Account) wait in a queue
|
||
with their exact payloads and an idempotency key. A Hermes cron job
|
||
installed by `install.sh` runs every 15 minutes. It calls
|
||
`supermarket.crm_pending_actions`, searches EspoCRM for duplicates, runs
|
||
each action through `mcphub`'s EspoCRM tools, and reports back with
|
||
`supermarket.crm_report_result(id, espo_id | error)`. You can also trigger
|
||
a run by asking Hermes, in its terminal or over Matrix.
|
||
- **Reads (for dedupe and metrics).** The same job pulls Leads, Accounts and
|
||
Opportunities changed since the last sync and hands them to
|
||
`supermarket.crm_ingest`. The app keeps a cached copy in SQLite.
|
||
- **Guardrails.** Hermes only carries out actions the app has queued; it
|
||
doesn't decide what goes into the CRM. Every result is checked against the
|
||
next read sync, and failures show in the app's CRM queue page with a retry
|
||
button.
|
||
- **Fallback.** The `crm` package has an interface. If having an LLM in the
|
||
loop proves too slow or unreliable for bulk writes, a direct MCP client in
|
||
the app can replace Hermes without changing the modules.
|
||
|
||
### Repo layout
|
||
|
||
```
|
||
cmd/supermarket/ server entry point
|
||
internal/
|
||
profile/ company, products, ICP, voice, websites
|
||
inventory/ partners & competitors (was config `applications:`)
|
||
ai/ provider interface: anthropic, openai-compatible
|
||
core/ core.conf, Core service URLs (Gitea, Plausible, MCP hub)
|
||
crm/ CRM queue + cached CRM data; executed by Hermes via mcphub
|
||
enrich/ contact-enrichment providers (Hunter, Apollo, …)
|
||
channels/ Publisher interface: x, linkedin, reddit
|
||
sources/ fetchers: x, youtube, rss/blog, reddit, (instagram)
|
||
content/ generation, drafts, approval, schedule, history ← today's pipeline
|
||
prospects/ discovery, enrichment, review, queue to CRM
|
||
seo/ crawler, checks, search-engine APIs, Hugo change sets
|
||
gitea/ clone, branch, PR, repo creation (SEO + Sites)
|
||
billing/ Stripe sync, MRR model, customer↔account matching
|
||
metrics/ pipeline influence, CAC, CLV, NRR
|
||
sites/ component library, page generation, publishing
|
||
mcp/ MCP tools over the modules (incl. the CRM bridge tools)
|
||
web/ handlers, templates, static assets
|
||
store/ SQLite + migrations
|
||
hermes/ cron job prompt + skill for the CRM bridge
|
||
Dockerfile · compose.yaml · install.sh · update.sh
|
||
```
|
||
|
||
### Sibling scripts
|
||
|
||
- `install.sh` (safe to re-run; it may prompt):
|
||
1. Checks that Docker is running and that the user is in the `docker` group.
|
||
2. Creates `~/.local/share/supermarket` and migrates
|
||
`~/.local/state/coremarketing/config.yaml` if it's there.
|
||
3. Runs `docker compose up -d --build`.
|
||
4. Adds the app-grid launcher with
|
||
`webapp add Supermarket http://localhost:8470`.
|
||
5. Sets up the Hermes bridge as described above, or explains how to run
|
||
`configure hermes` first if Hermes has no model provider yet.
|
||
6. Registers `/mcp` with Claude Code (`claude mcp add --transport http …`) so
|
||
it can drive the suite too.
|
||
- `update.sh` (doesn't prompt): runs `docker compose up -d --build`, which only
|
||
rebuilds when the source changed, and refreshes the Hermes cron job and skill
|
||
if they changed. It never touches the Hermes credentials. Schema migrations
|
||
run when the app starts.
|
||
- `restart: unless-stopped` keeps the app running across reboots, so scheduled
|
||
posts and syncs run without the browser open.
|
||
|
||
## 4. Domain model
|
||
|
||
### Company profile (one per install)
|
||
- Name, description, positioning, voice and tone, words to avoid
|
||
- **Products**: name, description, URL, pricing summary, key benefits
|
||
- **Ideal customer profile / targets**: industries, company size, roles,
|
||
regions, problems, buying signals, technologies they use
|
||
- **Websites** (many): URL, Gitea repo and branch, Plausible site, Search
|
||
Console property, Bing site
|
||
- **Accounts**: X handle, LinkedIn org/author, Reddit user, subreddits
|
||
- Keywords to rank for
|
||
|
||
The first time it runs, a wizard drafts the profile from the company's main
|
||
website with the AI, and the user edits it.
|
||
|
||
### Inventory (partners and competitors)
|
||
|
||
The current `applications:` list becomes the Inventory. Each entry has the same
|
||
fields as today (name, description, X handle, YouTube channel, Instagram,
|
||
hashtags) plus:
|
||
|
||
| Field | Purpose |
|
||
|-------|---------|
|
||
| `relationship` | `partner`, `competitor` or `watch` |
|
||
| `websites`, `linkedin`, `subreddits`, `rss` | More places to watch |
|
||
| `keywords` | Terms they own or compete on |
|
||
| `talking_points` | **Partners:** how we work together. **Competitors:** how we differ, where we win, what not to claim |
|
||
| `mention_policy` | Competitors: name them, or speak about the category without naming them |
|
||
|
||
What each relationship drives:
|
||
- **Partner**: today's behavior. Their news is fetched, and posts that
|
||
amplify it in our voice (co-promotion) are drafted for review.
|
||
- **Competitor: counter-programming.** Their launches, price changes, outages
|
||
and announcements trigger drafts that position our product, under the
|
||
entry's `mention_policy`. Also: "<competitor> alternative" landing-page
|
||
ideas, keyword-gap analysis against their sites, and prospects: companies
|
||
that use the competitor's product (technographics), and people asking for
|
||
alternatives on Reddit and X.
|
||
- **Watch**: only ecosystem news to curate, with no promotion either way.
|
||
|
||
Migration: entries from the old config are imported as `partner` (they are
|
||
the apps on a Federated Core), and the user re-labels them. The Federated list
|
||
ships as an example import file, `examples/federated-inventory.yaml`, not as a
|
||
default.
|
||
|
||
## 5. Phases
|
||
|
||
Each phase ends usable and with a release tag (`v0.x.0`).
|
||
|
||
### Phase 0: Foundation: web app, sibling, profile, Hermes bridge
|
||
|
||
**Status (2026-11-18): built on branch `phase0-foundation`.** Items 1–7 are
|
||
done, and so is the tooling for item 8. What changed from the plan:
|
||
- **No Hermes cron job yet.** Until Phase 2 there's no queued work, and every
|
||
run of the job is an LLM call. The bridge is tested by asking Hermes the
|
||
check-in question shown on the app's "Core & Hermes" page. The cron job
|
||
arrives with the CRM queue.
|
||
- **AI per task:** each task can use its own model, on the same provider.
|
||
- **The old TUI is gone.** Its post queue, dismissed items and last-checked
|
||
times are imported into SQLite, and its X/LinkedIn/YouTube clients and
|
||
fetcher are kept for Phase 1. Until Phase 1 lands, there's no way to post.
|
||
|
||
**Status (2026-11-20): Phase 0 is done, on `phase0-foundation`.** Item 8
|
||
works end to end: Hermes loads the hub's tools and checks in with the app.
|
||
|
||
What item 8 turned up:
|
||
- Sandboxed Hermes **can't** reach `127.0.0.1:8470` (see "Why a socket" in
|
||
the Hermes bridge section), so it reaches the app through `/data/mcp.sock`
|
||
with `socat`.
|
||
- `hermes config set` writes nested `mcp_servers.*` keys correctly, lists
|
||
(`args`) included.
|
||
- The hub rejected the shared admin token (401 at Traefik). The Core moved
|
||
to per-user tokens, still sent as `Authorization: "Basic <token>"`, with
|
||
`as_user=<user>` kept. The setup asks for the token, checks it with the
|
||
hub, and `supermarket hermes --reconfigure` re-enters it.
|
||
- The hub (FastMCP "mcpserver-hub" 3.2.0) speaks only SSE: a POST to `/sse`
|
||
gets 405. Hermes tries Streamable HTTP first, and that try ran out of its
|
||
60-second connect time, so setup.sh sets `transport: sse`. `tools/list`
|
||
takes about 10 seconds.
|
||
- A running Hermes gateway keeps its old servers, and `gateway stop` from
|
||
outside the sandbox didn't always stop it. setup.sh now checks the pid
|
||
file and says so when the gateway is still running.
|
||
- The hub offers 213 tools: Nextcloud 155, Listmonk 29, Superpanel 9,
|
||
Baserow 8, Plausible 6 and EspoCRM 6 (`espocrm_search_records`,
|
||
`espocrm_get_record`, `espocrm_get_related_records`,
|
||
`espocrm_create_record`, `espocrm_update_record`,
|
||
`espocrm_delete_record`). Hermes reports them with its own `mcp__mcphub__`
|
||
prefix, and the app stores the hub's names. Phase 2 builds on the generic
|
||
EspoCRM record tools.
|
||
- The per-user token also sees `nextcloud_admin_list_users` and
|
||
`nextcloud_admin_get_contacts`, both described as admin-only. To raise with
|
||
the Core's developer: it isn't known yet whether the hub blocks them for
|
||
non-admins.
|
||
|
||
Next: Phase 1, under way (see below).
|
||
|
||
Supermarket's half can be checked before the token arrives: ask Hermes the
|
||
check-in question now. It should reach `bridge_checkin` and note that
|
||
mcphub failed.
|
||
|
||
1. Restructure into the layout above. Port config and the JSON stores to
|
||
SQLite, with import from the old files.
|
||
2. Dockerfile (multi-stage: Go build → slim runtime with git and hugo) and
|
||
`compose.yaml`.
|
||
3. `install.sh` / `update.sh` as above, following
|
||
`coredesktop/skills/sibling-project-format.md`.
|
||
4. Web shell: navigation between the modules, a settings page, a credentials
|
||
page with OAuth "Connect" buttons, and a Core status page (whether
|
||
`core.conf` was found, whether Gitea and Plausible answer, and when the
|
||
Hermes bridge last ran).
|
||
5. Company profile + the wizard that drafts it from the website.
|
||
6. AI provider layer: choose the provider and model per task, and test the
|
||
connection.
|
||
7. Inventory module: list, edit, import (from the old config and from YAML),
|
||
and relationship labels.
|
||
8. **Hermes bridge test** (do this early, since Phases 2 and 4 depend on it):
|
||
- ~~Can sandboxed Hermes reach `127.0.0.1:8470` once it's in
|
||
`hermes.json`?~~ No. Answered 2026-11-19: it uses the MCP socket instead.
|
||
- ~~Does `hermes config set` write nested `mcp_servers.*.headers` keys
|
||
correctly?~~ Yes.
|
||
- What EspoCRM tools does the hub expose?
|
||
- Can Hermes cron jobs call MCP tools?
|
||
- How reliable is a run of 50 queued actions?
|
||
|
||
### Phase 1: Content (today's pipeline, generalized) + Reddit
|
||
|
||
**Status (2026-11-20): Phase 1 is built (all 4 parts) on `phase0-foundation`.** Phase 1 is
|
||
built in four parts, each committed on its own: (1) the pipeline, items 1–2
|
||
below, for X and LinkedIn; (2) the approval inbox, schedule and UTM tags,
|
||
item 5; (3) Reddit, item 4; (4) promoting our own products, the rest of
|
||
item 3. The user chose per-channel drafts and this order on 2026-11-20.
|
||
|
||
Part 1 (commit `13bf18f`):
|
||
- One generation writes **one draft per channel** (a short X post, a longer
|
||
LinkedIn post), each edited, published and retried on its own. The old
|
||
`posts` table became the `drafts` table (migration 2), one row per
|
||
platform a queued post hadn't reached.
|
||
- Fetching reads the entry's X account, X hashtag search, YouTube and RSS
|
||
feeds (new). Items are stored in `content_items`. A fetch only moves the
|
||
entry's start time on if every source answered.
|
||
- Prompts come from the profile, the entry's relationship, talking points
|
||
and mention policy, and the channel. Fetched text is marked as untrusted
|
||
quotes. An X draft over the limit gets one request to shorten it.
|
||
- Publishing claims the draft first (`publishing`), so it can't post twice;
|
||
a draft left `publishing` by a restart is marked failed for review.
|
||
|
||
Part 2 (commit `f275f03`):
|
||
- **Inbox** (top-level menu, with a count): everything waiting for
|
||
approval, one section per module; Content's drafts for now. Phase 2's
|
||
prospects and Phase 3's SEO changes add sections.
|
||
- **Scheduling**: a draft is published now or scheduled (`scheduled`,
|
||
`publish_at`, migration 3). A scheduler in the app checks every 30
|
||
seconds. A post more than 12 hours overdue (the computer was off) goes
|
||
back to Posts rather than out stale, and so does one refused before
|
||
posting (signed out, too long). Content has Scheduled and Published tabs.
|
||
- **UTM tags** only on links to the company's websites and product URLs
|
||
(from the profile), added at publishing; drafts are stored untagged.
|
||
`utm_source` = channel, `utm_medium` = social, `utm_campaign` = kind of
|
||
post, `utm_content` = entry slug and draft ID.
|
||
- The container now runs in the computer's time zone (`SUPERMARKET_TZ` in
|
||
compose.env, from /etc/localtime), so times show and parse correctly.
|
||
|
||
Part 3, Reddit (commit `0e34f57`):
|
||
- A third channel, `reddit`: a draft has a `title` and a `target`
|
||
subreddit (migration 4), chosen when writing, with suggestions from the
|
||
entry's and the profile's subreddits. Reddit is never pre-checked.
|
||
- Sign-in through a Reddit "web app" (`duration=permanent`; scopes
|
||
identity, submit, read, history). The hour-long access token is
|
||
refreshed on a 401 and saved. Before sign-in, rules are read with an
|
||
app-only token (client credentials).
|
||
- Subreddit info (description, posting guidelines, rules, allowed post
|
||
types) is cached in `subreddits` for a day. It goes into the prompt and
|
||
is shown with the draft, with a Refresh button.
|
||
- The prompt asks for a community member's post that says where they work:
|
||
no hashtags, emoji or marketing language, following the rules.
|
||
- Publishing: a text post with "Source: <link>" at the end, or a link post
|
||
where the subreddit takes only links.
|
||
- Warnings, never blocking (`content.RedditWarnings`): promotion-related
|
||
rules, restricted subreddits, wrong post type, a post in the same
|
||
subreddit in the past 7 days, more than 1 in 10 recent posts linking to
|
||
the company's own sites (counting this one), and a new account. They use
|
||
the account's last 100 posts, cached for 10 minutes.
|
||
|
||
Part 4, promoting our own products:
|
||
- A virtual inventory entry for the company (`content.OwnEntry`, items
|
||
stored under `_own`), shown first under Content as the company's name and
|
||
served at `/content/own`. It isn't stored in `inventory`.
|
||
- Products from the profile are kept in step as items
|
||
(`product:<slug>`, source `Product`), always there to pick from; they
|
||
don't count as waiting news.
|
||
- A new profile field, **Feeds**: the company's blog, news and release
|
||
feeds, fetched like an entry's RSS.
|
||
- Site pages: new or updated pages from each website's `sitemap.xml`
|
||
(sitemap indexes one level deep), newest 15 per fetch, with each page's
|
||
title and description. This runs only for the company's own sites.
|
||
- Drafts get kind `product` (so `utm_campaign=product`) and the company's
|
||
name. The prompt asks for posts that promote the company's own work with
|
||
claims the material supports. On Reddit it asks for the makers' voice and
|
||
invites feedback, and Posts warns that self-promotion is often
|
||
restricted.
|
||
|
||
**Not yet tried for real (deferred on 2026-11-21 for the UI redesign below; run this checklist next).** Parts 1–4 are covered by tests with fake AI
|
||
and channel clients, and the rebuilt app runs (schema 3). But the
|
||
installed app has no profile, AI key, inventory or social sign-ins yet, so no
|
||
real fetch, generation or post has been made. Before relying on it:
|
||
1. Fill in the Profile, add an Anthropic key, and add an inventory entry
|
||
with an RSS feed (needs no credentials).
|
||
2. Fetch, write drafts, and check Posts's prompts and lengths.
|
||
3. Connect X and LinkedIn, publish one draft now, schedule one a few
|
||
minutes ahead, and check that both go out, with UTM tags on a link to
|
||
the company's site.
|
||
4. Register a Reddit web app, connect it, write a Reddit draft for a
|
||
subreddit, and check its rules and warnings. Post to a test subreddit
|
||
you moderate first.
|
||
5. Add a product and a blog or releases feed to the profile, open
|
||
Content → (company name), fetch, and write a post from a product.
|
||
|
||
The database before migration 2 is backed up at
|
||
`~/.local/share/supermarket/app.db.pre-phase1`. Commits on
|
||
`phase0-foundation` are pushed from a host terminal (no credential helper,
|
||
so `git push` can't prompt from Claude Code). The branch stays off `main`
|
||
until the user decides to merge; posting works again now, which was the
|
||
condition for merging.
|
||
|
||
**UI redesign (2026-11-21).** The user asked for brain
|
||
(gitea.federated.computer/Federated_Computer/brain, a Next.js + Tailwind
|
||
app) to be the UI basis from now on. Supermarket stays Go templates + htmx;
|
||
it takes brain's look rather than its stack: brain's colour tokens, type,
|
||
radius and shadows (and its dark theme, following the system setting), a
|
||
left sidebar with search at the top and Settings at the bottom, a top bar
|
||
with breadcrumbs, and Settings as grouped tabs on the left. The menu:
|
||
Search, Overview (module cards and setup), Inventory, then the modules
|
||
(Content with Posts (was Inbox, renamed 2026-11-21), Sources, Scheduled and Published; the later phases
|
||
shown greyed out). Settings holds Profile, Social accounts (was
|
||
Credentials; keys and sign-in together per network), Core & Hermes, and AI
|
||
(provider, model, and the API keys, which moved there from Credentials).
|
||
Old addresses (`/profile`, `/core`, `/settings/credentials`) redirect.
|
||
Search (`/search`) matches every word across posts, fetched items, the
|
||
inventory, products and settings pages. New modules add a `modules` entry
|
||
in `internal/web/server.go` and an icon in `layout.html`. brain's fonts
|
||
(DM Sans, Plus Jakarta Sans) are named but not bundled, so the system font
|
||
is used unless they're installed.
|
||
|
||
**To pick this up:** try Phase 1 for real (the checklist above), fix what
|
||
that turns up, then decide whether to merge `phase0-foundation` into `main`
|
||
and tag `v0.1.0`. Then Phase 2, Prospects → EspoCRM, which depends on the
|
||
hub's EspoCRM tools (see Phase 0: `espocrm_search_records`,
|
||
`espocrm_get_record`, `espocrm_get_related_records`,
|
||
`espocrm_create_record`, `espocrm_update_record`, `espocrm_delete_record`).
|
||
|
||
The plan for Phase 1, as first written:
|
||
1. Port fetch → browse → select → generate → approve → publish into the web
|
||
UI, keeping the dismiss feature, tracking of what was posted where, partial
|
||
posting, and X length handling.
|
||
2. Generation prompts are built from the profile, the inventory entry's
|
||
relationship and talking points, and the target channel.
|
||
3. Content types: partner amplification, competitor counter-programming,
|
||
promotion of our own products (from the product list, site pages, blog RSS,
|
||
and releases).
|
||
4. Reddit: OAuth, subreddit list, each subreddit's rules shown with the draft,
|
||
approval always required, warnings about posting too often.
|
||
5. Scheduling queue, an approval inbox for drafts from all modules, and UTM
|
||
tags on every link so Metrics can attribute visits.
|
||
|
||
### Phase 2: Prospects → EspoCRM
|
||
1. Discovery from the profile's targets, from these sources:
|
||
- company search (enrichment provider, Brave Search API)
|
||
- technographics (companies using a competitor's product)
|
||
- intent signals on Reddit and X
|
||
2. Enrichment through the `enrich` providers: people by role at a target
|
||
company, work email, LinkedIn profile URL, and email verification.
|
||
LinkedIn itself isn't scraped.
|
||
3. Review screen: why each prospect fits, where each contact came from,
|
||
verification status, dedupe against the cached CRM data, then accept → the
|
||
CRM queue → Hermes → an EspoCRM Lead with source and campaign set.
|
||
4. Compliance: the source and date are recorded for every contact, plus a
|
||
suppression list that is checked before anything is queued.
|
||
5. Inbound: the lead-form component (Phase 5) queues a Lead the same way.
|
||
6. **To do (asked 2026-11-21): connect to outside marketing services to
|
||
collect leads.** Examples the user gave: origami.chat and explee.com. Each
|
||
service is a lead source: Supermarket connects with the user's own account
|
||
(API key or OAuth, under Settings), pulls the leads it found, and puts them
|
||
through the same review screen, dedupe, suppression list and
|
||
source/date record as the leads it finds itself, so nothing reaches
|
||
EspoCRM unreviewed. Before building, check each service: whether it has an
|
||
API, webhooks or only a CSV export (a CSV import is the fallback for any
|
||
service), what a lead holds, and its terms on storing and reusing the
|
||
data. Build it as a `leadsource` interface, one adapter per service, like
|
||
the `enrich` providers.
|
||
|
||
### Phase 3: SEO, for all of the company's websites
|
||
1. Audit each website: titles, meta descriptions, headings, canonical URLs,
|
||
sitemap, robots.txt, JSON-LD, Open Graph, broken links, alt text, Core Web
|
||
Vitals (PageSpeed Insights API).
|
||
2. Content gaps: the profile's keywords and the competitors' sites from the
|
||
Inventory, compared with ours.
|
||
3. Search engines: Google Search Console API, Bing Webmaster API, IndexNow on
|
||
publish, and Brave Search API rank tracking.
|
||
4. Apply fixes: clone the site's Gitea repo into `/data/sites/`, make the
|
||
changes on a branch, check that `hugo` still builds, show the diff in the
|
||
UI, and open a PR on Gitea. Nothing is pushed to the default branch.
|
||
Merging the PR is the user's decision, and their hooks publish it.
|
||
5. Before/after tracking for each change.
|
||
|
||
### Phase 4: Metrics, with Stripe
|
||
1. **Stripe sync**: a restricted, read-only key; customers, subscriptions,
|
||
invoices, credit notes and refunds; a full backfill, then incremental
|
||
updates through the Events API.
|
||
2. **MRR model**: MRR per customer per month, normalized from subscription items
|
||
(annual ÷ 12, with discounts, trials and pauses handled), classified as new,
|
||
expansion, contraction, churn or reactivation.
|
||
3. **Matching** Stripe customers to EspoCRM Accounts (from the cached CRM data)
|
||
by email domain or stored ID, with a screen to fix the matches it gets wrong.
|
||
4. **Spend log** for CAC: entered by hand or imported from CSV, by channel and
|
||
month (Stripe has no marketing spend). Enrichment provider costs can be
|
||
logged automatically.
|
||
|
||
| Metric | Definition | Sources |
|
||
|--------|-----------|---------|
|
||
| Pipeline influence | Value of open and won opportunities with at least one marketing touch (UTM visit, form, prospect push, engagement with a post), by channel | EspoCRM (via Hermes), Plausible, the app's own history |
|
||
| CAC | Spend ÷ new paying customers, per month and per channel | Spend log, Stripe (first paid invoice) |
|
||
| CLV | ARPA × gross margin ÷ monthly churn rate, plus actual cumulative revenue per cohort | Stripe; gross margin set in settings |
|
||
| NRR | (Starting MRR + expansion − contraction − churn) ÷ starting MRR, monthly and trailing-12-month, by cohort | Stripe MRR model |
|
||
|
||
5. A dashboard with CSV export. It can also be published as a page on one of
|
||
the company's sites.
|
||
|
||
### Phase 5: Sites and components
|
||
1. **Component library**: a Hugo theme module with section partials (hero,
|
||
features, cards, steps, pricing, stats, FAQ, comparison table, testimonial,
|
||
lead form, final CTA) on the `sections:` front-matter pattern from
|
||
`webcoredesktop`, themed from the profile (colors, fonts, logo). It lives
|
||
in its own Gitea repo and is versioned, so the company's sites can pull
|
||
updates.
|
||
2. **Site builder**: create a new site from the library (which creates its
|
||
Gitea repo through the API), or add pages to an existing one (landing,
|
||
product, "<competitor> alternative" and comparison pages, blog posts) from
|
||
the profile, the Inventory and SEO findings. Changes are always PRs.
|
||
Preview runs `hugo server` inside the container.
|
||
3. **Publishing** = merging into the site repo's publish branch on Gitea. The
|
||
user's Gitea hooks deploy it to their Hugo server. The app shows the last
|
||
merge, and checks the live site afterwards to confirm it changed.
|
||
|
||
### Future enhancements
|
||
|
||
Not in any phase yet; picked up when the user asks.
|
||
|
||
1. **Post to the LinkedIn company page** (deferred 2026-11-21). Today posts
|
||
go to the signed-in member's profile (`w_member_social`). Posting as the
|
||
Federated Computer page needs LinkedIn's **Community Management API**,
|
||
which LinkedIn approves by hand.
|
||
- The user's side: be an admin of the company page, with its website
|
||
and domain verified; create a *second* LinkedIn app linked to the page
|
||
(Community Management can only be requested on a new app with no other
|
||
products), have a page admin verify it, and request the Development
|
||
tier (an access form describing the use). It's likely enough: 500 calls
|
||
a day, though for up to 12 months. Standard tier needs a screen
|
||
recording and a privacy policy. A rejected app can't reapply; a new app
|
||
would be needed.
|
||
- Supermarket's side, once approved: a second set of LinkedIn keys and a
|
||
Connect button for the page app; list the pages the user administers
|
||
and pick one; on each LinkedIn draft, choose the profile or the page
|
||
(author `urn:li:organization:<id>`). Check the approved app's Auth tab
|
||
for the exact scopes (expected `w_organization_social`, plus one for
|
||
listing administered pages) before building.
|
||
- Docs: learn.microsoft.com/linkedin/marketing/community-management-app-review
|
||
and .../community-management/community-management-overview.
|
||
|
||
## 6. Contact enrichment: suggested services
|
||
|
||
"Enrichment" means: given a target company (or a person's name), find the
|
||
people in the roles you sell to, their work email and LinkedIn URL, and check
|
||
that the email is deliverable. These are good candidates; check current pricing
|
||
before choosing:
|
||
|
||
| Service | What it's good for | Notes |
|
||
|---------|-------------------|-------|
|
||
| **Hunter.io** | Emails at a company's domain, email finder by name, verification | Simple API, small free tier, cheap paid plans. A good first provider |
|
||
| **Apollo.io** | Searching people by title, seniority, industry and company size; returns email and LinkedIn URL | Largest database here. API access requires a paid plan. A strong second |
|
||
| **People Data Labs** | Person and company enrichment API for developers, paid per record | Good for bulk; little UI, which suits us |
|
||
| **Snov.io / Prospeo** | Finder + verifier, lower cost | Alternatives to Hunter |
|
||
| **BuiltWith or Wappalyzer** | Technographics: which companies use a given product | Feeds competitor counter-programming |
|
||
| **ZeroBounce / NeverBounce** | Verification only | Use if the finder's own verification isn't enough |
|
||
|
||
Recommendation: build the `enrich` interface with **Hunter** first (company
|
||
domain → people → verified email). Add **Apollo** for searching people by role,
|
||
and **BuiltWith/Wappalyzer** to find companies that use a competitor. Each user
|
||
brings their own API keys, and the app logs credits used as spend for CAC.
|
||
|
||
## 7. Order and dependencies
|
||
|
||
```
|
||
Phase 0 (incl. Hermes bridge test) ──► Phase 1 (content)
|
||
│
|
||
├──► Phase 2 (prospects) ── needs: Hermes bridge, mcphub EspoCRM tools
|
||
├──► Phase 3 (SEO) ──────── needs: Gitea token
|
||
├──► Phase 4 (metrics) ──── needs: Stripe key; CRM reads for pipeline
|
||
└──► Phase 5 (sites) ────── needs: Gitea token
|
||
```
|
||
|
||
Phases 1, 3, 5 and the Stripe half of 4 depend only on Phase 0.
|
||
|
||
## 8. Open questions
|
||
|
||
1. **MCP hub credentials**: the example authenticates as an admin and uses
|
||
`as_user=` to act as the user. Can the hub issue per-user credentials or
|
||
tokens instead? An admin password in each desktop's Hermes `.env` gives an
|
||
agent that reads untrusted web content admin access to the Core.
|
||
*2026-11-19:* the Core's developer confirmed it's always the admin token
|
||
today. After the admin token failed with a 401, they said the hub will
|
||
likely move to per-user tokens.
|
||
*2026-11-20:* resolved. The hub now issues per-user tokens, still sent as
|
||
`Authorization: "Basic <token>"`, with `as_user=<user>` kept in the URL.
|
||
2. **MCP hub URL**: is it always `mcphub.<CORE_DOMAIN>`, so it can be worked out
|
||
from `core.conf`?
|
||
3. **Gitea**: which Gitea do sites live on (the Core's, at
|
||
`gitea.<CORE_DOMAIN>`?), and should the app get its token from the user or
|
||
from Gitea's OAuth?
|