We are building an autonomous "Agentic AI" cybersecurity platform that audits APIs for complex Business Logic vulnerabilities (e.g., BOLA, IDOR). Crucially, the system must include a User-Friendly Web Client designed for "non-security guys" (developers, product managers). It must visually map the API workflows and explain vulnerabilities in plain English with actionable, copy-paste code fixes, bridging the gap between deep cybersecurity logic and everyday software development.
- Backend & AI Engine: Python, FastAPI, Pydantic, SQLAlchemy, PostgreSQL, and a custom provider-neutral ReAct loop for LLM orchestration.
- Traffic Capture:
mitmproxyfor live HTTP traffic capture and replay preparation. - Frontend (Web Client): Next.js, React, TypeScript, and React Flow for workflow visualization.
- Styling & Realtime: Custom CSS design system for the dashboard and SSE for live scan updates.
The AI Orchestrator requires "Data Fusion" from 4 sources:
- Live HTTP Traffic (Proxy): Intercepted requests/responses.
- Source Code (White-box): Ingested backend code snippets.
- API Specification: Swagger/OpenAPI docs.
- Knowledge Base: Security rules mapping to OWASP API Top 10.
The client-side dashboard must focus on usability and visualization:
- Interactive Workflow Mapping: A visual, node-based graph (using React Flow) showing how APIs interact. E.g.,
[POST /login]->[GET /user/profile]. The nodes should light up red if the AI detects a logic break in that specific path. - Plain-English Risk Scoring: Instead of complex CVSS metrics, use intuitive health scores (e.g., "Critical: Data Leak Risk", "Safe").
- Developer-Friendly Remediation: Vulnerability reports must explain why it's broken in developer terms and provide direct, copy-paste code patches.
- Scan Trigger & Real-time Logs: A simple button to "Start Audit" and a feed showing what the AI Agent is currently "thinking" and "testing" in real-time.
- Reason: The LLM correlates Swagger docs with live traffic to form hypotheses.
- Act: The Agent calls the Workflow Mapper (which feeds data to the Frontend UI) and the Automated Verifier to generate Python PoC scripts.
- Observe: The system executes the PoC. If successful, it sends the confirmed vulnerability and the auto-patch to the Frontend Dashboard.
Please organize the codebase into this modular full-stack structure:
backend/ai_orchestrator/: The ReAct agent loop.backend/proxy_engine/: Captures traffic and formats it.backend/tools/:semantic_analyzer.pyandverifier.py(PoC execution).backend/api_server/: FastAPI endpoints to serve data to the frontend.frontend_client/: React/Next.js application containing the Dashboard, Workflow Visualizer (React Flow), and Report Viewer.
- OpenCode Integration: Feel free to leverage OpenCode features or relevant open-source libraries (e.g., React Flow, Mitmproxy) to accelerate development.
- If the environment supports it, use code execution/sandbox features to test the backend logic or UI components before finalizing the code.
Based on this context, your first task is to set up the foundational repository structure.
- Initialize the
backendwith a basic FastAPI app. - Initialize the
frontend_client(React) and create a basic layout for the Dashboard that includes a placeholder area for the "API Workflow Visualization" graph. We will implement the LLM ReAct loop and Proxy step-by-step later.