Skip to content

Commit 4125fb5

Browse files
authored
FEAT add skeleton backend for the GUI/frontend (microsoft#1298)
1 parent 7e8518a commit 4125fb5

24 files changed

Lines changed: 595 additions & 81 deletions

File tree

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ default_memory.json.memory
3939
frontend/node_modules/
4040
frontend/dist/
4141
frontend/.vite/
42+
43+
# Backend frontend directory (generated during packaging)
44+
pyrit/backend/frontend/

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ exclude =
1313
*lib/python*,
1414
*egg,
1515
build,
16+
frontend/dev.py,
17+
pyrit/backend/main.py,
1618
pyrit/cli/pyrit_shell.py,
1719
pyrit/prompt_converter/morse_converter.py,
1820
pyrit/prompt_converter/emoji_converter.py,

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ dbdata/
55
eval/
66
default_memory.json.memory
77

8+
# Frontend build artifacts copied to backend for packaging
9+
pyrit/backend/frontend/
10+
811
# Byte-compiled / optimized / DLL files
912
__pycache__/
1013
*.py[cod]

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ recursive-include pyrit *.wav
88
recursive-include pyrit *.mp4
99
recursive-include pyrit *.md
1010
include pyrit/auxiliary_attacks/gcg/src/Dockerfile
11+
recursive-include pyrit/backend/frontend *

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: all pre-commit mypy test test-cov-html test-cov-xml
22

3-
CMD:=uv run --active -m
3+
CMD:=uv run -m
44
PYMODULE:=pyrit
55
TESTS:=tests
66
UNIT_TESTS:=tests/unit
@@ -17,8 +17,8 @@ mypy:
1717
$(CMD) mypy $(PYMODULE) $(UNIT_TESTS)
1818

1919
docs-build:
20-
uv run --active jb build -W -v ./doc
21-
uv run --active ./build_scripts/generate_rss.py
20+
uv run jb build -W -v ./doc
21+
uv run ./build_scripts/generate_rss.py
2222

2323
# Because of import time, "auto" seemed to actually go slower than just using 4 processes
2424
unit-test:

doc/contributing/1a_install_uv.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ However, there are many reasons to install as a contributor. Yes, of course, if
5151
git clone https://github.com/Azure/PyRIT
5252
```
5353

54+
4. **Node.js and npm**. Required for building the TypeScript/React frontend. Download [Node.js](https://nodejs.org/) (which includes npm). Version 18 or higher is recommended.
55+
5456
## Installation with uv
5557

5658
This is a guide for how to install PyRIT using uv

doc/contributing/1c_install_conda.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ This is a list of the prerequisites needed to run this library.
1111
git clone https://github.com/Azure/PyRIT
1212
```
1313

14+
1. **Node.js and npm**. Required for building the TypeScript/React frontend. Download [Node.js](https://nodejs.org/) (which includes npm). Version 18 or higher is recommended.
15+
1416
Note: PyRIT requires Python version 3.10, 3.11, 3.12, or 3.13. If using Conda, you'll set the environment to use this version. If running PyRIT outside of a python environment, make sure you have this version installed.
1517
1618
## Installation with conda

doc/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ potentially harmful outputs, which can take many forms, including harmful conten
1111
incitement or glorification of violence, or sexual content." Additionally, a variety of security risks
1212
can be introduced by the deployment of an AI system.
1313

14-
(installation-guide)=
1514
## Installation Guide
1615

1716
PyRIT offers flexible installation options to suit different needs. Choose the path that best fits your use case:

frontend/README.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,50 @@
22

33
Modern TypeScript + React frontend for PyRIT, built with Fluent UI.
44

5-
## Quick Start
6-
7-
### Installation
5+
## Development
86

97
```bash
8+
# Install dependencies
109
npm install
11-
```
12-
13-
### Running the Frontend
1410

15-
```bash
16-
# Start the frontend server
11+
# Start both backend and frontend (cross-platform)
1712
python dev.py start
13+
# OR use npm script
14+
npm run start
1815

19-
# Stop the frontend server
20-
python dev.py stop
21-
22-
# Restart the frontend server
16+
# Restart both servers
2317
python dev.py restart
24-
```
18+
# OR
19+
npm run restart
2520

26-
The frontend will be available at `http://localhost:3000`
27-
28-
### Alternative: Using npm directly
21+
# Stop all servers
22+
python dev.py stop
23+
# OR
24+
npm run stop
2925

30-
```bash
26+
# Run Vite dev server only (backend must be started separately)
3127
npm run dev
32-
```
3328

34-
### Building for Production
35-
36-
```bash
29+
# Build for production
3730
npm run build
31+
32+
# Preview production build
33+
npm run preview
3834
```
3935

40-
The built files will be in the `dist/` directory.
36+
**Development Mode**: The `dev.py` script sets `PYRIT_DEV_MODE=true` so the backend expects the frontend to run separately on port 3000.
37+
38+
**Production Mode**: When installed from PyPI, the backend serves the bundled frontend and will exit if frontend files are missing.
4139

42-
## Tech Stack
40+
## Stack
4341

4442
- **React 18** - UI framework
4543
- **TypeScript** - Type safety
4644
- **Fluent UI v9** - Microsoft design system
4745
- **Vite** - Fast build tool
46+
- **Axios** - HTTP client
47+
48+
## Configuration
49+
50+
The frontend proxies API requests to `http://localhost:8000` in development.
4851
Configure this in `vite.config.ts` if needed.

0 commit comments

Comments
 (0)