I designed AivulnHunter’s system architecture as a layered stack that cleanly separates UI, API, security pre‑execution, autonomous agents, learning, and persistence.
- Frontend Layer: Next.js 15 + Tailwind CSS – Dashboard & Scan Controls (page.tsx, ScanModal.tsx), WebSocket client (websocket.ts), AI Security Assistant UI (AiAssistant.tsx).
- Backend API Layer: FastAPI ASGI service exposing /api/v1/scans, /auth, /assistant, /ws; secured by JWT & RBAC (bcrypt + AdminGuard); includes WebSocket Connection Manager (ws_manager.py).
- Pre‑Execution Defense: AI Firewall & Sanitizer (ai_firewall.py) sanitizes target and payload before any agent runs.
- Autonomous Multi‑Agent Pipeline (pipeline_service.py) runs sequential agents: Profiling Agent (profiling_agent.py), Attack Strategy Agent (strategy_agent.py), Execution Agent & Plugins (execution_agent.py + plugins/), MCP Reasoning Agent (mcp_agent.py), Vulnerability Observer Agent (observer_agent.py).
- Intelligence & Learning: Q‑Learning Adaptive Engine (rule_prioritizer.py / learner.py) receives reward feedback (+2, +1, -0.1) from the Observer and updates priority weights; RAG Rule Search (rag_service.py) feeds context to an LLM Copilot Cascade (Claude 3.5 Sonnet → Gemini Flash).
- Persistence Layer: PostgreSQL or SQLite via SQLAlchemy 2.0 ORM.
I chose this stack because Next.js 15 gives fast SSR UI, FastAPI provides async API and native WebSocket support, and the sequential agent design offers clear responsibility and deterministic data flow.

