Initial commit — Sistema Generador de Guiones V4.0

Pipeline completo: URL → Whisper → GPT-4o → pgvector → Supabase
Frontend Vue 3 + Tailwind, Backend Express + Vercel serverless functions
This commit is contained in:
2026-03-28 16:02:59 -05:00
commit 7695dd0be6
47 changed files with 7552 additions and 0 deletions

1
api/analizar.js Normal file
View File

@ -0,0 +1 @@
export { default } from '../backend/api/analizar.js'

14
api/clientes.js Normal file
View File

@ -0,0 +1,14 @@
import { supabase } from '../backend/lib/supabase.js'
export default async function handler(req, res) {
if (req.method !== 'GET') return res.status(405).json({ error: 'Método no permitido' })
const { data, error } = await supabase
.from('clientes')
.select('id, nombre, industria')
.eq('activo', true)
.order('nombre')
if (error) return res.status(500).json({ error: error.message })
res.json(data)
}

30
api/guiones.js Normal file
View File

@ -0,0 +1,30 @@
import { supabase } from '../backend/lib/supabase.js'
export default async function handler(req, res) {
if (req.method !== 'GET') return res.status(405).json({ error: 'Método no permitido' })
const { niche, cliente_id, plataforma, page = 1, limit = 20 } = req.query
const offset = (Number(page) - 1) * Number(limit)
let query = supabase
.from('guiones')
.select(`
id, niche, sub_niche, plataforma, url_origen,
gancho_texto, gancho_tipo, estructura_narrativa, trigger_emocional,
tono, score_engagement, score_virabilidad, score_cialdini,
fecha_analisis, procesado_ok, vistas, likes, compartidos,
tema_principal, resumen_patron
`, { count: 'exact' })
.eq('procesado_ok', true)
.order('fecha_analisis', { ascending: false })
.range(offset, offset + Number(limit) - 1)
if (niche) query = query.eq('niche', niche)
if (cliente_id) query = query.eq('cliente_id', cliente_id)
if (plataforma) query = query.eq('plataforma', plataforma)
const { data, error, count } = await query
if (error) return res.status(500).json({ error: error.message })
res.json({ guiones: data, total: count, page: Number(page), limit: Number(limit) })
}

16
api/guiones/[id].js Normal file
View File

@ -0,0 +1,16 @@
import { supabase } from '../../backend/lib/supabase.js'
export default async function handler(req, res) {
if (req.method !== 'GET') return res.status(405).json({ error: 'Método no permitido' })
const { id } = req.query
const { data, error } = await supabase
.from('guiones')
.select('*')
.eq('id', id)
.single()
if (error) return res.status(404).json({ error: 'Guion no encontrado' })
res.json(data)
}

15
api/nichos.js Normal file
View File

@ -0,0 +1,15 @@
import { supabase } from '../backend/lib/supabase.js'
export default async function handler(req, res) {
if (req.method !== 'GET') return res.status(405).json({ error: 'Método no permitido' })
const { data, error } = await supabase
.from('guiones')
.select('niche')
.eq('procesado_ok', true)
if (error) return res.status(500).json({ error: error.message })
const nichos = [...new Set(data.map(r => r.niche))].sort()
res.json(nichos)
}

12
api/stats.js Normal file
View File

@ -0,0 +1,12 @@
import { supabase } from '../backend/lib/supabase.js'
export default async function handler(req, res) {
if (req.method !== 'GET') return res.status(405).json({ error: 'Método no permitido' })
const { data, error } = await supabase
.from('vista_resumen_nichos')
.select('*')
if (error) return res.status(500).json({ error: error.message })
res.json(data)
}