The previous deploy snippet rsync'd the UI repo root (excluding dist/), which pushed the Vite DEV index.html (<script src=/src/main.tsx>) to production and rendered a blank page. Correct to build then rsync the dist/ output with --delete.
3.3 KiB
3.3 KiB
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.csswith neon accents.
Backend conventions
- Use
_fmt_time()for timestamps; it must handle bothdatetime.datetimeand unix timestamps. - SQL queries via PyMySQL
%splaceholders; always usecon.execute()andcon.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.shwithsudo -A <cmd>. sudo bash <script>is blocked (nested root shell). Run privileged steps as individualsudo -A <cmd>calls.- Deploy backend:
sudo -A cp /home/jp/asterisk-vm/vm_api.py /opt/vm-transcribe/vm_api.py && sudo -A systemctl restart vm-api. - Deploy frontend: build in the UI repo, then rsync the
dist/output (not the repo root) to the web root:cd /home/jp/Work/voicemail-ui && npm install && npm run build && sudo rsync -a --delete dist/ /home/txt3/domains/vm.txt3.net/public_html/. NOTE: deploydist/, never the repo root — the rootindex.htmlis the Vite dev entry (<script src="/src/main.tsx">) and will render a blank page in production.
Git
- Remote: Gitea self-hosted. Push needs
jp-accountGitea PAT withreposcope. - Frontend sync:
rsync -a /home/jp/Work/voicemail-ui/ frontend/then commit underfrontend/.
Contacts & matching
- Contacts live in MySQL
contactstable. - E.164 is canonical; UK storage often 0-prefixed.
- Creating/updating a contact backfills
messages.contact_name/contact_emailfor matching callerids.
Known gotchas
- Chrome overrides dark inputs: use bare
inputselector, hardcodebackground: #0a0e17, resetappearance, set-webkit-text-fill-color. - React hook rules: no
useMemo/useStateinside.map(). Hooks must be at component top level. - Do NOT push to origin from this session unless explicitly asked; push is currently blocked by Gitea 401 (uid 0).