feat: add multi-app support with app switcher, per-app branding, and filtered queries
Apps share the same backend, API keys, and publishing flow but each gets its own branding (name, colors, icon, app URL), knowledge files (brand identity, product info, platform guidelines), and campaigns. The pipeline dynamically writes _knowledge/ files and copies app assets before each run. - Add App model with slug, colors, appUrl, and knowledge markdown fields - Add appId FK to Campaign, seed honeyDue as first app with existing knowledge - App switcher dropdown in sidebar with icon previews - Filter campaigns, stats, and assets by active app (cookie-based) - De-hardcode lib/claude.ts: AppConfig interface, templated prompts, dynamic _knowledge/ and Remotion asset copying - App management pages (list, create, edit) with icon upload and color pickers - Asset library sort options (newest, oldest, name, platform, type) - Asset cards show creation date - Remotion HoneyDueAd accepts colors/appName props Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { auth } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { buildCampaignPrompt, launchPipeline } from "@/lib/claude";
|
||||
import { buildCampaignPrompt, launchPipeline, type AppConfig } from "@/lib/claude";
|
||||
import path from "path";
|
||||
import { mkdirSync } from "fs";
|
||||
|
||||
@@ -13,7 +13,10 @@ export async function POST(
|
||||
|
||||
const { id } = await params;
|
||||
|
||||
const campaign = await prisma.campaign.findUnique({ where: { id } });
|
||||
const campaign = await prisma.campaign.findUnique({
|
||||
where: { id },
|
||||
include: { app: true },
|
||||
});
|
||||
if (!campaign) {
|
||||
return Response.json({ error: "Not found" }, { status: 404 });
|
||||
}
|
||||
@@ -25,6 +28,23 @@ export async function POST(
|
||||
);
|
||||
}
|
||||
|
||||
// Build AppConfig from the campaign's app
|
||||
let appConfig: AppConfig | undefined;
|
||||
if (campaign.app) {
|
||||
const app = campaign.app;
|
||||
appConfig = {
|
||||
name: app.name,
|
||||
slug: app.slug,
|
||||
primaryColor: app.primaryColor,
|
||||
accentColor: app.accentColor,
|
||||
darkBg: app.darkBg,
|
||||
assetsDir: `apps/${app.slug}`,
|
||||
brandIdentity: app.brandIdentity,
|
||||
productInfo: app.productInfo,
|
||||
platformGuidelines: app.platformGuidelines,
|
||||
};
|
||||
}
|
||||
|
||||
const config = campaign.config ? JSON.parse(campaign.config) : {};
|
||||
const pipelineRoot =
|
||||
process.env.PIPELINE_ROOT || path.join(process.cwd(), "pipeline");
|
||||
@@ -39,19 +59,22 @@ export async function POST(
|
||||
mkdirSync(path.join(pipelineRoot, outputPath, dir), { recursive: true });
|
||||
}
|
||||
|
||||
const prompt = buildCampaignPrompt({
|
||||
name: campaign.name,
|
||||
platforms: JSON.parse(campaign.platforms),
|
||||
goal: config.goal || "brand awareness",
|
||||
keyMessage: config.keyMessage || campaign.name,
|
||||
socialProof: config.socialProof,
|
||||
targetAudience: config.targetAudience,
|
||||
visualDirection: config.visualDirection,
|
||||
competitorApps: config.competitorApps,
|
||||
variations: config.variations,
|
||||
useTrendReport: config.useTrendReport,
|
||||
screenshots: config.screenshots,
|
||||
});
|
||||
const prompt = buildCampaignPrompt(
|
||||
{
|
||||
name: campaign.name,
|
||||
platforms: JSON.parse(campaign.platforms),
|
||||
goal: config.goal || "brand awareness",
|
||||
keyMessage: config.keyMessage || campaign.name,
|
||||
socialProof: config.socialProof,
|
||||
targetAudience: config.targetAudience,
|
||||
visualDirection: config.visualDirection,
|
||||
competitorApps: config.competitorApps,
|
||||
variations: config.variations,
|
||||
useTrendReport: config.useTrendReport,
|
||||
screenshots: config.screenshots,
|
||||
},
|
||||
appConfig
|
||||
);
|
||||
|
||||
await prisma.campaign.update({
|
||||
where: { id },
|
||||
@@ -59,7 +82,7 @@ export async function POST(
|
||||
});
|
||||
|
||||
// Launch pipeline asynchronously — don't await
|
||||
launchPipeline(id, prompt, pipelineRoot).catch((err) =>
|
||||
launchPipeline(id, prompt, pipelineRoot, appConfig).catch((err) =>
|
||||
console.error(`Pipeline failed for campaign ${id}:`, err)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user