How preambleai/prompt-injector works
Project type and purpose
• This is a full-stack, desktop Electron application (“Prompt Injector”) for AI security testing, combining a React/TypeScript UI with a Node.js/Electron main process, local data storage (SQLite), and integrations to external AI provider APIs.
File structure
• Top-level:
• .github/workflows → CI/CD pipelines (automated and manual builds)
• scripts/ → build-and-release helpers
• src/main → Electron main process (main.ts, preload.ts) and Node-side services
• src (root) → React entry points (main.tsx, App.tsx), UI components, pages, and front-end service wrappers
• public/assets/payloads → JSON library of attack payloads
• Configuration files: vite.config.ts, tsconfig*.json, jest.config.js, tailwind.config.js
README for additional insights
• Tech stack: Electron 25, React 18 + TypeScript + Tailwind CSS, Node.js with Express-style services, Vite build system, SQLite, external AI APIs (OpenAI, Anthropic, Google Gemini, Ollama).
• Build and release: GitHub Actions workflows trigger scripts/build-all.js and scripts/create-release.js to produce installers for macOS, Windows, Linux.
a. Main components
• Renderer Process (React UI): pages, components, Vite-bundled front end
• Electron Main Process: Node.js host, Express-style internal API (if any), preload.ts (IPC bridge)
• Business-Logic Services (under src/services and src/main/services): attack-engine, model-manager, semantic-guardian, payload-manager, etc.
• Data stores:
• SQLite local database
• Payload JSON file (all-attack-payloads.json)
• External AI Providers: OpenAI, Anthropic, Google, Ollama (HTTPS)
• CI/CD Pipeline: GitHub Actions workflows, build & release scripts
b. Relationships & interactions
• UI ↔ Main via Electron IPC (preload.ts exposes safe APIs)
• Main Process → Business Logic Services (invokes attack runs, payload generation)
• Services → Data stores for read/write (SQLite CRUD, JSON reads)
• Services → External AI Providers over HTTPS for model calls
• GitHub Actions → scripts → electron-builder → installable packages
c. Architectural patterns & principles
• Multi-process layering (Renderer vs. Main)
• Clear separation of concerns: Presentation (React), Application logic (services), Data layer (SQLite/JSON), External integrations (AI APIs)
• Local-first, offline-capable architecture
d. Key technologies to call out
• Electron (Main + Renderer)
• React + TypeScript + Tailwind + Vite
• Node.js, SQLite, file system
• External HTTP clients (fetch or axios) to AI APIs
• GitHub Actions, custom build scripts, electron-builder
Capturing essential elements
• Be thorough but not cluttered: group related modules
• Data flows (user action → test execution → result analysis → storage) are visible