# Hermes Assistant — admin-ai SSE Proxy Reference

Deployed Jul 8, 2026. FastAPI SSE proxy that streams tokens from admin-ai.itpropartner.com (OpenAI-compatible API) to a PWA frontend.

## Architecture

```
Browser (PWA) → Caddy (app.itpropartner.com) → FastAPI (:8082) → admin-ai.itpropartner.com/v1
```

- Frontend: `/var/www/assistant/` — served directly by Caddy
- API: reverse-proxied to `127.0.0.1:8082`
- Backend: `/root/hermes-assistant/server.py` — FastAPI app
- Service: `hermes-assistant.service` — systemd-managed
- Sessions: JSON files in `/root/hermes-assistant/sessions/`

## API Endpoints

| Method | Path | Purpose |
|--------|------|---------|
| GET | `/api/health` | Health check |
| GET | `/api/sessions` | List recent sessions |
| DELETE | `/api/sessions/{id}` | Delete session |
| POST | `/api/chat` | SSE streaming chat |

## Configuration

**Environment variables (in systemd unit):**
- `ADMIN_AI_API_KEY` — OpenAI-compatible API key
- `ADMIN_AI_BASE_URL` — `https://admin-ai.itpropartner.com/v1`
- `HERMES_MODEL` — `deepseek-chat`
- `PORT` — `8082`

**Caddyfile mapping:**
```
@api path /api/*
handle @api { reverse_proxy 127.0.0.1:8082 }
handle { root * /var/www/assistant; try_files {path} /index.html; file_server }
```

## Code locations

- Backend: `/root/hermes-assistant/server.py`
- Frontend: `/var/www/assistant/index.html`
- PWA manifest: `/var/www/assistant/manifest.json`
- Service worker: `/var/www/assistant/sw.js`
- Icon: `/var/www/assistant/icon.svg`
- Systemd unit: `/etc/systemd/system/hermes-assistant.service`
- Caddy config: `/etc/caddy/Caddyfile`
- Sessions: `/root/hermes-assistant/sessions/`

## Session persistence

Sessions are stored as JSON arrays of messages in `/root/hermes-assistant/sessions/<session_id>.json`. The backend appends each user + assistant response, so the session grows unbounded. For production, add a session rotation or truncation policy (e.g. keep last 50 messages).
