Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/marketing-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Marketing site and app

Factorize is deployed as two Cloudflare Workers:

- `packages/marketing` owns the public landing page at `https://factorize.sh`. It contains no authenticated APIs or tenant data. Set `APP_ORIGIN` to the app origin so login and Create a Job links always cross to the app.
- `packages/app` owns the authenticated dashboard, OAuth callbacks, API/MCP endpoints, provider webhooks, and job deep links at `https://app.factorize.sh`. Its `/` route is the signed-out login entry point and redirects signed-in users to `/jobs`.

Run the two Workers independently with `npm run dev` and `npm run dev:marketing`. Deploy the complete setup with `npm run deploy`; deploy only the public site with `npm run deploy:marketing`.

Configure the Linear OAuth callback and provider webhooks against the app origin, never the marketing origin. Existing `/jobs/*`, `/api/*`, `/mcp`, `/authorize`, and webhook URLs remain app routes.
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
"workspaces": ["packages/*"],
"scripts": {
"dev": "npm run dev --workspace=factorize",
"dev:marketing": "npm run dev --workspace=factorize-marketing",
"build:css": "npm run build:css --workspace=factorize",
"test": "npm run test --workspaces --if-present",
"check": "npm run check --workspace=factorize && npm run check --workspace=factorize-tail-relay",
"deploy": "npm run deploy:app && npm run deploy:tail-relay",
"check": "npm run check --workspace=factorize && npm run check --workspace=factorize-marketing && npm run check --workspace=factorize-tail-relay",
"deploy": "npm run deploy:marketing && npm run deploy:app && npm run deploy:tail-relay",
"deploy:marketing": "npm run deploy --workspace=factorize-marketing",
"deploy:app": "npm run deploy --workspace=factorize",
"deploy:tail-relay": "npm run deploy --workspace=factorize-tail-relay"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { equalHmac, hmac } from "./crypto";
import { Tenant, TenantV2 } from "./tenant";
import { GitHubInstallationRegistry, GitHubInstallationRegistryV2 } from "./github-registry";
import { createAppJwt, githubHeaders, readSetupState, signSetupState } from "./github";
import { apiKeysSettingsPage, jobDetailPage, jobPage, jobsPage, jobRunPage, landingPage, settingsPage } from "./ui";
import { apiKeysSettingsPage, jobDetailPage, jobPage, jobsPage, jobRunPage, loginPage, settingsPage } from "./ui";
import type { Env } from "./types";
import { ACCESS_SCOPES, accessTokenDigest, issueAccessToken } from "./access-tokens";

Expand Down Expand Up @@ -330,7 +330,7 @@ const render = (page: string, nonce: string) => page.replaceAll("<script>", `<sc

app.get("/", async (c) => {
const session = await owner(c);
return c.html(render(landingPage(session ? { email: session.email } : null), c.get("cspNonce")));
return session ? c.redirect("/jobs") : c.html(render(loginPage(c.env.MARKETING_ORIGIN), c.get("cspNonce")));
});
app.get("/jobs", async (c) => { const session = await owner(c); return session ? c.html(render(jobsPage({ email: session.email }), c.get("cspNonce"))) : c.redirect("/auth/linear"); });
app.get("/jobs/new", async (c) => { const session = await owner(c); return session ? c.html(render(jobPage({ email: session.email }), c.get("cspNonce"))) : c.redirect("/auth/linear"); });
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface Env {
GITHUB_INSTALLATIONS?: DurableObjectNamespace;
ASSETS: Fetcher;
APP_ORIGIN: string;
MARKETING_ORIGIN?: string;
LINEAR_CLIENT_ID: string;
LINEAR_CLIENT_SECRET: string;
LINEAR_OAUTH_SCOPES?: string;
Expand Down
12 changes: 12 additions & 0 deletions packages/app/src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ import { ansiToHtmlBrowserSource } from "./ansi";
type Viewer = { email: string } | null;
const escapeHtml = (value: string) => value.replace(/[&<>"']/g, (char) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[char]!);

/** The app entry point is intentionally separate from the public marketing site. */
export const loginPage = (marketingOrigin = "https://factorize.sh") => `<!doctype html>
<html lang="en" class="bg-stone-50 [color-scheme:light] dark:bg-slate-950 dark:[color-scheme:dark]"><head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Sign in — Factorize</title><link rel="stylesheet" href="/styles.css">
<script>try{const saved=localStorage.getItem('factorize-theme'),dark=saved?saved==='dark':matchMedia('(prefers-color-scheme: dark)').matches;document.documentElement.classList.toggle('dark',dark)}catch{}</script>
</head><body class="flex min-h-[100dvh] flex-col bg-stone-50 text-slate-950 dark:bg-slate-950 dark:text-slate-100"><main class="mx-auto flex w-full max-w-md flex-1 flex-col justify-center px-5 py-16">
<a href="${marketingOrigin}" class="text-center text-lg font-bold tracking-tight">Factorize</a><section class="mt-8 rounded-2xl border border-stone-200 bg-white p-8 shadow-sm dark:border-slate-800 dark:bg-slate-900">
<h1 class="text-2xl font-bold tracking-tight">Sign in to Factorize</h1><p class="mt-2 text-sm text-slate-600 dark:text-slate-400">Manage your software factory and its Jobs.</p>
<a href="/auth/linear" class="mt-8 flex min-h-12 items-center justify-center rounded-xl bg-slate-950 px-4 py-3 text-sm font-semibold text-white dark:bg-white dark:text-slate-950">Continue with Linear</a>
<p class="mt-6 text-center text-xs leading-5 text-slate-500">New here? Sign in to create your workspace. Email, Google, and Linear sign-in can be added as authentication providers without changing your Jobs.</p>
</section></main><footer class="border-t border-stone-200 px-5 py-6 text-center text-sm text-slate-500 dark:border-slate-800">Public site: <a class="underline" href="${marketingOrigin}">factorize.sh</a></footer><script>const root=document.documentElement;const button=document.createElement('button');button.type='button';button.className='fixed right-5 top-5 rounded-lg border px-3 py-2 text-sm';button.textContent=root.classList.contains('dark')?'☀':'☾';button.setAttribute('aria-label','Toggle theme');button.onclick=()=>{root.classList.toggle('dark');button.textContent=root.classList.contains('dark')?'☀':'☾';try{localStorage.setItem('factorize-theme',root.classList.contains('dark')?'dark':'light')}catch{}};document.body.append(button);</script></body></html>`;

const themeScript = `
const themeToggle=document.querySelector('#theme-toggle'),themeIcon=document.querySelector('#theme-icon');
const syncThemeButton=()=>{const dark=document.documentElement.classList.contains('dark');themeIcon.textContent=dark?'☀':'☾';themeToggle.setAttribute('aria-label',dark?'Use light mode':'Use dark mode')};
Expand Down
1 change: 1 addition & 0 deletions packages/app/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"vars": {
"APP_ORIGIN": "https://app.factorize.sh",
"MARKETING_ORIGIN": "https://factorize.sh",
"LINEAR_OAUTH_SCOPES": "read,write"
}
}
13 changes: 13 additions & 0 deletions packages/marketing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "factorize-marketing",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "wrangler dev",
"check": "tsc --noEmit && wrangler deploy --dry-run",
"deploy": "wrangler deploy"
},
"dependencies": { "hono": "^4.11.4" },
"devDependencies": { "@cloudflare/workers-types": "^5.20260910.1", "typescript": "^5.9.3", "wrangler": "^4.44.0" }
}
1 change: 1 addition & 0 deletions packages/marketing/public/bee-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/marketing/public/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions packages/marketing/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Hono } from "hono";

