Architecture - jejellyroll-fr/fpdb-3 GitHub Wiki
Developer notes. For using fpdb, start at Home.

fpdb runs the import loop and the HUD in separate processes, talking over a
local ZeroMQ socket on tcp://127.0.0.1:5555.
fpdb.pyw (GUI, importer) HUD_main.pyw (overlay)
βββββββββββββββββββββββββ ββββββββββββββββββββββββ
watch auto-import directories
parse new hand histories ββZMQβββΆ receive hand id
write to the database find the window whose title
matches the table
read that table's stats from
the database
draw / update the overlay
Why two processes: the overlay has to stay responsive while the importer is parsing and writing, and a parse that blocks must not freeze the HUD over a live table. The split is also why the HUD can be run on its own for debugging:
python fpdb_3_legacy/HUD_main.pywThe HUD only reads from the database. Nothing it displays is computed from the table window; the window supplies geometry, and β on Fast-Fold tables β seating.
IdentifySite β <Room>ToFpdb β Hand β DerivedStats β Database
which parse the the compute the persist
room is text into hand statistics
this file a Hand model the reports
and HUD read
| Module | Role |
|---|---|
Importer.py |
Watches directories, drives the pipeline, sends hand ids over ZMQ |
IdentifySite.py |
Decides which converter a file belongs to |
*ToFpdb.py |
One converter per room. iPoker/ is split into mixins. |
HandHistoryConverter.py |
The base class every converter implements |
Hand.py |
The parsed hand model |
DerivedStats.py |
Turns a hand into the per-player statistics that get stored |
Database.py |
The data layer, across all three backends |
SQL.py, dialects.py
|
Per-backend SQL |
db_migrate.py |
Cross-backend migration, preserving primary keys |
Rooms that write no hand-history file are handled by capture modules
(*_capture*.py) instead of a directory watcher β SwC Poker over HTTP and
natively, and iPoker.
| Module | Role |
|---|---|
HUD_main.pyw |
The HUD process: socket, table matching, orchestration |
Hud.py |
One HUD instance β one table |
Aux_Base.py |
The overlay framework, including seat rotation (adj_seats) |
Aux_Hud.py, Aux_Classic_Hud.py
|
The classic stat-block overlay |
Stats.py, stats.d/
|
Statistic definitions. Evaluated as data β no eval. |
Popup.py, ModernPopup.py, PopupThemes.py, PopupIcons.py
|
Popups |
hud_profiles.py |
Profile selection: rules narrow a HudContext down to a profile |
HudStatsPersistence.py |
Caching across hands |
SmartHudManager.py |
Lifecycle |
Window detection lives outside the legacy package, in
fpdb/infrastructure/platform/: linux.py, macos.py, windows.py behind a
common protocol.py, chosen by factory.py. permissions.py handles the macOS
screen-recording and accessibility prompts.
Seat rotation is computed once, when the HUD is created, so that the hero lands at the bottom of the screen. Everything downstream assumes the hero's seat number does not move after that β which is the constraint the Fast-Fold seat mapping had to be built around.
New in 3.6.0. On a Fast-Fold pool the hero changes table on every fold, so a hand history describes players who are already gone by the time it is imported; and every window on a pool writes under the same table name, so hands from several windows collide on one HUD key.
The engine separates the two jobs a hand history was doing:
| Source | Answers |
|---|---|
winamax_live_log_reader.py |
Which window a hand belongs to; when the hero folded or the pot was awarded |
winamax_ax_seats.py |
Who is sitting where |
| Hand histories | The statistics |
winamax_live_log_reader.py tails the client log. It primes from the tail on
startup (PRIME_BYTES) so hands still waiting to be imported can be matched, and
remembers recent hand-to-window pairs (HAND_TABLE_HISTORY).
winamax_ax_seats.py reads the seating off the window. The Winamax client is an
Electron application, so its table is a web page and Chromium will build an
accessibility tree for it β which carries every player's name with its on-screen
position. That is the seat directly, with no inference and no waiting for anyone
to act. macOS only; elsewhere the engine falls back to the log-derived ring,
which is an acting order rather than a seating plan.
fast_fold_engine.py holds the platform-independent part: is_fast_fold_table
(title patterns for Go Fast, Hold-Up, Escape, Splash, Zoom, Rush),
build_seat_map (ring β seat numbers, pinned on the hero), and the request /
result pair that carries a seat map to the database worker and brings statistics
back β the HUD's own connection is a database-free replay faΓ§ade, so it cannot
read them itself.
To extend this to another room, what is needed is a reader for that client's log that answers the same two questions. The rest of the engine is room-agnostic.
Configuration.py reads HUD_config.xml β sites, HUD profiles, popups, database
connections, import parameters. ConfigurationManager.py tracks pending changes
so the application knows what a reload will alter.
disabled_sites.py is the switch for a room whose support is off: it forces the
site disabled whatever the user's XML says, drops its <hhc> converter binding
so the room's files stop being recognised, and hides its menu entries. The code
and its tests stay in the tree; re-enabling is a one-line change there.
i18n.py provides gettext (translate now) and N_ (mark for extraction,
translate later β used for module-level data such as menu_layout.py).
i18n_compile.py compiles locale/fpdb-<lang>.po to .mo with no external
dependency, lazily at startup. See Translations.
fpdb_3_legacy/
βββ *ToFpdb.py # one converter per room
βββ iPoker/ # the iPoker converter, split into mixins
βββ Hand.py, Database.py # hand model and data layer
βββ Hud.py, HUD_main.pyw # the HUD
βββ fast_fold_engine.py, winamax_live_log_reader.py, winamax_ax_seats.py
βββ AutoNotes*.py # the note rule engine
βββ *_capture*.py # SwC and iPoker live capture
βββ Gui*.py # the GUI tabs and dialogs
βββ modern_*/ # the modern preference dialogs
βββ fpdb.pyw # GUI entry point
βββ legacy_launcher.py # the `fpdb_3_legacy` console script
fpdb/infrastructure/platform/ # window detection and geometry
locale/ # 14 gettext catalogues
tests/fixtures/ # the golden-master corpus
tools/ # maintenance and release scripts
docs/ # equity engine, macOS Gatekeeper, SwC capture
Parser behaviour is locked by a golden-master corpus with per-hand invariant checks β see Adding a room parser.
make test # main suite, excluding the GUI
make test-all # including the GUI
make lint && make formatCoverage is enforced as a ratchet: floors in coverage-baseline.json may rise,
never fall.