DEV Community

Quiet Stack Lab
Quiet Stack Lab

Posted on

Deterministic 4-Axis Archetype Matching & Zero-Backend Co-Builder Synergy in Pure Browser JS

Interactive diagnostics and calculators are some of the highest-retention micro-tools you can build on the web — yet most implementations still spin up a backend database, auth wall, or LLM endpoint just to map 8 multiple-choice answers to a result card.

When we built CashCode 2027 (a 45-second side-income archetype diagnostic + unit-economics estimator), we set three hard engineering constraints:

  1. Zero backend, zero signup, zero API cost — 100% static ES modules running in the browser.
  2. All 8 archetypes guaranteed reachable — no dead centroids where 70% of users fall into the same two buckets.
  3. Stateless 2-person comparison links — two people should be able to score co-builder synergy with a plain URL parameter (?c=<archetypeId>) and zero server storage.

Here is the exact scoring, synergy, and privacy architecture we shipped in pure JavaScript.


1. Normalizing 8 Answers onto 4 Orthogonal Axes

Instead of using brittle if/else decision trees (which explode combinatorially and create unreachable branches), every answer option applies small integer deltas across four axes:

  • build — Asset Building (shipping reusable products/templates/code)
  • speed — Cash Velocity (time to first dollar)
  • audience — Audience Pull (organic distribution & content leverage)
  • leverage — Scalable Leverage (decoupling income from billable hours)
