Old: app.py (monolithic) → New: domain/ + routers/ (modular)
| Section | Function | Line | Size |
|---|---|---|---|
| AI Commentary | get_ai_roast(username, stats) | L1472 | 83L |
| AI Commentary | generate_roast_for_user(username, stats) | L1564 | 6L |
| AI Commentary | get_ai_performance_analysis(username, profile_stats, all_time_lb...) | L1572 | 119L |
| AI Commentary | generate_performance_analysis(username, profile_stats, all_time_lb...) | L1693 | 20L |
| AI Commentary | get_month_events_tips(db, month_str) | L1966 | 108L |
| AI Integration | _clamp_int(value, low, high) | L333 | 7L |
| AI Integration | _tone_level(value) | L342 | 11L |
| AI Integration | resolve_tone_config(settings) | L355 | 41L |
| AI Integration | get_openai_client_class() | L434 | 5L |
| AI Integration | get_plotly_go() | L442 | 5L |
| AI Integration | get_competition_ai_guardrails() | L541 | 11L |
| AI Integration | is_ai_error_response(text) | L554 | 5L |
| AI Live Commentary | get_forecast_submission_commentary(db, username, month_str...) | L2553 | 66L |
| Auth & Password | send_firebase_password_reset_email(email, db) | L5258 | 24L |
| Auth & Password | verify_firebase_email_password(email, password, db) | L5284 | 14L |
| Auth & Password | ensure_firebase_auth_user(email, display_name) | L5300 | 33L |
| Auth & Password | firebase_auth_user_exists(email) | L5335 | 17L |
| Auth & Password | get_firebase_auth_email_set() | L5354 | 18L |
| Auth & Password | should_store_local_password_hash(db) | L5374 | 7L |
| Auth & Password | sync_password_to_firebase_auth(email, password, display_name) | L5383 | 22L |
| Auth & Password | request_password_reset_for_user(db, username, user_data...) | L5425 | 59L |
| Caching | save_local_data(data) | L3669 | 10L |
| Caching | set_cached_data(cache_key, data, ttl_seconds) | L3707 | 7L |
| Caching | clear_leaderboard_related_caches() | L3731 | 10L |
| Caching | clear_forecast_related_caches() | L3743 | 4L |
| Email System | get_firebase_web_api_key(db) | L3835 | 11L |
| Email System | _next_month_str(month_str) | L4052 | 11L |
| Email System | _build_metric_rows_for_results(scores, actuals, metric_type) | L4074 | 115L |
| Email System | _build_forecast_rows_for_metric(forecasts_map, metric_type) | L4191 | 35L |
| Email System | build_forecast_lock_email_content(db, month, month_label...) | L4228 | 162L |
| Email System | get_metric_results_email_commentary(db, month, metric_name...) | L4392 | 37L |
| Email System | build_results_published_email_content(db, month, month_label...) | L4431 | 262L |
| Email System | create_event_email_log(db, entry) | L4831 | 14L |
| Email System | mark_event_email_log_retried(db, log_id, retry_by...) | L4912 | 22L |
| Email System | retry_event_email_from_log(db, log_id, retry_by) | L4936 | 24L |
| Firebase Init | get_local_data() | L3651 | 16L |
| Forecasts & Scoring | get_actuals_for_scoring(db, month, monthly_df) | L6425 | 22L |
| Forecasts & Scoring | _fetch_dropbox_data_internal() | L6454 | 77L |
| Leaderboard State | official_pts(s) | L2094 | 9L |
| Leaderboard State | get_previous_leaderboard_state(db, metric_type, month_str) | L2198 | 13L |
| Leaderboard State | get_movement_indicator(username, current_rank, prev_state...) | L2242 | 31L |
| Login Tokens | hash_token(token) | L5623 | 3L |
| Login Tokens | save_login_token(db, username, token...) | L5628 | 15L |
| User Management | is_email_in_use(db, email, exclude_username) | L3783 | 25L |
| Function | Line | Size |
|---|---|---|
| df_to_image | L629 | 104L |
| plotly_to_image | L735 | 9L |
| generate_whatsapp_text | L1073 | 30L |
| Old Name | New Name | Match | New File |
|---|---|---|---|
| init_firebase | _init_firebase | 100% | domain/firebase.py |
| normalize_email | _normalize_email | 100% | domain/email.py |
| is_valid_email | _is_valid_email | 100% | domain/email.py |
| get_sast_now | _get_sast_now | 100% | domain/scheduler.py |
| send_app_event_email | _send_app_event_email | 100% | domain/email.py |
| get_first_workday_of_month | _get_first_workday_of_month | 100% | domain/scheduler.py |
| build_ai_tone_directive | build_tone_directive | 93% | domain/ai.py |
| get_month_end_commentary | generate_month_end_commentary | 91% | domain/ai.py |
| get_rivals_commentary | generate_rivals_commentary | 89% | domain/ai.py |
| get_leaderboard_mode_flags | get_leaderboard_flags | 89% | domain/settings.py |
| send_winners_announcement_email | send_winners_announcement | 89% | domain/email.py |
| _get_current_username | get_current_user | 89% | routers/pages.py |
| get_ai_settings | get_settings | 89% | domain/settings.py |
| count_recent_bulk_event_sends | _count_recent_bulk_sends | 88% | domain/email.py |
| fetch_dropbox_data | get_dropbox_data | 88% | domain/dropbox.py |
| get_live_leaderboard_commentary | generate_leaderboard_commentary | 87% | domain/ai.py |
| get_event_email_recipients | get_email_recipients | 87% | domain/email.py |
| get_analyst_tips | generate_analyst_tips | 86% | domain/ai.py |
| send_event_smtp_email | send_event_email | 86% | domain/email.py |
| get_monthly_actuals | extract_monthly_actuals | 86% | domain/scoring.py |
| generate_whatsapp_leaderboard_image | generate_leaderboard_image | 85% | domain/image_export.py |
| get_event_email_config | get_email_config | 84% | domain/email.py |
| set_user_email | get_user_by_email | 84% | domain/auth.py |
| get_forecast | get_user_forecast | 83% | domain/forecasts.py |
| get_annual_pot_commentary | generate_annual_commentary | 82% | domain/ai.py |
| send_event_resend_email | send_event_email | 82% | domain/email.py |
| get_cache_key | get_cache | 82% | domain/cache.py |
| get_profile_rankings_commentary | generate_rankings_commentary | 81% | domain/ai.py |
| validate_login_token | validate_session_token | 81% | domain/auth.py |
| get_profile_badges_commentary | generate_badges_commentary | 80% | domain/ai.py |
| find_user_by_email | get_user_by_email | 80% | domain/auth.py |
| get_user_fyi_leaderboard_preferences | get_user_fyi_preferences | 80% | domain/settings.py |
| set_user_fyi_leaderboard_preferences | set_user_fyi_preferences | 80% | domain/settings.py |
| get_locked_actuals | lock_actuals | 80% | routers/admin.py |
| calculate_annual_leaderboard | get_annual_leaderboard | 80% | domain/leaderboard.py |
| calculate_all_time_leaderboard | get_alltime_leaderboard | 79% | domain/leaderboard.py |
| highlight_current_user | get_current_user | 79% | routers/pages.py |
| get_event_email_log | get_recent_emails | 78% | domain/email.py |
| save_locked_actuals | lock_actuals | 77% | routers/admin.py |
| get_recent_event_email_logs | get_recent_emails | 77% | domain/email.py |
| get_all_forecasts | get_all_forecasts_for_month | 77% | domain/forecasts.py |
| delete_locked_actuals | delete_locked | 76% | routers/admin.py |
| get_user | get_all_users | 76% | domain/users.py |
| get_previous_month | auto_lock_previous_month | 76% | domain/scheduler.py |
| reserve_event_email_idempotency | _reserve_idempotency | 76% | domain/email.py |
| render_recent_final_results_panel | recent_results_panel | 75% | routers/fragments.py |
| get_cached_data | get_cache | 75% | domain/cache.py |
| _get_event_email_setting | get_recent_emails | 75% | domain/email.py |
| get_bonus_rules_for_month | get_bonus_rules | 75% | domain/settings.py |
| display_detailed_monthly_leaderboard | get_monthly_leaderboard | 75% | domain/leaderboard.py |
| get_user_profile_stats | profile_stats | 74% | routers/fragments.py |
| update_settings | get_settings | 74% | domain/settings.py |
| set_user_must_change_password | set_user_password | 74% | domain/auth.py |
| save_leaderboard_state | leaderboard_page | 74% | routers/pages.py |
| change_password_page | needs_password_change | 73% | domain/auth.py |
| check_event_email_rate_limit | _check_rate_limit | 73% | domain/email.py |
| calculate_monthly_scores | build_monthly_scores | 73% | domain/scoring.py |
| get_cached_roast | get_cache | 72% | domain/cache.py |
| generate_login_token | generate_ai_content | 72% | domain/ai.py |
| get_latest_sales_date | get_latest_month_data | 71% | domain/dropbox.py |
| get_mtd_data | get_dropbox_data | 71% | domain/dropbox.py |
| send_event_notification_email | send_event_email | 71% | domain/email.py |
| delete_login_token | delete_locked | 71% | routers/admin.py |
| get_all_locked_actuals | lock_actuals | 71% | routers/admin.py |
| get_openai_client | get_email_recipients | 70% | domain/email.py |
| get_user_current_rank | get_current_user | 70% | routers/pages.py |
| display_live_detailed_leaderboard | get_live_mtd_leaderboard | 70% | domain/leaderboard.py |
| clear_cache | get_cache | 70% | domain/cache.py |
| can_send_reset_email_now | send_event_email | 70% | domain/email.py |
| admin_page | admin_logs | 70% | routers/admin.py |
| Section | Function | Size |
|---|---|---|
| Admin Pages | _calculate_monthly_scores_live | 18L |
| Admin Pages | warm_runtime_leaderboard_caches | 19L |
| Download Helpers | create_download_button | 34L |
| Formatting & UI Util | fmt_currency | 5L |
| Formatting & UI Util | fmt_percent | 5L |
| Formatting & UI Util | fmt_number | 5L |
| Leaderboard Display | get_sa_time | 3L |
| Leaderboard Display | _cached_dropbox_fetch | 34L |
| Leaderboard Display | force_refresh_dropbox_data | 19L |
| Leaderboard Display | get_sales_daily_preview | 39L |
| Leaderboard Display | extract_latest_sales_date_from_df | 21L |
| Leaderboard Display | build_runtime_page_context | 16L |
| Leaderboard Display | get_sidebar_data_status | 17L |
| Leaderboard Display | get_user_leaderboard_rank_summary | 127L |
| Leaderboard Display | get_precomputed_scores | 14L |
| Leaderboard Display | get_all_precomputed_scores | 22L |
| Leaderboard Display | precompute_and_store_monthly_scores | 36L |
| Other | calculate_forecast_twins | 117L |
| Other | calculate_monthly_breakdown | 107L |
| Other | parse_formatted_number | 10L |
| Other | format_with_commas | 6L |
| Other | get_rank_display | 15L |
| Other | parse_num | 14L |
| Other | get_stored_badges | 11L |
| Other | store_badges | 13L |
| Other | get_pwa_build_version | 30L |
| Other | main | 508L |
| Rank Display | get_rank_display_badge | 11L |
| Rank Display | get_sidebar_ranks | 26L |
| WhatsApp Export | _calc_col_widths | 19L |
| Function | Old | New Location |
|---|---|---|
| _due_reminder_slots_for_now | app.py:L6300 | domain/scheduler.py |
| _format_month_label | app.py:L4044 | domain/email.py |
| _get_forecast_auto_close_due_at | app.py:L6207 | domain/scheduler.py |
| _parse_iso_datetime | app.py:L4695 | domain/scheduler.py |
| assign_ranking_points | app.py:L7002 | domain/scoring.py |
| auto_lock_previous_month | app.py:L6106 | domain/scheduler.py |
| auto_open_next_month_forecast | app.py:L6158 | domain/scheduler.py |
| calculate_absolute_error | app.py:L6997 | domain/scoring.py |
| calculate_bonus_points | app.py:L7007 | domain/scoring.py |
| carry_over_forecasts | app.py:L5918 | domain/scheduler.py |
| create_user | app.py:L5486 | domain/users.py |
| forecast_page | app.py:L8358 | routers/pages.py |
| generate_ai_content | app.py:L490 | domain/ai.py |
| get_all_forecasts_for_month | app.py:L6019 | domain/forecasts.py |
| get_all_users | app.py:L5678 | domain/users.py |
| get_bonus_rules | app.py:L5865 | domain/settings.py |
| get_db | app.py:L3754 | domain/firebase.py |
| get_settings | app.py:L5701 | domain/settings.py |
| get_user_achievements | app.py:L7356 | domain/achievements.py |
| leaderboard_page | app.py:L9612 | routers/pages.py |
| login_page | app.py:L8096 | routers/pages.py |
| profile_page | app.py:L13632 | routers/pages.py |
| reserve_scheduler_run_slot | app.py:L4785 | domain/scheduler.py |
| reset_user_password | app.py:L5554 | domain/users.py |
| run_auto_close_forecast_window | app.py:L6251 | domain/scheduler.py |
| run_deadline_submission_reminders | app.py:L6319 | domain/scheduler.py |
| run_weekly_leaderboard_updates | app.py:L6386 | domain/scheduler.py |
| save_bonus_rules | app.py:L5875 | domain/settings.py |
| save_forecast | app.py:L5959 | domain/forecasts.py |
| scoring_rules_page | app.py:L14561 | routers/pages.py |
| set_user_password | app.py:L5588 | domain/auth.py |
| update_user_status | app.py:L5529 | domain/users.py |
| verify_password | app.py:L5696 | domain/auth.py |
Generated by SafairBru Gap Analysis · MC-392