⭐ REPLIT AI AGENT PROMPT — Add API Endpoints + Supabase Client Task: Update my Flask backend to support the Dealer Pulse dashboard. Modify app/main.py (or main.py if that’s where the Flask app is) with the following: 1. Add Supabase Client At the top of the file, after the existing imports, add: import os from supabase import create_client, Client SUPABASE_URL = os.environ.get("SUPABASE_URL") SUPABASE_SERVICE_ROLE_KEY = os.environ.get("SUPABASE_SERVICE_ROLE_KEY") supabase: Client = create_client(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY) 2. Add API Route: /api/monthly-summary from flask import jsonify @app.get("/api/monthly-summary") def api_monthly_summary(): try: res = ( supabase .table("v_retention_pen_monthly_v2") .select( "month_key, contact_rate, reply_rate, retention_pen_pct," " total_contacts, total_replies, drop_off_total" ) .order("month_key", desc=False) .limit(12) .execute() ) data = res.data or [] return jsonify({"data": data}) except Exception as e: print("monthly-summary error:", e) return jsonify({"error": str(e)}), 500 3. Add API Route: /api/retention-pen @app.get("/api/retention-pen") def api_retention_pen(): try: res = ( supabase .table("v_retention_pen_monthly_book") .select( "customer_name, reg, payments_remaining," " payment_month, agreement_number" ) .order("payment_month", desc=False) .limit(200) .execute() ) data = res.data or [] return jsonify({"data": data}) except Exception as e: print("retention-pen error:", e) return jsonify({"error": str(e)}), 500 4. Add API Route: /api/campaigns (temporary stub) from datetime import date @app.get("/api/campaigns") def api_campaigns(): today = date.today().isoformat() data = [ { "campaign_id": 1, "name": "12–9–6–3 Payment Loyalty Sweep", "type": "renewals", "status": "live", "starts_on": today, "ends_on": None, "target_segment": "Customers with 12/9/6/3 payments remaining", "notes": "Focus on like-for-like upgrade with minimal payment change.", }, { "campaign_id": 2, "name": "Service Lane to Showroom", "type": "service", "status": "planned", "starts_on": today, "ends_on": None, "target_segment": "Service customers with finance and equity", "notes": "Triggered from workshop visits – pilot only.", }, { "campaign_id": 3, "name": "Lost Sale Follow-Back", "type": "lost_sale", "status": "planned", "starts_on": today, "ends_on": None, "target_segment": "Prospects who did not purchase in the last 90 days", "notes": "WhatsApp + email re-engagement.", }, ] return jsonify({"data": data}) 5. Restart the Flask server ⸻ Please implement all modifications above, ensuring correct indentation and placement within the Flask file