# codefingers809/logspec architecture

> Architecture diagram of the GitHub repository codefingers809/logspec, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codefingers809/logspec
- Repository: https://github.com/codefingers809/logspec

## Overview

1. **Repository shape**
   - This is a three-part system: `client/` is the Laravel + React product UI, `backend/` is the Python security-analysis engine, and `dasht/` is a separate DAST service stack for live web scanning.
   - The architecture is intentionally split between a user-facing control plane and a scan-execution plane.

2. **Client app: UI, auth, and report presentation**
   - `client/` is a Laravel 13 app using Inertia.js + React 19 + TailwindCSS as the presentation layer.
   - It owns browser sessions, Fortify-based authentication, settings/profile flows, and the main dashboard pages for repositories, scans, findings, threat intel, and DAST.
   - Controllers such as `RepositoryController`, `ScanController`, `FindingController`, `DastController`, and `ThreatIntelController` act as the Laravel-facing orchestration layer.

3. **Backend app: scan API and analysis engine**
   - `backend/` is a FastAPI service that exposes versioned REST endpoints under `app/api/v1`.
   - Its role is not the UI; it is the analysis and persistence backend that receives authenticated requests, starts scan workflows, and serves scan/finding data back to the client.
   - The API boundary is explicit: routers for repos, scans, findings, reports, tools, providers, files, health, and model metadata.

4. **Async job pipeline**
   - The backend uses Celery with Redis as the queueing layer for long-running scans.
   - HTTP requests trigger scan jobs, but the actual work is done asynchronously by workers, which is important for the architecture because scans are multi-step and expensive.
   - This separates request/response latency from scan execution.

5. **Scanner execution subsystem**
   - The `backend/app/scanners` package is the core execution layer for SAST-style analysis.
   - It includes dependency scanning, code scanning, secret detection, IaC/policy checks, container/Dockerfile linting, and preflight/incremental/triage logic.
   - Concrete scanners include Semgrep, Gitleaks, Checkov, Hadolint, Conftest, Trivy, and fingerprinting/dedup helpers.

6. **Analysis and orchestration graph**
   - The backend also has a graph-based agent layer in `app/graph` with agent/tool nodes and a shared state model.
   - This is the LLM-driven analysis path: source files and scan context are fed into an agent workflow to produce context-aware findings that complement the rule-based scanners.
   - `app/tools` provides the tool registry used by that agent layer.

7. **LLM provider abstraction**
   - LLM access is abstracted behind provider interfaces in `backend/app/llm/providers`.
   - Supported providers include OpenAI, Anthropic, Groq, and AWS Bedrock, with a factory and a Bedrock-specific client.
   - This is a key boundary: the rest of the system talks to a provider-agnostic LLM interface rather than a single vendor API.

8. **Data persistence and repository layer**
   - The backend persists scan results, repos, users, provider keys, credentials, scan context, and scanner runs through a repository pattern in `backend/app/db/repositories`.
   - MySQL is the main relational store for findings and scan metadata; the schema evolves through SQL migrations in `backend/app/db/migrations`.
   - This repository layer is the main persistence boundary between API/service logic and the database.

9. **Client/backend security boundary**
   - Auth is handled on the Laravel side with Fortify and JWT cookies, which are then used for server-to-server communication with the Python backend.
   - That means the browser authenticates to Laravel, while Laravel acts as the trusted bridge to backend APIs.
   - This is a meaningful trust boundary in the architecture diagram: browser → Laravel session/auth → JWT-authenticated backend calls.

10. **Report generation and summaries**
   - The system produces a consolidated report with deduplicated findings, severity breakdowns, and AI-generated remediation guidance.
   - Laravel includes a `scan_report.blade.php` view for presentation/PDF generation, while the backend has report and summary services for aggregated scan output.
   - The reporting flow sits downstream of scan ingestion and deduplication, not in the live scan path.

11. **DAST subsystem**
   - `dasht/` is a separate Docker Compose-based service that wraps web attack scanners.
   - It combines ZAP, Wapiti, and WPScan sidecars, with a Python API layer for report merging and result normalization.
   - This is a distinct runtime from the main backend because it scans live targets, not source code.

