How nschaefer1/jockle works
1. Overall shape
- Jockle is a Windows desktop app packaged around a Python host process and a HTML/CSS/JavaScript UI rendered inside PyWebview.
- The repository is organized as a small desktop shell plus a local application backend and a file-based database layer.
2. Application entry and runtime boundary
- main.py is the launch point.
- It likely creates the webview window, wires the backend object into the frontend, and starts the app lifecycle.
- This is the key boundary: native Python runtime on one side, browser-like UI on the other.
3. Frontend subsystem
- frontend/html/ contains the screens: characters.html, inventory.html, and a sub-screen for creating inventories.
- frontend/css/global.css provides shared styling.
- frontend/js/router.js suggests a client-side screen/navigation layer, while inventory.js and inventory_sub/new_inventory.js handle page-specific interaction logic.
- The frontend is static and local; it does not appear to be a public web app.
4. Frontend-to-backend interaction
- The JavaScript layer acts as the interaction middleware for user actions.
- UI events likely call into the Python backend through the PyWebview bridge rather than via HTTP over a network.
- That separation matters for the architecture: UI is presentation and event handling, while Python owns state, persistence, and business rules.
5. Backend API layer
- backend/api.py is the main backend interface exposed to the frontend.
- backend/base_api.py and the backend/api_requests/ package split behavior by operation type: get.py, post.py, put.py, patch.py, and delete.py.
- This indicates a request-dispatch pattern where frontend actions are mapped to CRUD-style handlers.
6. Application/domain management
- managers/main_app.py appears to coordinate higher-level app behavior, likely campaign/character/inventory workflows.
- This layer is the likely place where the app’s business logic lives: selecting campaigns, managing characters, and updating inventory state.
- It acts as a bridge between the API surface and the lower-level data layer.
7. Persistence and database access
- managers/db_manager.py centralizes access to the local database.
- The app uses SQLite, consistent with the README’s “local relational database” goal.
- SQL is stored separately under sql/, which cleanly divides schema/query definitions from Python code.
8. Database design and seed data
- sql/create_dim.sql and sql/create_ft.sql suggest a dimensional / fact-style schema rather than a simple flat schema.
- The CSV seed files under sql/csv_seeds/ provide initial data for characters, inventories, and inventory statistics.
- Additional query files in sql/inventory/ indicate dedicated SQL for inventory views or lookup operations.
9. Static rules and game-specific data
- data/static_carry_cap.json likely stores encumbrance/carry-capacity rules used by the inventory system.
- The included Encumbrance Math.tex / .pdf reinforce that inventory weight/encumbrance is a meaningful domain rule, not just incidental data.
- This suggests a small rules/data layer separate from the database.
10. Asset and icon subsystem
- frontend/assets/icons/ is organized by content type: accessories, armor, items, misc, weapons, and custom.
- managers/icon_manager.py likely maps inventory items or categories to the correct icon asset.
- This keeps UI rendering independent from business logic and avoids hardcoding file paths in the frontend.
11. Shared models and return contracts
- models/api_response.py and models/db_return.py define structured outputs for backend calls and database operations.
- These models are the contract boundary between backend services and the frontend caller, helping standardize success/error payloads.
12. Utility layer
- utils/file_utils.py, json_utils.py, and logging_utils.py provide cross-cutting support functions.
- These are infrastructure helpers rather than domain logic, likely used by both backend services and managers.
13. Primary data flow
- User opens the desktop app → PyWebview loads local HTML/CSS/JS → frontend navigation selects a screen → JS calls backend methods → backend routes to the correct request handler or manager → database and static data are read/updated → structured response returns to the UI → UI refreshes.
14. Key architectural boundaries
- Presentation boundary: frontend HTML/CSS/JS.
- Application logic boundary: backend API and managers.
- Persistence boundary: SQLite via SQL scripts and the DB manager.
- Static content boundary: icons and JSON rule data.
- The repo is intentionally split so UI, rules, and storage can evolve independently as campaign and inventory features expand.
Main entry points: api.py API facade · main_app.py Main app · router.js Router · inventory.js Inventory JS
Components 17
Desktop runtime
Native Python host and local web UI boundary.
- main.py · Launches the desktop app and starts the PyWebview lifecycle.
main.py - Router · Client-side screen switching and page coordination.
frontend/js/router.js - Inventory JS · Inventory screen interactions and frontend event handling.
frontend/js/inventory.js - New Inventory JS · Create-inventory subflow logic.
frontend/js/inventory_sub/new_inventory.js - Characters UI · Character-focused HTML view.
frontend/html/characters.html - Inventory UI · Primary inventory HTML view.
frontend/html/inventory.html - New Inventory UI · Inventory creation sub-screen.
frontend/html/inventory_sub/new_inventory.html
Backend logic
API surface, request handlers, and app orchestration.
- API facade · Main interface exposed to the frontend bridge.
backend/api.py - Base API · Shared API behavior and dispatch support.
backend/base_api.py - CRUD handlers · Operation-specific backend request modules.
backend/api_requests - Main app · Coordinates app workflows and domain operations.
managers/main_app.py
Data layer
Database access, SQL assets, and static rule data.
- DB manager · Centralized SQLite access and query execution.
managers/db_manager.py - SQL scripts · Schema, fact/dimension setup, and inventory queries.
sql - Carry rules · Static encumbrance and carry-capacity rule data.
data/static_carry_cap.json
Shared support
Contracts, utilities, and asset mapping used across layers.
- Icon manager · Resolves item and category icons for the UI.
managers/icon_manager.py - Response models · Structured backend and database return types.
models - Utilities · File, JSON, and logging helpers used across the app.
utils
Connections 21
- main.py → Router: loads UI · The desktop host initializes the local webview UI.
- main.py → API facade: injects backend · The Python host exposes backend methods to the frontend bridge.
- Router → Inventory JS: navigates · Router selects the inventory screen behavior.
- Router → Characters UI: shows · Router switches to the characters view.
- Router → Inventory UI: shows · Router switches to the inventory view.
- Inventory JS → New Inventory JS: opens flow · Inventory interactions lead into the create-inventory subflow.
- Inventory UI → Inventory JS: binds · Inventory page markup is driven by its page script.
- New Inventory UI → New Inventory JS: binds · Create-inventory markup is driven by its page script.
- Inventory JS → API facade: calls · User actions are sent through the PyWebview bridge.
- New Inventory JS → API facade: calls · Inventory creation actions invoke backend methods.
- API facade → Base API: extends · The main API builds on shared API dispatch behavior.
- API facade → CRUD handlers: dispatches · API calls are routed to CRUD-style request modules.
- CRUD handlers → Main app: orchestrates · Request handlers delegate app workflows to the main application layer.
- Main app → DB manager: persists · Application logic reads and writes through the database manager.
- DB manager → SQL scripts: executes · SQL definitions and inventory queries back the persistence layer.
- Main app → Carry rules: applies rules · Business logic uses carry-capacity and encumbrance data.
- Main app → Icon manager: resolves assets · Domain objects are mapped to UI icons through the asset manager.
- API facade → Response models: returns · Backend responses are normalized through shared models.
- DB manager → Response models: returns · Database operations use structured return contracts.
- API facade → Utilities: uses · Backend layers rely on shared file, JSON, and logging helpers.
- Main app → Utilities: uses · Application orchestration uses common helper functions.