Skip to content

Refactor: Separate Core Logic from UI for CLI/GUI Independence #22

Description

@totalbrain

Description
Separate the core optimization logic from the UI to make the app modular. The core should handle input/output independently (e.g., console, file, event viewer) without relying on Tkinter. This is like logging systems that output to multiple sinks.

Why this is useful?

  • Enables CLI mode (--terminal) without GUI dependencies
  • Makes output flexible (console, file, notification, etc.)
  • Improves maintainability and testability
  • Allows future extensions (web API, integration with other tools)
  • Reduces main.py length by modularizing

Implementation Ideas

  • Create src/core.py for all optimizations (apply_optimizations)
  • Use abstract I/O handlers (e.g., ConsoleOutput, FileOutput)
  • Main entry: Check args --gui / --terminal and load appropriate mode
  • Example structure:
    • src/core.py: Pure functions for token crushing
    • src/ui.py: GUI logic (Tkinter)
    • src/cli.py: Console logic (argparse)
    • main.py: Parse args and route to UI or CLI

Additional context

  • Inspired by logging modules (console, file handlers)
  • Relates to issue #X (CLI version)
  • Test with pytest: Core independent of UI

Priority

  • Must-have

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions