import { NextResponse } from 'next/server' export async function POST(request) { try { const { symbol, timeframes } = await request.json(); console.log('🔍 Getting REAL automated analysis for:', symbol, 'timeframes:', timeframes); // Get REAL analysis from enhanced screenshot system const screenshotResponse = await fetch(`${process.env.APP_URL || 'http://localhost:3000'}/api/enhanced-screenshot`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ symbol, timeframes, layouts: ['ai', 'diy'], analyze: true }) }); if (!screenshotResponse.ok) { throw new Error('Failed to get real analysis'); } const analysisData = await screenshotResponse.json(); if (!analysisData.success) { throw new Error(analysisData.error || 'Analysis failed'); } return NextResponse.json({ success: true, analysis: analysisData.analysis, screenshots: analysisData.screenshots, timeframes: timeframes, source: 'REAL_SCREENSHOT_ANALYSIS' }); } catch (error) { console.error('Error in automated analysis:', error); return NextResponse.json({ success: false, error: error.message }, { status: 500 }); } } export async function GET() { return NextResponse.json({ message: 'AI Analysis endpoint - Use POST to perform analysis', supportedActions: ['capture_and_analyze', 'capture_multiple'], requiredFields: ['symbol', 'timeframe', 'action'], optionalFields: ['credentials'] }) }