feat: add use cases marketing product with AI-generated content

Transform qualifying scenarios into marketing-ready use cases with:
- AI-generated titles, descriptions, ROI estimates, business value
- Persona/industry/category taxonomy for targeting
- Browseable feed with filtering and ranking
- SEO-optimized case study pages
- Daily cron job for generation and ranking

Database:
- Add Persona, Industry, Category lookup tables
- Add UseCase model with marketing content fields
- Add junction tables for personas/industries/categories
- Add SocialProof model for cached metrics

API:
- GET /api/use-cases - Global directory with filtering
- GET /api/use-cases/[id] - Individual use case details
- GET /api/public/users/[username]/collections/[slug]/use-cases
- POST /api/cron/use-cases - Nightly generation job

Frontend:
- /use-cases - Global feed with persona dropdown
- /use-cases/[slug] - SEO case study page
- /[username]/collections/[slug]/use-cases - Collection feed
- UseCasesFeed component - Sortable table component
- UseCaseCaseStudy component - Full case study layout
This commit is contained in:
Ajax Davis 2026-01-20 16:17:35 +10:00
parent 5fafc90e3e
commit 48c41e8733
245 changed files with 4734 additions and 2075 deletions

View file

@ -3,11 +3,10 @@
* Securely executes npm packages using isolated-vm
*/
import { execSync } from 'child_process';
import { existsSync, mkdirSync } from 'fs';
import { join } from 'path';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { execSync } from 'node:child_process';
import { existsSync, mkdirSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import cors from 'cors';
import express from 'express';
import ivm from 'isolated-vm';
@ -34,7 +33,7 @@ app.use(express.json({ limit: '1mb' }));
/**
* Health check endpoint
*/
app.get('/health', (req, res) => {
app.get('/health', (_req, res) => {
res.json({
status: 'healthy',
service: 'tpmjs-sandbox-executor',
@ -72,7 +71,7 @@ app.post('/execute', async (req, res) => {
await jail.set('global', jail.derefInto());
// Create console mock that captures logs
const logs = [];
const _logs = [];
const consoleObject = await isolate.compileScript(`
({
log: (...args) => { logs.push(args.join(' ')); },
@ -84,7 +83,7 @@ app.post('/execute', async (req, res) => {
await jail.set('logs', []);
// Build execution code
const code = `
const _code = `
(async function() {
try {
// Dynamic import is not available in isolated-vm
@ -111,7 +110,9 @@ app.post('/execute', async (req, res) => {
pkg = await import(packagePath);
} catch {
// Fallback to require for CommonJS
pkg = await import('module').then((m) => m.createRequire(import.meta.url)(packagePath));
pkg = await import('node:module').then((m) =>
m.createRequire(import.meta.url)(packagePath)
);
}
const fn = typeof pkg === 'function' ? pkg : pkg[functionName] || pkg.default;
@ -146,7 +147,7 @@ app.post('/execute', async (req, res) => {
/**
* Clear package cache endpoint
*/
app.post('/cache/clear', async (req, res) => {
app.post('/cache/clear', async (_req, res) => {
try {
if (existsSync(CACHE_DIR)) {
execSync(`rm -rf ${CACHE_DIR}`, { stdio: 'ignore' });