Skip to content

Refactor: split deps.py into feature modules + reduce import graph #491

Description

@phernandez

Refactor: split deps.py into feature modules + reduce import graph

Why

basic_memory/deps.py currently centralizes many unrelated dependency factories (DB/session, repositories, services, sync/watch, etc.). This increases coupling and the import graph; small changes ripple across unrelated features.

Scope

  • Split dependency wiring into feature-scoped modules:
    • basic_memory/deps/db.py
    • basic_memory/deps/projects.py
    • basic_memory/deps/services.py
    • basic_memory/deps/sync.py
    • basic_memory/deps/http.py
  • Keep deps.py as a temporary thin re-export layer during migration (optional), then delete it once callers are migrated.

Acceptance criteria

  • Routers/tools only import the deps they need (no global deps.py imports for unrelated deps).
  • Import graph is measurably smaller (qualitative is fine: fewer cross-module imports; no new circulars).
  • Tests pass (SQLite + Postgres-focused runs).

Dependencies

  • Best done after composition roots are introduced (see the container issue), but can start in parallel.

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

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions