# Magic Cockpit · קוקפיט מג׳יק

Hebrew, read-only replacement of the Magic/Hafill cockpit screens over a typed PostgreSQL mirror: 390,653 works, 1.46M plays, the ten report types, corrections, audit log and the entity map.

**Status:** Live · Projects · 2026

- **Local checkout:** `/Users/simon/Developer/magic-cockpit` (branch `main`, last commit ff77810, 2026-11-07 — Add debug session summary document)
- **Uncommitted changes:** 5 file(s) at brief generation time
- **Repository:** https://github.com/ShimonNavon/magic-cockpit
- **On another machine:** `git clone https://github.com/ShimonNavon/magic-cockpit` — the paths below are Simon's Mac
- **Live:** https://magic.navonsimon.com/ · http://ubuntu03:30122/
- **Open (tailnet):** http://ubuntu03:30122/
- **Where it runs:** https://magic.navonsimon.com/ (ACCESS_KEY password gate) and http://ubuntu03:30122/ on the tailnet
- **Note:** Read-only; tailnet only; Magic stays the system of record.

## Stack

Python 3.12, stdlib http.server, pg8000, PostgreSQL 17, Kubernetes ConfigMap

## Start here

- `app/main.py` — HTTP server, routes, CSV exports, access gate
- `app/repo.py` — every SQL query behind a screen
- `app/pages.py` — screen builders, Hebrew copy
- `app/ui.py` — layout and components; table cells escape unless wrapped in ui.H
- `load/schema.sql` — typed mirror + cockpit tables
- `load/seed.py` — COPY from magic_raw over two SSH hops, Hebrew decode pass
- `deploy/deploy.sh` — namespace, secret, ConfigMap, app rollout

## Commands

- **Unit tests:** `.venv/bin/python -m pytest -q tests`
- **Run locally against the cluster database:** `DATABASE_URL=postgres://cockpit:...@127.0.0.1:15432/cockpit .venv/bin/python -m app.main`
- **Load the mirror from magic_raw:** `python3 load/seed.py`
- **Re-run the Hebrew decode pass:** `python3 load/seed.py --decode-only`
- **Deploy to the cluster:** `./deploy/deploy.sh`

## Deploy and where it runs

- Kubernetes on ubuntu03/ubuntu04, namespace magic-cockpit, NodePort 30122, postgres:17 on a local-path PVC; code in a ConfigMap, pg8000 installed by an initContainer; public edge magic.navonsimon.com via Cloudflare Tunnel and ubuntu01 edge nginx

## Current state

Live, read-only. 2026 dataset loaded (2.9M rows). Writes only to cockpit.review_note and cockpit.search_log. Public subdomain added 2026-11-07 with a password gate; the edge allows GET/HEAD only, so review notes stay a tailnet action.

## Watch out

- FromDate/ToDate are day serials from 1900-12-31, not YYYYMMDD
- Play counters mix per-line counts with period summaries; show row count beside the sum
- Source is cp1255 read as latin-1; decode on the target with cockpit.fix_hebrew()
- 2026 playlist, report line and contact tables are empty in the source — screens say so
- ConfigMap must not exceed 1MB; app/static/map.html is the largest key

## Secrets — locations only, never print values

- D
- a
- t
- a
- b
- a
- s
- e
-  
- p
- a
- s
- s
- w
- o
- r
- d
-  
- i
- n
-  
- m
- a
- g
- i
- c
- -
- c
- o
- c
- k
- p
- i
- t
- /
- .
- e
- n
- v
-  
- (
- g
- i
- t
- i
- g
- n
- o
- r
- e
- d
- )
-  
- a
- n
- d
-  
- t
- h
- e
-  
- c
- o
- c
- k
- p
- i
- t
- -
- s
- e
- c
- r
- e
- t
- s
-  
- S
- e
- c
- r
- e
- t
-  
- i
- n
-  
- t
- h
- e
-  
- c
- l
- u
- s
- t
- e
- r
- .

## Links

- [Data dictionary (pass 1)](file:///Users/simon/Developer/pil/mapping/data-dictionary.md)
- [Relationships with measured overlap](file:///Users/simon/Developer/pil/mapping/relationships.md)
- [Repository README](https://github.com/ShimonNavon/magic-cockpit)

## Tags

Hebrew UI, PostgreSQL, Kubernetes, Python, Data mapping

---

Brief generated 2026-11-08 from `~/Developer/my-projects/context/`. Canonical URL: https://projects.navonsimon.com/context/magic-cockpit.md
