Skip to content

Architecture

Architecture

This page describes the high-level system architecture of BugTraceAI, including the technology stacks, communication protocols, port assignments, and data flow between components.


System Overview

BugTraceAI is a modular ecosystem where each component can function independently or work together as a unified platform.

+-------------------------------------------------------------+
| BugTraceAI Platform |
| |
| +-------------------------+ +-------------------------+ |
| | BugTraceAI-WEB | | BugTraceAI-CLI | |
| | | | | |
| | Frontend (React) | | FastAPI Server | |
| | Port 6869 (Nginx) | | Port 8000 | |
| | | | | |
| | Backend (Express) | | SQLite + LanceDB | |
| | Port 3001 | | Go Fuzzers | |
| | | | Playwright Chromium | |
| | PostgreSQL | | | |
| +----------+--------------+ +------------+------------+ |
| | | |
| +---------- REST API -----------+ |
| +---------- WebSocket ----------+ |
+-------------------------------------------------------------+

Component Stacks

BugTraceAI-CLI Stack

The CLI is the core scanning engine. It exposes a REST API and WebSocket endpoints for integration.

LayerTechnologyPurpose
API ServerFastAPI (Python)REST API + WebSocket endpoints
DatabaseSQLiteSource of truth for all scan data
Vector StoreLanceDBSemantic search over findings
FuzzersGo binariesHigh-speed XSS, SSRF, IDOR, LFI fuzzing
BrowserPlaywright + ChromiumCDP-based validation, DOM analysis
AIOpenRouter APIMulti-model agents (Gemini, Claude, GPT)

Port: 8000 (FastAPI)

BugTraceAI-WEB Stack

The WEB provides a browser-based dashboard that connects to the CLI API.

LayerTechnologyPurpose
FrontendReact 18 + TypeScript + ViteDashboard UI, 20+ security tools
StylingTailwindCSSResponsive design
BackendExpress + TypeScriptAPI for local WEB data
ORMPrismaDatabase access layer
DatabasePostgreSQLChats, settings, analysis reports
ProxyNginxStatic file serving, reverse proxy

Ports: 6869 (Nginx frontend), 3001 (Express backend)

BugTraceAI-Launcher Stack

LayerTechnologyPurpose
ScriptsBashInteractive wizard, lifecycle management
OrchestrationDocker ComposeMulti-container deployment
Configuration.env filesEnvironment variable management

Communication

REST API

The WEB frontend communicates with the CLI via its FastAPI REST API on port 8000.

WEB Frontend ---HTTP/REST---> CLI FastAPI (:8000)
|
+---> /api/scans
+---> /api/scans/{id}/status
+---> /api/scans/{id}/findings
+---> /api/scans/{id}/report/{format}
+---> /api/config
+---> /api/metrics

The CLI API follows the OpenAPI 3.1 specification. Interactive documentation is available at /docs (Swagger UI).

See API Reference for the complete endpoint listing.

WebSocket

Real-time scan monitoring uses WebSocket connections:

WEB Frontend ---WebSocket---> CLI FastAPI (:8000)
|
+---> /ws/scans/{id} (per-scan events)
+---> /ws/global (all-scan events)

WebSocket connections support reconnection via last_seq parameter for event replay.

See WebSocket Events for the complete event protocol.

Full Mode Data Flow

In full deployment mode (WEB + CLI connected):

  1. User initiates a scan from the WEB dashboard
  2. WEB sends POST /api/scans to CLI API
  3. CLI begins autonomous scanning pipeline
  4. CLI emits real-time events via WebSocket
  5. WEB receives and displays progress, findings, and phase transitions
  6. Scan results are persisted in CLI’s SQLite database
  7. WEB can fetch findings and reports via REST API
User --> WEB Dashboard --> CLI REST API --> Scanning Pipeline
^ |
| v
+--- WebSocket Events --- Event Bus
|
v
SQLite DB

Database Architecture

BugTraceAI uses a dual-database system:

DatabaseLocationPurposeStores
SQLiteCLI (bugtrace.db)Source of truthScans, findings, targets, reports
PostgreSQLWEB backendLocal WEB dataChats, settings, analysis reports

Key design decisions:

  • SQLite in the CLI is the single source of truth for all scan-related data
  • PostgreSQL in the WEB stores only WEB-local data (chat history, tool settings, AI analysis reports)
  • The databases work autonomously OR together — they are not required to be co-located
  • Multiple WEB instances can connect to a single CLI API server over the network
  • The origin field tracks where each scan was launched ("cli", "web", or "unknown"). The system defaults to "unknown" rather than guessing — it is better to not know than to lie about data provenance.

See Dual Database System for full details.


Infrastructure Features

Server-Side ZIP Generation

The CLI API can generate complete report archives server-side via GET /api/scans/{id}/report-zip. This includes all report artifacts (markdown, JSON, HTML, specialist results, PoC enrichment, reconnaissance data) in a single download, replacing the need for client-side file assembly.

Circuit Breaker

The scanning pipeline includes a circuit breaker that automatically pauses all agents when the target becomes unresponsive (consecutive timeouts or high timeout percentage). This prevents wasted API calls and protects the target from being overwhelmed. See Configuration for threshold settings.


Port Assignments

PortServiceProtocol
8000CLI FastAPI serverHTTP + WebSocket
8001CLI MCP server (bugtrace_mcp)HTTP/SSE
6869WEB Nginx frontendHTTP
3001WEB Express backendHTTP
5432PostgreSQL (WEB)TCP

Deployment Topologies

Standalone CLI

+-------------------+
| BugTraceAI-CLI |
| FastAPI :8000 |
| SQLite |
+-------------------+

API-only, headless. Ideal for CI/CD and scripted usage.

Standalone WEB

+-------------------+
| BugTraceAI-WEB |
| Nginx :6869 |
| Express :3001 |
| PostgreSQL :5432 |
+-------------------+

Dashboard-only, with AI-powered security toolkit. No active scanning.

Full Platform

+-------------------+ REST + WS +-------------------+
| BugTraceAI-WEB | <--------------------> | BugTraceAI-CLI |
| Nginx :6869 | | FastAPI :8000 |
| Express :3001 | | SQLite |
| PostgreSQL :5432 | | Go Fuzzers |
+-------------------+ | Playwright |
+-------------------+

Full integration. WEB sends scan requests to CLI API, receives real-time updates.

See Deployment Modes for detailed deployment options.


Security Considerations

Network Isolation

In production deployments, internal services should not be exposed:

  • PostgreSQL (5432) and Express backend (3001) should be internal only
  • Only Nginx (6869) and optionally CLI API (8000) should be externally accessible
  • Use Docker network isolation to enforce boundaries

API Authentication

  • The CLI API supports API key authentication
  • The WEB backend uses JWT tokens for user sessions
  • API keys are stored encrypted (AES-256-GCM) in PostgreSQL

Data Privacy

  • No data is transmitted to BugTraceAI servers (there are none)
  • The only external call is to OpenRouter API for AI functionality
  • Users control what data is sent to AI models
  • All scan data remains in the local SQLite/PostgreSQL databases

Sub-pages: Dual Database System | API Reference | WebSocket Events

See also: Deployment Modes | BugTraceAI-CLI | BugTraceAI-WEB