export function evaluateAnswers(answersMap) {
  const totals = { build: 0, speed: 0, audience: 0, leverage: 0 };
  let hours = 8;
  let skill = "systems";
  let trap = "perfection";

  for (const q of QUESTIONS) {
    const chosenId = answersMap[q.id];
    const opt = q.options.find((o) => o.id === chosenId) || q.options[0];
    if (opt.scores) {
      totals.build += opt.scores.build || 0;
      totals.speed += opt.scores.speed || 0;
      totals.audience += opt.scores.audience || 0;
      totals.leverage += opt.scores.leverage || 0;
    }
    if (opt.hours) hours = opt.hours;
    if (opt.skill) skill = opt.skill;
    if (opt.trap) trap = opt.trap;
  }

  const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
  const userAxes = {
    build: clamp(Math.round(52 + totals.build * 4.6), 12, 98),
    speed: clamp(Math.round(52 + totals.speed * 5.0), 12, 98),
    audience: clamp(Math.round(50 + totals.audience * 5.2), 12, 98),
    leverage: clamp(Math.round(52 + totals.leverage * 4.5), 18, 98),
  };
Enter fullscreen mode Exit fullscreen mode

Centering each axis around 50–52 with a clamped [12, 98] range prevents radar charts and progress bars from pinning at ugly 0% or 100% extremes while preserving meaningful separation.


2. Weighted Euclidean Nearest-Archetype Matching

Once the user sits at a 4D coordinate (build, speed, audience, leverage), we compute weighted Euclidean distance against all 8 archetype centroids:

  let best = ARCHETYPES[0];
  let bestDist = Infinity;
  for (const arch of ARCHETYPES) {
    const db = (userAxes.build - arch.axes.build) * 1.15;
    const ds = (userAxes.speed - arch.axes.speed) * 1.1;
    const da = (userAxes.audience - arch.axes.audience) * 1.15;
    const dl = (userAxes.leverage - arch.axes.leverage) * 0.9;
    const dist = Math.sqrt(db * db + ds * ds + da * da + dl * dl);
    if (dist < bestDist) {
      bestDist = dist;
      best = arch;
    }
  }
Enter fullscreen mode Exit fullscreen mode

Why weight the axes (1.15 / 1.10 / 1.15 / 0.90)?

In practice, leverage correlates mildly with both build and audience. Giving build and audience a 1.15× weight while nudging leverage down to 0.90× keeps builder-heavy archetypes cleanly separated from distribution-heavy archetypes.

Before shipping, we ran an exhaustive Cartesian check across question answer combinations to verify every single archetype is reachable and no centroid acts as a black hole.


3. Grounding the 90-Day Ceiling Band in Weekly Hours

One reason side-hustle calculators feel fake is static, disconnected revenue claims. Instead, we scale the 90-day monthly ceiling directly from the user's stated weekly commitment (hours) and the matched archetype's leverage multiplier, then round to clean $50 / $100 increments so the UI never displays bogus precision like $1,347.82:

  const baseLow = Math.round((hours * 75 * best.multiplier) / 50) * 50;
  const baseHigh = Math.round((hours * 165 * best.multiplier) / 100) * 100;
  const leverageIndex = clamp(
    Math.round(
      userAxes.build * 0.28 +
      userAxes.leverage * 0.37 +
      userAxes.audience * 0.18 +
      userAxes.speed * 0.17
    ),
    42,
    98
  );

  return {
    archetype: best,
    userAxes,
    hours,
    leverageIndex,
    monthlyBandUsd: { low: Math.max(400, baseLow), high: Math.max(1100, baseHigh) },
  };
Enter fullscreen mode Exit fullscreen mode

4. Stateless 2-Person Co-Builder Synergy via URL Query Params

Most "compare with a friend" viral loops store session rows in Postgres or Redis. You don't need a database at all if the archetype ID itself is a compact slug (e.g. ?c=midnight-curator):

export function computeSynergy(archIdA, archIdB) {
  const a = ARCHETYPES.find((x) => x.id === archIdA) || ARCHETYPES[0];
  const b = ARCHETYPES.find((x) => x.id === archIdB) || ARCHETYPES[1];

  if (a.id === b.id) {
    return {
      score: 76,
      titleEn: "Mirror Operators — Fast Alignment, Watch Distribution Blindspot",
      descEn: "Split ownership strictly: one person owns shipping, the other owns weekly distribution & outreach.",
    };
  }

  const isBestPair = a.synergyBest.includes(b.id) || b.synergyBest.includes(a.id);
  const compBuild = Math.abs(a.axes.build - b.axes.build);
  const compAud = Math.abs(a.axes.audience - b.axes.audience);
  const rawScore = isBestPair
    ? 92 + ((compBuild + compAud) % 7)
    : 78 + Math.min(13, Math.round((compBuild + compAud) / 11));

  const builder = a.axes.build >= b.axes.build ? a : b;
  const grower = a.axes.audience >= b.axes.audience ? a : b;

  return {
    score: Math.min(99, rawScore),
    titleEn: isBestPair ? "Powerhouse Co-Build Pair (Top 8% Synergy)" : "Balanced Side-Hustle Duo",
    descEn: `${builder.en.name} ships the core asset in 48h while ${grower.en.name} drives traffic and closing.`,
  };
}
Enter fullscreen mode Exit fullscreen mode

Notice the product detail hidden inside that math: identical archetypes only score 76% ("Mirror Operators"), whereas complementary build vs audience gaps score up to 99%. That mirrors real-world solo/duo execution — two builders with zero distribution rarely ship revenue as fast as one builder paired with one distributor.


5. Privacy-Safe Canvas Exports Drive Organic Shares

People love sharing archetypes, but they will never screenshot a personal finance tool if it exposes their current salary or bank balance. When rendering the 9:16 Story PNG (1080×1920) and 16:9 social PNG directly on HTML5 <canvas>, we intentionally omit all sensitive personal inputs and render only:

  • Archetype title + code
  • 4-axis DNA bars
  • 90-day ceiling band + #1 money-leak trap

Everything runs client-side in <15ms — nothing leaves the browser tab.


Try It Live (Free, No Signup)

If you've built deterministic scoring engines or URL-stateless comparison loops in pure JS, how do you test centroid reachability across question sets? Drop your approach below!

Top comments (0)