instructSite

byDarren Hopwood

import os from fastapi import FastAPI, File, UploadFile, HTTPException from fastapi.middleware.cors import CORSMiddleware from pydantic import BaseModel from supabase import create_client, Client app = FastAPI(title="instructBrain™ AI Engine", version="1.0.0") # Enable Cross-Origin Resource Sharing (CORS) so your Lovable frontend can talk to it safely app.add_middleware( CORSMiddleware, allow_origins=["*"], # In production, restrict this to your Lovable deployment URL allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Initialize Supabase Client Connection SUPABASE_URL = os.getenv("SUPABASE_URL") SUPABASE_KEY = os.getenv("SUPABASE_SERVICE_ROLE_KEY") # Use service role key to bypass RLS limits during testing if not SUPABASE_URL or not SUPABASE_KEY: raise RuntimeError("Missing Supabase configuration environment variables.") supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY) class AnalysisRequest(BaseModel): project_id: str drawing_name: str @app.get("/") def read_root(): return {"status": "online", "engine": "instructBrain v1.0.0"} @app.post("/api/v1/analyze-blueprint") async def analyze_blueprint(project_id: str, drawing_name: str, file: UploadFile = File(...)): """ Accepts an architectural drawing PDF, runs text/vector extraction, matches rules from Supabase, and inserts found scope gaps. """ try: # Read raw binary data from uploaded file pdf_bytes = await file.read() # TODO: Insert Phase 2 extraction logic here (PyMuPDF parser) return { "success": True, "message": f"Successfully initialized parsing for {drawing_name}", "bytes_received": len(pdf_bytes) } except Exception as e: raise HTTPException(status_code=500, detail=str(e))

LandingLoginDashboardAnalysisSignupSettingsResultsHomeUploadsRulesUploadScopeGaps
Landing

Comments (0)

No comments yet. Be the first!

Landing design preview
Landing: View Platform
Login: Sign In
Dashboard: View Overview
Dashboard: Review Conflicts
ScopeGaps: View Flagged Items
ScopeGaps: Update Status
Rules: Manage Keywords
Rules: Edit Templates
Settings: Configure System
Settings: Set Severities
Uploads: Monitor Analyses