refactor(api): split views_api.py into a package of domain modules

Pure move — no logic changes. The 4,100-line single file becomes
views_api/ with one module per domain (accounts, entries, payments,
settings_reports, reconciliation, permissions, admin), each
registering full literal paths on its own APIRouter; __init__ builds
the combined libra_api_router so libra/__init__.py is untouched.
Shared imports/helpers live in views_api/_shared.py;
_extract_entry_id and _SYSTEM_LINK_PREFIXES move to
beancount_format.py (they are pure entry-dict parsing).

Route behavior is pinned by tests/test_route_table.py: the 73-route
set is unchanged, and the two order-sensitive families (the shadowed
/accounts/hierarchy wart — deliberately preserved here, fixed in the
next commit — and the admin sync literal/param pair) keep their
relative order inside a single module each.

Addresses CODE-REVIEW-2026-06 structure findings (views_api monolith).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-07-12 16:09:58 +02:00
commit a7d7740a3a
12 changed files with 4233 additions and 4130 deletions

31
views_api/__init__.py Normal file
View file

@ -0,0 +1,31 @@
"""Libra API endpoints, split by domain.
Each module registers full literal paths on its own APIRouter; this
package includes them in a canonical order pinned by
tests/test_route_table.py. Route ORDER matters only for overlapping
patterns (literal vs {param} siblings) those live within a single
module so their relative order is stable regardless of include order.
"""
from fastapi import APIRouter
from . import (
accounts,
entries,
payments,
settings_reports,
reconciliation,
permissions,
admin,
)
libra_api_router = APIRouter()
for _module in (
accounts,
entries,
payments,
settings_reports,
reconciliation,
permissions,
admin,
):
libra_api_router.include_router(_module.router)