# AGENTS.md — Asterisk Voicemail Portal Project: mail.txt3.net Asterisk PBX + MySQL voicemail store + React portal (vm.txt3.net) Backend repo: `/home/jp/Work/asterisk-voicemail` (this repo) Frontend repo: `/home/jp/Work/voicemail-ui` Deployed frontend: `/home/txt3/domains/vm.txt3.net/public_html/` Deployed backend: `/opt/vm-transcribe/` --- ## Directory layout - `src/vm_api.py` — FastAPI JSON API (:8098). Apache proxies `/api/` → :8098. - `src/vm_web.py` — Original FastAPI HTML portal (:8099). - `src/vm_store.py` — MySQL-backed voicemail store. - `src/vm_contacts.py` — MySQL-only contact backend (no CardDAV/Google). - `frontend/` — React frontend synced from `/home/jp/Work/voicemail-ui`. - `apache/vm.txt3.net.conf` — Apache vhost (CSP relaxed, Let's Encrypt cert). --- ## Services - `vm-api.service` → :8098 (JSON API). Active unit. - `vm-portal.service` → :8099 (HTML portal). - `apache2` → :443 with per-subdomain cert for vm.txt3.net. Auth: voicemail `pin` from `voicemail.conf`. No separate portal passwords. --- ## Frontend stack - React + react-router-dom (createBrowserRouter + RouterProvider). - TanStack Query for data fetching/mutations. - Vite build → `dist/` → rsync to `/home/txt3/domains/vm.txt3.net/public_html/`. - Dark cyber theme in `src/index.css` with neon accents. --- ## Backend conventions - Use `_fmt_time()` for timestamps; it must handle both `datetime.datetime` and unix timestamps. - SQL queries via PyMySQL `%s` placeholders; always use `con.execute()` and `con.commit()`. - Callerid matching: strip spaces/quotes with `REPLACE(REPLACE(callerid, ' ', ''), '"', '')` before LIKE comparison. - Normalize UK numbers to E.164 in backend; 0-prefix fallback in queries. --- ## Sudo / deployment - Sudo requires password. Use `SUDO_ASKPASS=/home/jp/.hermes/askpass.sh` with `sudo -A `. - `sudo bash