Skip to main content
Architecture

System architecture

How the engine works under the hood — from research to distribution — and where the safety rails live.

Five specialist agents, one engine

MarquIQ is not a single LLM behind a pretty UI. It is a pipeline of five specialist agents — each with its own prompt, memory, and rate limits — composed through a durable job queue. No agent can skip the queue. No agent can double-post. Every action lands in the decision feed at /agent.

  1. 1

    Research agent

    Scans Reddit, HN, Dev.to, X, Mastodon, Bluesky, and your RSS sources every few minutes. Scores each opportunity for relevance + freshness. Drops the keepers into the writer's queue.

  2. 2

    Writer agent

    Drafts platform-specific variants in your brand voice. Pulls evidence from your product graph + source context. Never hallucinates a feature you do not ship.

  3. 3

    Distributor

    Owns the outbound channel. Dedupes across platforms, enforces idempotency keys, respects per-platform rate limits, and holds the OAuth tokens behind a KEK→DEK envelope.

  4. 4

    Reply guy

    Polls each connected platform for replies, DMs, and mentions. Routes the high-signal ones to /inbox with a pre-drafted response. The low-signal ones get auto-liked or archived.

  5. 5

    Attribution agent

    Closes the loop. Watches UTM-tagged click-throughs, matches posts to outcomes, retires topic clusters that are underperforming, and retunes confidence weights weekly.

Data plane

Everything is multi-tenant at the Postgres row level. Every model has an org_id column and every query filters on it. There is no global cache, no shared queue, no "noisy neighbor" path.

  • Postgres — primary store for products, content, distribution tasks, inbox items, automations, leads, and the decision log.
  • Redis — rate limiter state, short-lived idempotency keys, and Celery broker.
  • Celery — durable background jobs. Six queues: distribution, engagement, health, intelligence, reports, analytics.
  • Object storage — media assets. Pluggable (local disk → S3/R2 with no code changes, only env vars).

Safety rails

What the engine will not do

It will not auto-post to Reddit. Reddit is permanently forced to full-review mode because the downside of a bad post there is a sitewide ban. It will not post twice within a platform rate-limit window. It will not draft against a product URL it has not been able to fetch. It will not dispatch a distribution task that is missing an idempotency key.

Request flow

Every authenticated request carries a bearer JWT and an X-Org-Id header. The auth middleware loads the user, verifies org membership, and attaches both to the request context. Write endpoints are rate-limited per org. Read endpoints are aggressively cached at the Redis layer with 60-second TTLs for summary endpoints.

Where to look

  • /agent — live decision feed (last 20 agent actions).
  • /queue — drafts awaiting approval, grouped by confidence.
  • /automations — scheduled + event-triggered jobs, with next-run times.
  • /analytics — attribution closure rate, confidence calibration.