- Update frontend stack description in README - Add detailed architecture and module responsibilities in ARCHITECTURE_MAP.md - Update PLAN_REFACTO_COMPLET_MAJOOR_ASSETS_MANAGER.md with latest changes
4.0 KiB
4.0 KiB
Architecture Map
Version: 2.4.5
Last Updated: April 10, 2026
This map is the working reference for backend refactors. It is intentionally short and operational.
Package Responsibilities
mjr_am_backend/routes- HTTP surface only.
- Parse request data, apply auth/CSRF/rate-limit guards, call services, map
Resultpayloads. route_catalog.py— declarative route registry (RouteRegistrationdataclass, CORE + OPTIONAL catalogs).
mjr_am_backend/routes/core- Shared route helpers for security, path rules, JSON parsing, responses, and service resolution.
mjr_am_backend/routes/assets- Thin compatibility facades re-exporting from
features/assets/.
- Thin compatibility facades re-exporting from
mjr_am_backend/features- Business logic and orchestration by domain: index, metadata, collections, browser, health, tags, viewer.
mjr_am_backend/features/assets- Asset domain sub-services:
lookup_service— asset lookups and queriesdownload_service— download/streaming logicrating_tags_service— ratings, tags, collectionsrequest_context_service— request parsing and context extractionpath_resolution_service— root/subfolder/path resolutiondelete_service— asset deletionrename_service— asset renamingfilename_validator— filename validation rulesmodels— shared data modelsservice— thin compatibility facade
- Asset domain sub-services:
mjr_am_backend/adapters- Boundary code for SQLite, filesystem watchers, external tools, and other integration points.
mjr_am_backend/adapters/dbsqlite_facade.py— main entry point for DB access (~1900 L)sqlite_connections.py— connection pool, pragmas, acquire/releasesqlite_execution.py— query execution, timeout, retry, batchsqlite_lifecycle.py— transactions, reset, WAL, Windows file-handle managementsqlite_recovery.py— malformed recovery, FTS rebuild, schema repairschema.py(331 L) +schema_sql.py,schema_fts.py,schema_vec.py— DDL and migrationconnection_pool.py,db_recovery.py,transaction_manager.py— lower-level helpers
mjr_am_shared- Shared result types, error definitions, logging, time helpers, and cross-cutting utilities.
Frontend
- Vue 3 + Pinia for all major UI surfaces (grid, sidebar, feed, context menus, settings).
js/vue/— Vue components and stores.js/features/— feature-scoped JS modules.js/stores/— Pinia stores.- Imperative runtime services remain for viewer, DnD, and ComfyUI integration (by design).
Request Flow
UI action -> route handler -> route/core helper -> feature service -> adapter -> DB/filesystem/tool -> Result response -> UI mapping
Rules:
- Routes do not decide filesystem or security policy locally.
- Services own business rules and orchestration.
- Adapters isolate external side effects.
security.pyis the single policy entry point for auth, write access, safe mode, trusted proxies, and CSRF.
Watcher And Index Flow
Filesystem event -> watcher scope/runtime -> index orchestration -> DB update -> UI refresh event
Hot zones:
- watcher lifecycle and scope resolution
- reset/rebuild orchestration
- metadata probing and vector backfill
- live viewer synchronization
These zones should be refactored behind stable service facades before adding new behavior.
Security Rules
- Public API base stays
/mjr/am/*. - Backend returns structured
Resultpayloads for expected errors. - Safe mode is enabled by default.
- Remote write remains denied without a valid token.
- Loopback write is allowed by default in the current compatibility model unless
MAJOOR_REQUIRE_AUTH=1is set.
Naming And Internal API Conventions
- Public internal APIs should be thin, stable facades under
features/*orroutes/core/*. - Route modules may import facades and helpers, but should not directly orchestrate storage internals across multiple subsystems.
- New security-sensitive mutations must call shared security and path helpers instead of duplicating checks.