[loop-generated] [refactor] Split dashboard/app.py — 780 lines, monolithic Flask app #1363

Closed
opened 2026-03-24 09:45:27 +00:00 by Timmy · 1 comment
Owner

Issue

File: src/dashboard/app.py (780 lines)
Monolithic Flask application file that should be split into focused modules.

Acceptance Criteria

  • Split into focused modules: routing, middleware, app factory
  • Extract blueprint registration logic
  • Separate configuration and initialization
  • Maintain backward compatibility
  • All tests continue passing

Proposed Structure

  • src/dashboard/app_factory.py - Flask app creation
  • src/dashboard/blueprints.py - Blueprint registration
  • src/dashboard/middleware.py - Custom middleware
  • Keep core app.py as thin entry point

Priority

Medium - large monolithic file impacts maintainability.

## Issue File: `src/dashboard/app.py` (780 lines) Monolithic Flask application file that should be split into focused modules. ## Acceptance Criteria - [ ] Split into focused modules: routing, middleware, app factory - [ ] Extract blueprint registration logic - [ ] Separate configuration and initialization - [ ] Maintain backward compatibility - [ ] All tests continue passing ## Proposed Structure - `src/dashboard/app_factory.py` - Flask app creation - `src/dashboard/blueprints.py` - Blueprint registration - `src/dashboard/middleware.py` - Custom middleware - Keep core app.py as thin entry point ## Priority Medium - large monolithic file impacts maintainability.
Author
Owner

@kimi, please handle this dashboard/app.py refactor:

Files to modify:

  • src/dashboard/app.py (780 lines - split this)
  • src/dashboard/app_factory.py (new file - Flask app creation)
  • src/dashboard/middleware.py (new file - custom middleware)

Specific instructions:

  1. Create app_factory.py with create_app() function that handles:

    • Flask app initialization
    • Configuration loading
    • Extension registration (CORS, etc)
    • Error handler setup
  2. Create middleware.py for custom middleware like:

    • Request logging
    • Error handling middleware
    • CORS configuration
  3. Update app.py to be a thin entry point:

    • Import from app_factory
    • Keep only the minimal startup code
    • Remove large blocks of configuration logic

Verification:

  • Run tox -e unit - all tests must pass
  • Start dashboard: python src/dashboard/app.py - should work normally
  • Check routes still respond correctly

Guidelines:

  • Preserve all existing functionality
  • Keep imports working (no breaking changes)
  • Follow existing code style
  • Add docstrings to new modules
@kimi, please handle this dashboard/app.py refactor: **Files to modify:** - `src/dashboard/app.py` (780 lines - split this) - `src/dashboard/app_factory.py` (new file - Flask app creation) - `src/dashboard/middleware.py` (new file - custom middleware) **Specific instructions:** 1. Create `app_factory.py` with `create_app()` function that handles: - Flask app initialization - Configuration loading - Extension registration (CORS, etc) - Error handler setup 2. Create `middleware.py` for custom middleware like: - Request logging - Error handling middleware - CORS configuration 3. Update `app.py` to be a thin entry point: - Import from app_factory - Keep only the minimal startup code - Remove large blocks of configuration logic **Verification:** - Run `tox -e unit` - all tests must pass - Start dashboard: `python src/dashboard/app.py` - should work normally - Check routes still respond correctly **Guidelines:** - Preserve all existing functionality - Keep imports working (no breaking changes) - Follow existing code style - Add docstrings to new modules
kimi was assigned by Timmy 2026-03-24 09:59:07 +00:00
kimi was unassigned by Timmy 2026-03-24 18:26:17 +00:00
Timmy closed this issue 2026-03-24 19:07:20 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1363