How mreflow/control-center works
Purpose and runtime
Control Center is a local-first Next.js dashboard for collecting and curating industry news, verified brand mentions, newsletter intelligence, public audience metrics, and personal action items. It runs as a loopback-only Node.js service, with durable local settings/files and SQLite storage. Main UI entry points are app/page.tsx and app/layout.tsx; API entry points are Next route handlers under app/api/.
UI and API boundary
The single-page dashboard composes its live areas and settings controls from client components, principally components/control-center.tsx, components/audience-insights.tsx, and components/ai-provider-settings.tsx. Browser interactions call narrowly scoped local APIs for workspace state, settings, brief data, library/archive actions, and collectors:
• app/api/workspace/route.ts
• app/api/settings/route.ts
• app/api/brief/route.ts
Server-side routes form the trust boundary: secrets never return to the client, and loopback/host protections are enforced before local data or external services are accessed.
Local persistence and workspace state
SQLite is the primary durable record for discovered content, queues, archives, newsletter metadata, tasks, reminders, and historical audience readings. Server persistence and data-directory initialization center on lib/server/database.ts; settings/secrets are handled in lib/server/settings.ts. Domain stores isolate each saved queue:
• lib/industry-store.ts
• lib/newsletter-store.ts
• lib/archive-store.ts
A workspace/brief layer combines saved collector state rather than recollecting when users navigate or open Today, via lib/workspace-store.ts, lib/brief-store.ts, and lib/daily-brief-snapshot.ts.
Industry collection pipeline
Industry collection discovers feeds from configured sites, then falls back to robots/sitemap traversal and optional Google News topic search. Discovery and ranking stages are separated so broad raw results do not directly become cards. Key stages are feed/sitemap discovery, cached collection, canonical deduplication, freshness/topic/source prioritization, optional AI reranking, then persistence of the bounded active queue:
• lib/feed-discovery.ts
• lib/sitemap.ts
• lib/industry-curation.ts
External public-web access is hardened through server fetch/RSS modules such as lib/server/safe-fetch.ts and lib/server/rss.ts.
Mention research and verification
Mentions begin with public news search and optional cloud-AI broad-web discovery, but are only surfaced after direct canonical-page verification against configured identities, domains, anchors, and exclusions. The flow deliberately separates untrusted search/AI candidates from literal page-local evidence, then applies summaries/priority ranking and stable archival identity:
• lib/server/mention-research.ts
• lib/server/mention-curation.ts
• lib/mention-filter.ts
Google News and Bing/public pages are external discovery sources; AI is advisory and cannot qualify an otherwise unverified mention.
Newsletter and Gmail intelligence
Gmail OAuth is a separate optional integration. OAuth start/callback routes establish read-only access, then bounded background collection reads matching unseen issues. Bodies are masked for privacy and passed to the selected AI model for extraction, ranking, cross-newsletter event consolidation, and persistent topic aliases:
• app/api/auth/google/start/route.ts
• app/api/auth/google/callback/route.ts
• lib/server/newsletter-collector.ts
The Gmail API client resides in lib/server/gmail.ts; lib/server/newsletter-ai.ts handles AI extraction. Without a usable AI runtime, newsletter processing pauses rather than degrading into an inbox mirror.
AI runtime and provider boundary
AI is optional for industry reranking, mention research/summaries, and required for newsletters. Provider selection, saved credentials, model discovery, and bounded requests are separated across:
• lib/ai-settings.ts
• lib/ai-model-discovery.ts
• lib/server/ai.ts
Supported external providers include OpenAI, Anthropic, Gemini, and Grok; local LM Studio/Ollama endpoints are restricted to numeric loopback addresses. The models endpoint, app/api/ai/models/route.ts, exposes discovered selectable models without exposing keys. Deterministic local ranking provides failure fallback where AI is optional.
Scheduling, audience, and connector ingestion
Startup/manual refresh and 15-minute recurring collection are coordinated by lib/server/scheduler.ts and lib/tasks.ts. Audience collection validates configured public profiles before storing verified readings and deriving comparable growth/chart data:
• lib/server/audience.ts
• lib/audience-growth.ts
• app/api/live/audience/route.ts
Optional private connector automations submit normalized action/meeting/message summaries to the local brief boundary rather than receiving direct account access; its contract is documented in docs/CONNECTOR_BRIDGE.md and ingested through app/api/brief/route.ts.
Main entry points: database.ts SQLite content store · ai.ts AI provider runtime · control-center.tsx Control Center UI · scheduler.ts Collection scheduler
Components 23
Dashboard & local API
- Control Center UI · Live dashboard, audience, and AI settings surfaces.
components/control-center.tsx - Workspace API
app/api/workspace/route.ts - Settings API
app/api/settings/route.ts - Brief API · Local trust boundary for brief state and connector submissions.
app/api/brief/route.ts - Model discovery API · Returns selectable models without credentials.
app/api/ai/models/route.ts - Google OAuth start
app/api/auth/google/start/route.ts - Google OAuth callback
app/api/auth/google/callback/route.ts
Local state & scheduling
- SQLite content store · Durable queues, archives, tasks, newsletters, and audience history.
lib/server/database.ts - Settings & secrets · Keeps provider credentials server-side.
lib/server/settings.ts - Workspace & daily brief · Reuses saved collector state instead of recollecting on navigation.
lib/workspace-store.ts - Collection scheduler · Runs startup, manual, and 15-minute collection.
lib/server/scheduler.ts
Curation pipelines
- Feed & sitemap discovery · Finds feeds, robots/sitemaps, and topic-search candidates.
lib/feed-discovery.ts - Industry curation · Deduplicates, prioritizes, optionally reranks, and bounds the active queue.
lib/industry-curation.ts - Mention research · Search and AI candidates remain untrusted until verified.
lib/server/mention-research.ts - Mention verification · Requires canonical-page evidence before ranking and archival.
lib/server/mention-curation.ts - Newsletter collector · Reads bounded unseen Gmail issues and masks bodies before AI processing.
lib/server/newsletter-collector.ts - Newsletter AI extraction · Extracts, ranks, consolidates events, and stores topic aliases.
lib/server/newsletter-ai.ts
Optional integrations
- AI provider runtime · Selects providers, discovers models, and bounds requests.
lib/server/ai.ts - Audience validation · Validates profiles and stores verified readings.
lib/server/audience.ts - Audience growth analysis · Builds comparable growth and chart data.
lib/audience-growth.ts - Connector bridge · Private automations submit normalized summaries without direct account access.
docs/CONNECTOR_BRIDGE.md - Public web sources · Feeds, sites, search, canonical pages, and public profiles.
- AI providers · Cloud providers or restricted loopback local models.
Connections 32
- Control Center UI → Workspace API: loads state
- Control Center UI → Settings API: updates settings
- Control Center UI → Brief API: reads brief
- Control Center UI → Model discovery API: lists models
- Workspace API → Workspace & daily brief: serves
- Settings API → Settings & secrets: reads/writes
- Brief API → Workspace & daily brief: composes
- Model discovery API → AI provider runtime: discovers
- Google OAuth start → Google OAuth callback: OAuth redirect
- Google OAuth callback → Settings & secrets: stores authorization
- Workspace & daily brief → SQLite content store: saved queues and snapshots
- Collection scheduler → Feed & sitemap discovery: triggers
- Collection scheduler → Mention research: triggers
- Collection scheduler → Newsletter collector: triggers
- Collection scheduler → Audience validation: triggers
- Feed & sitemap discovery → Public web sources: discovers
- Feed & sitemap discovery → Industry curation: raw candidates
- Industry curation → AI provider runtime: optional reranking
- Industry curation → SQLite content store: active queue
- Mention research → Public web sources: searches
- Mention research → Mention verification: candidates
- Mention verification → Public web sources: verifies pages
- Mention verification → SQLite content store: verified mentions
- Newsletter collector → Newsletter AI extraction: masked issues
- Newsletter AI extraction → AI provider runtime: requires extraction
- Newsletter AI extraction → SQLite content store: events and aliases
- AI provider runtime → Settings & secrets: provider selection
- AI provider runtime → AI providers: bounded requests
- Audience validation → Public web sources: validates profiles
- Audience validation → SQLite content store: verified readings
- Audience growth analysis → SQLite content store: reads history
- Brief API → Connector bridge: accepts summaries