Cadence.doc - WordPadケーススタディ
← Back to projects もどる
Cadence

Cadence

A team workspace for scheduling social posts and publishing them through background jobs that retry when a platform fails

Team

Solo project

My role

Full-Stack Engineering

System Design

Tools

TypeScript

Next.js

NestJS

MongoDB

Redis + BullMQ

Duration

In progress

Overview

Cadence lets a team write posts together, schedule them, and have them published automatically by a background worker that retries when a platform fails. Every attempt is logged, and the dashboard shows each post's status live. Social platforms are mocked in the MVP.

Problem

Small teams that post to social media usually work out of a shared doc and someone's phone, which breaks down in predictable ways:

Drafts spread across a doc, a chat thread, a notes app and a phone

No shared workflow

Drafts live in different places, with no clear rule for who can edit or publish.

A scheduled post hits a rate limit and never reaches the platform

Unreliable publishing

If a platform is down or rate-limits at the scheduled time, the post silently doesn't go out.

No visibility

Nobody can see what's scheduled, what failed, or why without checking each platform by hand.

Goals

The MVP proves a team can schedule posts and trust that they'll publish, or see exactly why they didn't. Real platform integrations, post analytics, and billing are out of scope.

Roles

One workspace, clear permissions

Acme marketing · 3 members

DLDonnaOwner
JKJamieEditor
RSRileyViewer

Background worker

Posts publish from a queue, not the API

Launch teaser · 9:00

8:59Job queuedQueue
9:00Worker picked it upWorker
9:00Sent to platformSent

Retries

Failures retry with backoff

Max 5 attempts

Try 1429 rate limitedFailed
Try 2Waited 2s, 503Failed
Try 3Waited 4sPublished

Audit log

Every attempt is on record

9:00:00Attempt 1 · 429
9:00:02Attempt 2 · 503
9:00:06Attempt 3 · 200 OK
9:00:06Marked published by worker

Live status

The dashboard updates on its own

Today

9:00Launch teaserPublished
12:00Customer storyRetrying
15:30Event recapScheduled

Users

The primary user is a content editor on a small marketing team who writes and schedules posts. The workspace owner invites teammates, sets roles, and connects social accounts. Viewers, such as a manager or client, only need to see the schedule and each post's status.

Requirements

The core requirements for the MVP:

  • Short-lived JWT access tokens with rotating refresh tokens; reusing an old refresh token revokes the whole token family.
  • Every API route checks the caller's role in the target workspace.
  • Scheduling a post adds a delayed job; rescheduling replaces it and cancelling removes it.
  • Failed publishes retry with exponential backoff, and every attempt is written to an audit log.
  • Publishing is idempotent, so a retried job never posts the same content twice.
  • The dashboard receives status changes over WebSocket.
dn=d0⋅2 n−1,n=1,…,Nd_n = d_0 \cdot 2^{\,n-1}, \qquad n = 1, \dots, N
Exponential backoff between publish attempts. The base delay and the attempt limit N are still open questions.

Architecture

A Next.js dashboard talks to a NestJS API over REST and WebSocket. The API stores data in MongoDB and adds delayed jobs to a BullMQ queue in Redis. A separate worker process, built from the same codebase, picks up each job, calls the platform, updates the post, and emits a status event. Because the API and worker scale and restart independently, a slow platform never blocks API requests, and Redis runs with append-only persistence so queued jobs survive a restart. A post moves from draft to scheduled to publishing, then to published, or through retrying to failed once its attempts run out.

A post moves from the dashboard through the API into the Redis queue, and the worker publishes it. A failed attempt (red) goes back to the queue with backoff.Next.js appNestJS APIMongoDBRedis queuePublish workerPlatform
A post moves from the dashboard through the API into the Redis queue, and the worker publishes it. A failed attempt (red) goes back to the queue with backoff.

Success metrics

Proposed targets: 99% of posts start publishing within 5 seconds of their scheduled time, every post recovers when a platform fails fewer times than the retry limit, zero duplicate publishes across retries and worker restarts, and the dashboard reflects a status change in under 2 seconds.

Pr⁡ ⁣(tfirst attempt−tscheduled≤5 s)  ≥  0.99\Pr\!\left(t_{\text{first attempt}} - t_{\text{scheduled}} \leq 5\,\text{s}\right) \;\geq\; 0.99
Proposed on-time publish target.

Risks

The biggest risk is a post that publishes twice or not at all without anyone noticing. A worker crash after the platform call can cause a duplicate, so each attempt carries an idempotency key. Using the post id as the job id keeps jobs in sync with edits, and a sweeper re-queues any overdue posts if Redis loses a job.

Next steps

The foundation is done: the monorepo, Docker setup, health checks across MongoDB, Redis, and the queue, a separate worker process, and the web app. Next come auth, workspaces and roles, mock accounts and posts, then scheduling with retries, the live dashboard, media uploads, and deploy.

Ready 準備完了9 sections