Skip to content

Fix core->api layering inversion in create_app() #46

Description

@tschm

Subcategory: Overall architecture
Score: 7 → 9 (target)

The import graph has a layer inversion: core/server.py (lower layer) imports the api layer.

  • src/pycharting/core/server.py:201create_app() does a deferred from pycharting.api.routes import router to mount API routes. The function-local import is the classic "break the cycle" smell; app composition belongs at a top-level composition root, not in core.
  • Shared mutable module globals couple modules through global state: _data_managers (api/routes.py:26) and _active_server (api/interface.py:32).

No true import cycle exists today, but the dependency direction is inverted.

Suggested fix: move router-mounting/app assembly to a dedicated composition module (or __init__), and encapsulate the session registry behind an object rather than a module global.

Done when: no module under src/pycharting/core/ imports pycharting.api (deferred or otherwise).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions