Track A (Infrastructure & Data Layer): - docker-compose.yml with all 7 services (nginx, frontend, api, mcp, renderer, worker, postgres, redis) - docker-compose.override.yml for local dev (hot reload, port exposure) - PostgreSQL init.sql with full schema (15 tables, pgvector indexes, creator economy stubs) - .env.example with all required environment variables Track A+B (API Layer): - FastAPI app with 10 routers (auth, shaders, feed, votes, generate, desires, users, payments, mcp_keys, health) - SQLAlchemy ORM models for all 15 tables - Pydantic schemas for all request/response types - JWT auth middleware (access + refresh tokens, Redis blocklist) - Redis rate limiting middleware - Celery worker config with job stubs (render, embed, generate, feed cache, expire bounties) - Alembic migration framework Service stubs: - MCP server (health endpoint, 501 for all tools) - Renderer service (Express + Puppeteer scaffold, 501 for /render) - Frontend (package.json with React/Vite/Three.js/TanStack/Tailwind deps) - Nginx reverse proxy config (/, /api, /mcp, /renders) Project: - DECISIONS.md with 11 recorded architectural decisions - README.md with architecture overview - Sample shader seed data (plasma, fractal noise, raymarched sphere)
58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
/**
|
|
* Fractafrag Renderer — Headless Chromium shader render service.
|
|
*
|
|
* Accepts GLSL code via POST /render, renders in an isolated browser context,
|
|
* returns thumbnail + preview video.
|
|
*
|
|
* Full implementation in Track C.
|
|
*/
|
|
|
|
import express from 'express';
|
|
import { writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
import path from 'path';
|
|
|
|
const app = express();
|
|
app.use(express.json({ limit: '1mb' }));
|
|
|
|
const PORT = 3100;
|
|
const OUTPUT_DIR = process.env.OUTPUT_DIR || '/renders';
|
|
const MAX_DURATION = parseInt(process.env.MAX_RENDER_DURATION || '8', 10);
|
|
|
|
// Ensure output directory exists
|
|
if (!existsSync(OUTPUT_DIR)) {
|
|
mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
}
|
|
|
|
// Health check
|
|
app.get('/health', (req, res) => {
|
|
res.json({ status: 'ok', service: 'renderer' });
|
|
});
|
|
|
|
// Render endpoint (stub — Track C)
|
|
app.post('/render', async (req, res) => {
|
|
const { glsl, duration = 5, width = 640, height = 360, fps = 30 } = req.body;
|
|
|
|
if (!glsl) {
|
|
return res.status(400).json({ error: 'Missing glsl field' });
|
|
}
|
|
|
|
// TODO: Track C implementation
|
|
// 1. Launch Puppeteer page
|
|
// 2. Inject GLSL into shader template HTML
|
|
// 3. Capture frames for `duration` seconds
|
|
// 4. Encode to WebM/MP4 + extract thumbnail
|
|
// 5. Write to OUTPUT_DIR
|
|
// 6. Return URLs
|
|
|
|
res.status(501).json({
|
|
error: 'Renderer implementation coming in Track C',
|
|
thumbnail_url: null,
|
|
preview_url: null,
|
|
});
|
|
});
|
|
|
|
app.listen(PORT, '0.0.0.0', () => {
|
|
console.log(`Renderer service listening on :${PORT}`);
|
|
console.log(`Output dir: ${OUTPUT_DIR}`);
|
|
console.log(`Max render duration: ${MAX_DURATION}s`);
|
|
});
|