Split webui into Flask blueprints and data domain modules

- Split app.py (66 routes) into 3 blueprints: pages (public), api (JSON), admin (@admin_required)
- Split data.py (4,360 LOC) into 7 domain modules: drafts, authors, ratings, gaps, analysis, search, proposals
- Add data/__init__.py re-exporting all public functions for backward compatibility
- Add custom 404/500 error pages matching dark theme
- Add request timing logging via before_request/after_request hooks
- Refactor app.py into create_app() factory pattern
- All 106 tests pass, all 66 routes preserved

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 03:37:15 +01:00
parent c066b04d74
commit 3fb17100d7
17 changed files with 4144 additions and 5170 deletions

View File

@@ -0,0 +1,97 @@
"""Data access layer for the web dashboard.
Thin wrapper around ietf_analyzer.db.Database that returns plain dicts
ready for JSON serialization or Jinja2 template rendering.
All public functions are re-exported here for backward compatibility:
from webui.data import get_overview_stats
"""
from __future__ import annotations
# Shared utilities
from webui.data._shared import get_db, _cached, _extract_month # noqa: F401
# Drafts
from webui.data.drafts import ( # noqa: F401
OverviewStats,
DraftListItem,
DraftsPage,
get_overview_stats,
get_category_counts,
get_category_summary,
get_drafts_page,
get_draft_detail,
get_generated_drafts,
read_generated_draft,
)
# Authors
from webui.data.authors import ( # noqa: F401
AuthorInfo,
AuthorNetworkNode,
AuthorNetworkEdge,
AuthorCluster,
AuthorNetwork,
get_top_authors,
get_org_data,
get_coauthor_network,
get_cross_org_data,
get_author_network_full,
)
# Ratings
from webui.data.ratings import ( # noqa: F401
get_rating_distributions,
get_category_radar_data,
get_score_histogram,
get_false_positive_profile,
)
# Gaps
from webui.data.gaps import ( # noqa: F401
get_all_gaps,
get_gap_detail,
)
# Analysis & Visualization
from webui.data.analysis import ( # noqa: F401
TimelineData,
SimilarityGraphStats,
SimilarityGraph,
CitationGraphStats,
CitationGraph,
MonitorCost,
MonitorPipeline,
MonitorStatus,
get_ideas_by_type,
get_timeline_data,
get_similarity_graph,
get_idea_clusters,
get_timeline_animation_data,
get_monitor_status,
get_citation_graph,
get_landscape_tsne,
get_comparison_data,
get_architecture,
get_idea_analysis,
get_trends_data,
get_complexity_data,
get_source_comparison,
get_citation_influence,
get_bcp_analysis,
)
# Search
from webui.data.search import ( # noqa: F401
SearchResults,
global_search,
get_ask_search,
get_ask_synthesize,
)
# Proposals
from webui.data.proposals import ( # noqa: F401
get_all_proposals,
get_proposal_detail,
get_proposals_for_gap,
)