12. **External integrations**
   - The architecture depends on external security tooling and cloud services: OSV/Trivy for dependency intel, Pulsedive for IOC reputation lookups, and multiple LLM providers for remediation and summarization.
   - Docker is also a structural dependency because several scanners and the DAST stack run as containerized subprocesses or sidecars.

13. **Operational concerns**
   - The backend includes lifespan and logging modules, plus scanner lifecycle helpers, showing that startup/shutdown and execution control are first-class concerns.
   - Tests are present in both Python and Laravel sides, with end-to-end scripts in the backend, indicating the repo is designed around integrated scan workflows rather than isolated libraries.

14. **How to draw it**
   - A good diagram should show three major blocks: Laravel UI/control plane, Python scan engine, and DAST service.
   - Inside the Python block, draw separate lanes for API, queue/worker execution, scanner modules, LLM provider adapters, and MySQL repositories.
   - The main flows are: user request → Laravel auth/UI → backend scan dispatch → Celery workers → scanners/LLM → persisted findings → report/summary output back to the client.

Main entry points: [`client/app/Http/Controllers`](https://github.com/codefingers809/logspec/tree/main/client/app/Http/Controllers) (App controllers), [`backend/app/db/repositories`](https://github.com/codefingers809/logspec/tree/main/backend/app/db/repositories) (Repositories), [`backend/app/api/v1`](https://github.com/codefingers809/logspec/tree/main/backend/app/api/v1) (API routers), [`backend/app/services`](https://github.com/codefingers809/logspec/tree/main/backend/app/services) (Scan services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Laravel control plane"]
  node_client_ui["UI shell<br/>Laravel + React"]
  node_client_auth["Auth flow<br/>Fortify sessions"]
  node_client_ctrl["App controllers<br/>Laravel orchestration"]
  node_client_reports["Report views<br/>Blade output"]
  node_client_models["Client models<br/>UI domain models"]
  node_client_bridge["Backend bridge<br/>JWT client<br/>[LogSpecClient.php]"]
end

subgraph group_backend["Python analysis engine"]
  node_backend_api["API routers<br/>FastAPI REST"]
  node_backend_auth["JWT auth<br/>Cookie auth<br/>[jwt_cookie.py]"]
  node_backend_service["Scan services<br/>Workflow service"]
  node_backend_tasks["Celery queue<br/>Async jobs"]
  node_backend_scanners["Scanner suite<br/>SAST execution"]
  node_backend_graph{{"Agent graph<br/>LLM workflow"}}
  node_backend_tools["Tool registry<br/>Agent tools"]
  node_backend_llm["LLM adapters<br/>Provider abstraction"]
  node_backend_repos[("Repositories<br/>Persistence layer")]
  node_backend_db[("MySQL store<br/>Relational data")]
  node_backend_vcs["VCS access<br/>Repo ingestion"]
end

subgraph group_dasht["DAST service"]
  node_dasht_api["DAST API<br/>Python service<br/>[main.py]"]
  node_dasht_scanners["DAST sidecars<br/>Container scanners<br/>[server.py]"]
end

node_client_ui -->|"routes to"| node_client_ctrl
node_client_auth -->|"protects"| node_client_ui
node_client_ctrl -->|"calls backend"| node_client_bridge
node_client_ctrl -->|"renders"| node_client_reports
node_client_models -->|"binds data"| node_client_ctrl
node_client_bridge -->|"authenticates"| node_backend_auth
node_backend_api -->|"delegates"| node_backend_service
node_backend_api -->|"dispatches"| node_backend_tasks
node_backend_tasks -->|"executes"| node_backend_scanners
node_backend_tasks -->|"invokes"| node_backend_graph
node_backend_graph -->|"uses"| node_backend_tools
node_backend_graph -->|"queries"| node_backend_llm
node_backend_scanners -->|"reads repos"| node_backend_vcs
node_backend_scanners -->|"stores runs"| node_backend_repos
node_backend_service -->|"persists"| node_backend_repos
node_backend_repos -->|"reads/writes"| node_backend_db
node_backend_service -->|"summarizes"| node_backend_llm
node_backend_api -->|"reads"| node_backend_repos
node_dasht_api -->|"orchestrates"| node_dasht_scanners
node_dasht_api -.->|"returns results"| node_client_ctrl

click node_client_ui "https://github.com/codefingers809/logspec/tree/main/client/resources/js"
click node_client_auth "https://github.com/codefingers809/logspec/blob/main/client/app/Providers/FortifyServiceProvider.php"
click node_client_ctrl "https://github.com/codefingers809/logspec/tree/main/client/app/Http/Controllers"
click node_client_reports "https://github.com/codefingers809/logspec/blob/main/client/resources/views/scan_report.blade.php"
click node_client_models "https://github.com/codefingers809/logspec/tree/main/client/app/Models"
click node_client_bridge "https://github.com/codefingers809/logspec/blob/main/client/app/Services/LogSpecClient.php"
click node_backend_api "https://github.com/codefingers809/logspec/tree/main/backend/app/api/v1"
click node_backend_auth "https://github.com/codefingers809/logspec/blob/main/backend/app/auth/jwt_cookie.py"
click node_backend_service "https://github.com/codefingers809/logspec/tree/main/backend/app/services"
click node_backend_tasks "https://github.com/codefingers809/logspec/tree/main/backend/app/tasks"
click node_backend_scanners "https://github.com/codefingers809/logspec/tree/main/backend/app/scanners"
click node_backend_graph "https://github.com/codefingers809/logspec/tree/main/backend/app/graph"
click node_backend_tools "https://github.com/codefingers809/logspec/tree/main/backend/app/tools"
click node_backend_llm "https://github.com/codefingers809/logspec/tree/main/backend/app/llm/providers"
click node_backend_repos "https://github.com/codefingers809/logspec/tree/main/backend/app/db/repositories"
click node_backend_db "https://github.com/codefingers809/logspec/tree/main/backend/app/db/migrations"
click node_backend_vcs "https://github.com/codefingers809/logspec/tree/main/backend/app/vcs"
click node_dasht_api "https://github.com/codefingers809/logspec/blob/main/dasht/api/main.py"
click node_dasht_scanners "https://github.com/codefingers809/logspec/blob/main/dasht/wapiti-sidecar/server.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_ui,node_client_auth,node_client_ctrl,node_client_reports,node_client_models,node_client_bridge toneBlue
class node_backend_api,node_backend_auth,node_backend_service,node_backend_tasks,node_backend_scanners,node_backend_graph,node_backend_tools,node_backend_llm,node_backend_repos,node_backend_db,node_backend_vcs toneAmber
class node_dasht_api,node_dasht_scanners toneMint
```

## Components

### Laravel control plane

Browser-facing UI, auth, dashboards, and report presentation.

- [UI shell](https://github.com/codefingers809/logspec/tree/main/client/resources/js): Laravel + React · Inertia/React presentation layer for dashboards, repositories, scans, findings, and settings. · `client/resources/js`
- [Auth flow](https://github.com/codefingers809/logspec/blob/main/client/app/Providers/FortifyServiceProvider.php): Fortify sessions · Browser session handling, login, registration, password reset, and 2FA. · `client/app/Providers/FortifyServiceProvider.php`
- [App controllers](https://github.com/codefingers809/logspec/tree/main/client/app/Http/Controllers): Laravel orchestration · Controllers coordinating repositories, scans, findings, DAST, and threat intel views. · `client/app/Http/Controllers`
- [Report views](https://github.com/codefingers809/logspec/blob/main/client/resources/views/scan_report.blade.php): Blade output · Consolidated scan report presentation and PDF-friendly rendering. · `client/resources/views/scan_report.blade.php`
- [Client models](https://github.com/codefingers809/logspec/tree/main/client/app/Models): UI domain models · Frontend-facing repository, scan, finding, and user models used by the control plane. · `client/app/Models`
- [Backend bridge](https://github.com/codefingers809/logspec/blob/main/client/app/Services/LogSpecClient.php): JWT client · Trusted server-to-server calls from Laravel to the Python backend using JWT cookies. · `client/app/Services/LogSpecClient.php`

### Python analysis engine

API, async workers, scanners, persistence, and LLM-assisted analysis.

- [API routers](https://github.com/codefingers809/logspec/tree/main/backend/app/api/v1): FastAPI REST · Versioned REST boundary for repos, scans, findings, reports, tools, providers, files, and health. · `backend/app/api/v1`
- [JWT auth](https://github.com/codefingers809/logspec/blob/main/backend/app/auth/jwt_cookie.py): Cookie auth · Backend authentication support for Laravel-issued trusted requests. · `backend/app/auth/jwt_cookie.py`
- [Scan services](https://github.com/codefingers809/logspec/tree/main/backend/app/services): Workflow service · Repo, scan, report, and summary services that coordinate scan lifecycle and persisted output. · `backend/app/services`
- [Celery queue](https://github.com/codefingers809/logspec/tree/main/backend/app/tasks): Async jobs · Long-running scan dispatch and worker execution through Redis-backed task processing. · `backend/app/tasks`
- [Scanner suite](https://github.com/codefingers809/logspec/tree/main/backend/app/scanners): SAST execution · Rule-based scanners for dependencies, code, secrets, IaC, containers, preflight, incremental, and triage. · `backend/app/scanners`
- [Agent graph](https://github.com/codefingers809/logspec/tree/main/backend/app/graph): LLM workflow · Graph-based agent and tool nodes that analyze files and scan context for richer findings. · `backend/app/graph`
- [Tool registry](https://github.com/codefingers809/logspec/tree/main/backend/app/tools): Agent tools · Tool definitions exposed to the analysis graph. · `backend/app/tools`
- [LLM adapters](https://github.com/codefingers809/logspec/tree/main/backend/app/llm/providers): Provider abstraction · Provider-agnostic interfaces and adapters for OpenAI, Anthropic, Groq, and Bedrock. · `backend/app/llm/providers`
- [Repositories](https://github.com/codefingers809/logspec/tree/main/backend/app/db/repositories): Persistence layer · Repository pattern for scans, findings, repos, users, credentials, provider keys, and scanner runs. · `backend/app/db/repositories`
- [MySQL store](https://github.com/codefingers809/logspec/tree/main/backend/app/db/migrations): Relational data · Primary database for findings, scan metadata, users, and scan context. · `backend/app/db/migrations`
- [VCS access](https://github.com/codefingers809/logspec/tree/main/backend/app/vcs): Repo ingestion · Git and GitHub URL handling for repository acquisition and context. · `backend/app/vcs`

### DAST service

Containerized live-target scanning stack with report normalization.

- [DAST API](https://github.com/codefingers809/logspec/blob/main/dasht/api/main.py): Python service · Live-scan API that merges and normalizes web scanner output. · `dasht/api/main.py`
- [DAST sidecars](https://github.com/codefingers809/logspec/blob/main/dasht/wapiti-sidecar/server.py): Container scanners · ZAP, Wapiti, and WPScan sidecar services for live target scanning. · `dasht/wapiti-sidecar/server.py`

## Connections

- UI shell → App controllers: routes to · UI pages are driven by Laravel controllers.
- Auth flow → UI shell: protects · Authenticated sessions gate the presentation layer.
- App controllers → Backend bridge: calls backend · Controllers use the trusted bridge to reach Python APIs.
- App controllers → Report views: renders · Controllers feed report presentation and PDF output.
- Client models → App controllers: binds data · Models shape dashboard and view state.
- Backend bridge → JWT auth: authenticates · Laravel requests are accepted via JWT-backed auth.
- API routers → Scan services: delegates · Routers hand requests to service-layer workflow logic.
- API routers → Celery queue: dispatches · Scan requests enqueue asynchronous work.
- Celery queue → Scanner suite: executes · Workers run multi-step scan pipelines.
- Celery queue → Agent graph: invokes · Worker jobs can trigger agent-based analysis workflows.
- Agent graph → Tool registry: uses · Graph nodes consume registered tools.
- Agent graph → LLM adapters: queries · Agent workflow calls provider-agnostic LLM adapters.
- Scanner suite → VCS access: reads repos · Scanners consume repository content and Git context.
- Scanner suite → Repositories: stores runs · Scanner outcomes are persisted through repositories.
- Scan services → Repositories: persists · Services write repos, scans, findings, and summaries.
- Repositories → MySQL store: reads/writes · Repository layer mediates database access.
- Scan services → LLM adapters: summarizes · Report and summary services may use LLM-assisted guidance.
- API routers → Repositories: reads · APIs serve scan and finding data from persistence.
- DAST API → DAST sidecars: orchestrates · DAST API coordinates live scanner sidecars.
- DAST API → App controllers: returns results · DAST outcomes are surfaced back through the UI/control plane.