type Bindings = { ASSETS: Fetcher; APP_ORIGIN: string };
const app = new Hono<{ Bindings: Bindings }>();

app.use("*", async (c, next) => {
await next();
c.header("Content-Security-Policy", "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; base-uri 'none'; frame-ancestors 'none'; form-action 'self'");
c.header("Referrer-Policy", "strict-origin-when-cross-origin");
c.header("X-Content-Type-Options", "nosniff");
c.header("X-Frame-Options", "DENY");
});

const page = (appOrigin: string) => `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Factorize: Software Factories for Everybody</title><link rel="stylesheet" href="/styles.css"><link rel="icon" href="/bee-mark.svg"></head><body><header><nav><a class="brand" href="/">🐝 Factorize</a><a class="login" href="${appOrigin}/">Log in</a></nav></header><main>
<p class="eyebrow">Linear → Exe.dev → Herdr</p><h1>No-code Software Factories</h1><p class="lede">Create a multiplayer software factory with <a href="https://linear.app/">Linear</a>, <a href="https://exe.dev/">Exe.dev</a> and <a href="https://herdr.dev/">Herdr</a>.</p><div class="actions"><a class="primary" href="${appOrigin}/">Create a Job</a><a class="secondary" href="https://github.com/GenerationSoftware/factorize">Host it Yourself</a></div>
<section><p class="eyebrow">How it works</p><h2>Choose when to fully automate</h2><p>Factorize routes Linear issues to your coding agent of choice running on your exe.dev VM.</p><ol><li><b>Plan work in Linear</b><span>Define bugs, features, and product work as Linear issues.</span></li><li><b>Issues are routed to agents</b><span>Factorize listens to Linear and sends issues to agents on your VM.</span></li><li><b>Watch, guide, or take over</b><span>Connect to the VM and steer agents together with your colleagues.</span></li></ol></section></main><footer>Open-source software factories for everybody. · <a href="https://github.com/GenerationSoftware/factorize">View on GitHub</a></footer></body></html>`;

app.get("/", (c) => c.html(page(c.env.APP_ORIGIN)));
app.get("/health", (c) => c.json({ ok: true }));
app.all("*", (c) => c.env.ASSETS.fetch(c.req.raw));
export default app;
4 changes: 4 additions & 0 deletions packages/marketing/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"compilerOptions": { "target": "ES2022", "module": "ESNext", "moduleResolution": "Bundler", "lib": ["ES2022"], "strict": true, "skipLibCheck": true, "types": ["@cloudflare/workers-types"], "noEmit": true },
"include": ["src/**/*.ts"]
}
8 changes: 8 additions & 0 deletions packages/marketing/wrangler.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "../../node_modules/wrangler/config-schema.json",
"name": "factorize-marketing",
"main": "src/index.ts",
"compatibility_date": "2026-09-10",
"assets": { "directory": "./public", "binding": "ASSETS" },
"vars": { "APP_ORIGIN": "https://app.factorize.sh" }
}