Skip to content

Commit f1be81d

Browse files
authored
Add embedded web UI for config editing and live monitoring (#305)
1 parent 58a753d commit f1be81d

37 files changed

Lines changed: 6478 additions & 50 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
hooks:
2828
- id: black
2929
- repo: https://github.com/astral-sh/ruff-pre-commit
30-
rev: v0.7.4
30+
rev: v0.11.12
3131
hooks:
3232
- id: ruff
3333
args: [--fix]

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ AI: Great deal; A well-priced, well-maintained camera meets all search criteria,
3333

3434
## What's New
3535

36+
- **Built-in Web UI**: Edit config, add AI backends, and monitor live logs from your browser — starts automatically with the monitor. See [Web UI documentation](docs/WEBUI.md).
3637
- **Anthropic/Claude AI Backend**: Use Claude models (e.g. `claude-sonnet-4-20250514`) to evaluate listings alongside OpenAI, DeepSeek, and Ollama. See [AI Services](docs/README.md#ai-services) for configuration.
3738
- **Configurable Rate Limiting**: Rate limiting framework for all notification types with per-instance and global limits. Telegram notifications use optimized defaults automatically.
3839

@@ -71,6 +72,15 @@ AI: Great deal; A well-priced, well-maintained camera meets all search criteria,
7172
- Customizable notification levels
7273
- Repeated notification options
7374

75+
🖥️ **Web UI**
76+
77+
- Built-in config editor with TOML syntax highlighting
78+
- Live log streaming and filtering
79+
- Add, edit, and delete config sections from your browser
80+
- No password required on localhost
81+
82+
![Web UI](docs/webui_screenshot.png)
83+
7484
🌎 **Location Support**
7585

7686
- Multi-city search
@@ -112,7 +122,7 @@ pushbullet_token = 'your_token_here' # Get from pushbullet.com
112122
ai-marketplace-monitor
113123
```
114124

115-
The program will open a browser, search Facebook Marketplace, and notify you of matching items.
125+
The program will open a browser, search Facebook Marketplace, and notify you of matching items. A web UI also starts automatically at [http://127.0.0.1:8467](http://127.0.0.1:8467) for editing config and monitoring logs — see [Web UI Guide](docs/webui.md).
116126

117127
## 💡 Example Usage
118128

@@ -158,6 +168,7 @@ For detailed information on setup and advanced features, see the comprehensive d
158168
- **[📱 Usage Guide](https://ai-marketplace-monitor.readthedocs.io/en/latest/usage.html)** - Command-line options and tips
159169
- **[🔧 Configuration Guide](https://ai-marketplace-monitor.readthedocs.io/en/latest/configuration-guide.html)** - Notifications, AI prompts, multi-location search
160170
- **[⚙️ Configuration Reference](https://ai-marketplace-monitor.readthedocs.io/en/latest/configuration.html)** - Complete configuration reference
171+
- **[🖥️ Web UI Guide](docs/webui.md)** - Built-in web interface for config editing and monitoring
161172

162173
### Key Topics Covered in Documentation
163174

@@ -169,7 +180,7 @@ For detailed information on setup and advanced features, see the comprehensive d
169180

170181
**AI Integration:**
171182

172-
- OpenAI, DeepSeek, Ollama setup
183+
- OpenAI, DeepSeek, Anthropic, Ollama setup
173184
- Custom prompt configuration
174185
- Rating thresholds and filtering
175186

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ One of more sections to list the AI agent that can be used to judge if listings
4747
Note that:
4848

4949
1. `provider` can be [OpenAI](https://openai.com/),
50-
[DeepSeek](https://www.deepseek.com/), [Ollama](https://ollama.com/), or [Anthropic](https://www.anthropic.com/). The name of the ai service will be used if this option is not specified so `OpenAI` will be used for section `ai.openai`.
50+
[DeepSeek](https://www.deepseek.com/), [Anthropic](https://www.anthropic.com/), or [Ollama](https://ollama.com/). The name of the ai service will be used if this option is not specified so `OpenAI` will be used for section `ai.openai`.
5151
2. [OpenAI](https://openai.com/) and [DeepSeek](https://www.deepseek.com/) models sets default `base_url` and `model` for these providers.
52-
3. Ollama models require `base_url`. A default model is set to `deepseek-r1:14b`, which seems to be good enough for this application. You can of course try [other models](https://ollama.com/library) by setting the `model` option.
53-
4. [Anthropic](https://www.anthropic.com/) uses the Anthropic SDK directly (not OpenAI-compatible). The default model is `claude-sonnet-4-20250514`. An `api_key` is required.
52+
3. [Anthropic](https://www.anthropic.com/) uses the Anthropic SDK directly (not OpenAI-compatible). The default model is `claude-sonnet-4-20250514`. An `api_key` is required.
53+
4. Ollama models require `base_url`. A default model is set to `deepseek-r1:14b`, which seems to be good enough for this application. You can of course try [other models](https://ollama.com/library) by setting the `model` option.
5454
5. Although only four providers are directly supported, you can use any other service provider with `OpenAI`-compatible API using customized `base_url`, `model`, and `api_key`.
5555
6. You can use option `ai` to list the AI services for particular marketplaces or items.
5656

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Reference & Setup
2626

2727
configuration-guide
2828
Configuration Reference <configuration>
29+
webui
2930
troubleshooting
3031

3132
Development & Reference

docs/webui.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Web UI
2+
3+
AI Marketplace Monitor includes a built-in web interface for editing your configuration and monitoring activity in real time. The web UI starts automatically when you run the monitor — no extra setup needed.
4+
5+
![Web UI Screenshot](webui_screenshot.png)
6+
7+
## Overview
8+
9+
The web UI provides:
10+
11+
- **TOML Config Editor** with syntax highlighting, powered by CodeMirror
12+
- **Add / Edit / Delete** config sections (items, AI backends, users, marketplaces) through guided forms
13+
- **Live Log Streaming** with filtering by level, item, AI score, and text search
14+
- **Auto-validation** of your config as you type
15+
16+
## Getting Started
17+
18+
Simply run the monitor:
19+
20+
```bash
21+
ai-marketplace-monitor
22+
```
23+
24+
The web UI is available at [http://127.0.0.1:8467](http://127.0.0.1:8467). A startup banner in the terminal shows the URL:
25+
26+
```
27+
╭──────────── Web UI ────────────╮
28+
│ 🌐 http://127.0.0.1:8467 │
29+
│ │
30+
│ No password required │
31+
│ (local access only). │
32+
╰────────────────────────────────╯
33+
```
34+
35+
On localhost, **no password is required**. Open the URL in your browser and start editing.
36+
37+
## Disabling the Web UI
38+
39+
If you don't need the web UI, disable it with:
40+
41+
```bash
42+
ai-marketplace-monitor --no-webui
43+
```
44+
45+
## Changing the Port
46+
47+
To use a different port:
48+
49+
```bash
50+
ai-marketplace-monitor --webui-port 9090
51+
```
52+
53+
## Advanced: Remote Access
54+
55+
By default, the web UI only listens on `127.0.0.1` (localhost) and requires no password. To access it from another machine on your network, you need to:
56+
57+
1. **Configure credentials** so the web UI is protected by a login screen.
58+
2. **Bind to a network interface** so other machines can connect.
59+
3. **Open a firewall port** if your system has a firewall enabled.
60+
61+
### Step 1: Set up username and password
62+
63+
The web UI uses your marketplace credentials for authentication. Set them in your config file:
64+
65+
```toml
66+
[marketplace.facebook]
67+
username = "you@example.com"
68+
password = "your-password"
69+
```
70+
71+
Or use environment variables:
72+
73+
```toml
74+
[marketplace.facebook]
75+
username = "${FACEBOOK_USERNAME}"
76+
password = "${FACEBOOK_PASSWORD}"
77+
```
78+
79+
Then set the environment variables in your shell before running the monitor:
80+
81+
```bash
82+
export FACEBOOK_USERNAME="you@example.com"
83+
export FACEBOOK_PASSWORD="your-password"
84+
```
85+
86+
### Step 2: Bind to a network interface
87+
88+
Use `--webui-host` to listen on all interfaces:
89+
90+
```bash
91+
ai-marketplace-monitor --webui-host 0.0.0.0
92+
```
93+
94+
The startup banner will show all reachable URLs:
95+
96+
```
97+
╭──────────────── Web UI ────────────────╮
98+
│ 🌐 http://127.0.0.1:8467 │
99+
│ 🌐 http://192.168.1.42:8467 │
100+
│ │
101+
│ user: you@example.com │
102+
│ password: (from marketplace config) │
103+
│ │
104+
│ ⚠ Bound to non-loopback interface. │
105+
│ Consider TLS via a reverse proxy. │
106+
╰────────────────────────────────────────╯
107+
```
108+
109+
You can also specify a port:
110+
111+
```bash
112+
ai-marketplace-monitor --webui-host 0.0.0.0 --webui-port 9090
113+
```
114+
115+
> **Note:** If no credentials are configured, `--webui-host` will refuse to start and display an error. This prevents accidentally exposing an unprotected editor on the network.
116+
117+
### Step 3: Open a firewall port
118+
119+
If your machine has a firewall, open the web UI port. For example, on Ubuntu with `ufw`:
120+
121+
```bash
122+
sudo ufw allow 8467/tcp
123+
```
124+
125+
On macOS, allow incoming connections through **System Settings > Network > Firewall**.
126+
127+
On Windows, add an inbound rule in **Windows Defender Firewall > Advanced Settings**.
128+
129+
> **Warning:** Exposing the web UI on a network means anyone who can reach the port can attempt to log in. Consider using a reverse proxy (nginx, Caddy, Tailscale) with TLS for encrypted connections, especially over untrusted networks.
130+
131+
## CLI Options Reference
132+
133+
| Option | Default | Description |
134+
| ----------------------- | ----------- | --------------------------------------------------- |
135+
| `--webui / --no-webui` | `--webui` | Enable or disable the web UI |
136+
| `--webui-host` | `127.0.0.1` | Bind address (requires credentials if not loopback) |
137+
| `--webui-port` | `8467` | Port for the web UI |
138+
| `--webui-log-retention` | `2000` | Number of log messages kept in memory |

docs/webui_screenshot.png

1.28 MB
Loading

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ dependencies = [
3838
"safety>=3.5.2",
3939
"pip-audit>=2.9.0",
4040
"python-telegram-bot>=22.3",
41+
"fastapi>=0.110",
42+
"uvicorn[standard]>=0.27",
43+
"itsdangerous>=2.1",
44+
"bcrypt>=4.0",
45+
"python-multipart>=0.0.9",
4146
]
4247

4348
[project.urls]

src/ai_marketplace_monitor/ai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
class AIServiceProvider(Enum):
1818
OPENAI = "OpenAI"
1919
DEEPSEEK = "DeepSeek"
20-
OLLAMA = "Ollama"
2120
ANTHROPIC = "Anthropic"
21+
OLLAMA = "Ollama"
2222

2323

2424
@dataclass

0 commit comments

Comments
 (0)