Commit Graph

743 Commits

Author SHA1 Message Date
fb8cb14506 refactor: rename public routes and templates to platform
Complete the public -> platform naming migration across the codebase.
This aligns with the naming convention where "platform" refers to
the marketing/public-facing pages of the platform itself.

Changes:
- Update all imports from public to platform modules
- Update template references from public/ to platform/
- Update route registrations to use platform prefix
- Update documentation to reflect new naming
- Update test files for platform API endpoints

Files affected:
- app/api/main.py - router imports
- app/modules/*/routes/*/platform.py - route definitions
- app/modules/*/templates/*/platform/ - template files
- app/modules/routes.py - route discovery
- docs/* - documentation updates
- tests/integration/api/v1/platform/ - test files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:49:39 +01:00
967f08e4ba feat: add module definition completeness validation and permissions
Add new validation rules MOD-020 to MOD-023 for module definition
completeness and standardize permissions across all modules.

Changes:
- Add MOD-020: Module definitions must have required attributes
- Add MOD-021: Modules with menus should have features
- Add MOD-022: Feature modules should have permissions
- Add MOD-023: Modules with routers should use get_*_with_routers pattern

Module permissions added:
- analytics: view, export, manage_dashboards
- billing: view_tiers, manage_tiers, view_subscriptions, manage_subscriptions, view_invoices
- cart: view, manage
- checkout: view_settings, manage_settings
- cms: view_pages, manage_pages, view_media, manage_media, manage_themes
- loyalty: view_programs, manage_programs, view_rewards, manage_rewards
- marketplace: view_integration, manage_integration, sync_products
- messaging: view_messages, send_messages, manage_templates
- payments: view_gateways, manage_gateways, view_transactions

Module improvements:
- Complete cart module with features and permissions
- Complete checkout module with features and permissions
- Add features to catalog module
- Add version to cms module
- Fix loyalty platform_router attachment
- Add path definitions to payments module
- Remove empty scheduled_tasks from dev_tools module

Documentation:
- Update module-system.md with new validation rules
- Update architecture-rules.md with MOD-020 to MOD-023

Tests:
- Add unit tests for module definition completeness
- Add tests for permission structure validation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:23:04 +01:00
30a5c75e74 refactor: remove backward compatibility layer for permissions
- Delete app/core/permissions.py (VendorPermissions enum, PermissionGroups)
- Update all code to use permission_discovery_service directly:
  - app/api/deps.py: get_user_permissions() uses discovery service
  - app/modules/tenancy/models/vendor.py: get_all_permissions() uses discovery
  - app/modules/tenancy/routes/api/vendor_team.py: use string literals
  - app/modules/tenancy/services/vendor_team_service.py: use discovery service
  - scripts/init_production.py: use discovery service for presets

Permissions are now fully module-driven:
- Each module defines permissions in definition.py
- PermissionDiscoveryService aggregates all permissions
- Role presets reference permission IDs directly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:49:11 +01:00
03395a9dfa refactor: implement module-driven permissions and relocate business logic
File Relocations:
- Delete app/config/ folder (empty after menu_registry removal)
- Move feature_gate.py → app/modules/billing/dependencies/
- Move theme_presets.py → app/modules/cms/services/

Module-Driven Permissions System:
- Add PermissionDefinition dataclass to app/modules/base.py
- Create PermissionDiscoveryService in tenancy module
- Update module definitions to declare their own permissions:
  - core: dashboard.view, settings.*
  - catalog: products.*
  - orders: orders.*
  - inventory: stock.*
  - customers: customers.*
  - tenancy: team.*
- Update app/core/permissions.py to use discovery service
- Role presets (owner, manager, staff, etc.) now use module permissions

This follows the same pattern as module-driven menus:
- Each module defines its permissions in definition.py
- PermissionDiscoveryService aggregates all permissions at runtime
- Tenancy module handles role-to-permission assignment

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:42:13 +01:00
31e3d0fcba refactor: remove deprecated menu_registry.py in favor of module-driven menus
- Delete app/config/menu_registry.py (centralized menu definitions)
- Update app/config/__init__.py to remove menu_registry exports
- Migrate menu_service.py to use menu_discovery_service exclusively
- Add helper methods to menu_discovery_service.py:
  - get_all_menu_item_ids() - get all item IDs for a frontend type
  - get_menu_item() - get specific menu item by ID
  - is_super_admin_only_item() - check if item is super-admin only
  - get_menu_item_module() - get module code for a menu item

Menu items are now defined in each module's definition.py file and
aggregated by MenuDiscoveryService at runtime, enabling true
module-driven architecture.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:29:03 +01:00
c13eb8d8c2 fix: resolve all architecture validation warnings
JavaScript improvements:
- Add try/catch error handling to all async init() functions
- Move initialization guards before try/catch blocks (JS-005)
- Use centralized logger in i18n.js with silent fallback (JS-001)
- Add loading state to icons-page.js (JS-007)

Payments module structure:
- Add templates/, static/, and locales/ directories (MOD-005)
- Add locale files for en, de, fr, lb (MOD-006)

Architecture validation now passes with 0 errors, 0 warnings, 0 info.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:21:03 +01:00
d7a0ff8818 refactor: complete module-driven architecture migration
This commit completes the migration to a fully module-driven architecture:

## Models Migration
- Moved all domain models from models/database/ to their respective modules:
  - tenancy: User, Admin, Vendor, Company, Platform, VendorDomain, etc.
  - cms: MediaFile, VendorTheme
  - messaging: Email, VendorEmailSettings, VendorEmailTemplate
  - core: AdminMenuConfig
- models/database/ now only contains Base and TimestampMixin (infrastructure)

## Schemas Migration
- Moved all domain schemas from models/schema/ to their respective modules:
  - tenancy: company, vendor, admin, team, vendor_domain
  - cms: media, image, vendor_theme
  - messaging: email
- models/schema/ now only contains base.py and auth.py (infrastructure)

## Routes Migration
- Moved admin routes from app/api/v1/admin/ to modules:
  - menu_config.py -> core module
  - modules.py -> tenancy module
  - module_config.py -> tenancy module
- app/api/v1/admin/ now only aggregates auto-discovered module routes

## Menu System
- Implemented module-driven menu system with MenuDiscoveryService
- Extended FrontendType enum: PLATFORM, ADMIN, VENDOR, STOREFRONT
- Added MenuItemDefinition and MenuSectionDefinition dataclasses
- Each module now defines its own menu items in definition.py
- MenuService integrates with MenuDiscoveryService for template rendering

## Documentation
- Updated docs/architecture/models-structure.md
- Updated docs/architecture/menu-management.md
- Updated architecture validation rules for new exceptions

## Architecture Validation
- Updated MOD-019 rule to allow base.py in models/schema/
- Created core module exceptions.py and schemas/ directory
- All validation errors resolved (only warnings remain)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:02:56 +01:00
09d7d282c6 refactor: complete JS i18n migration for confirm dialogs and toast messages
Migrate 34 hardcoded user-facing strings to use I18n.t() for translation:

- CMS: media file operations (5 strings)
- Marketplace: Letzshop integration (16 strings)
- Messaging: notifications, messages, email templates (5 strings)
- Tenancy: platform modules, menu config, theme (5 strings)
- Core: menu config, settings, storefront cart (5 strings)
- Catalog: product creation (3 strings)
- Utils: clipboard operations (2 strings)

Added confirmations and messages keys to module locale files.
Added I18n.loadModule() calls to JS files that were missing them.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 17:29:13 +01:00
1d78085085 docs: update documentation consolidation plan status
Mark documentation consolidation plan as mostly complete:
- All session notes archived
- All implementation plans archived
- Only future feature proposals remain in proposals/

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:38:20 +01:00
4e28d91a78 refactor: migrate templates and static files to self-contained modules
Templates Migration:
- Migrate admin templates to modules (tenancy, billing, monitoring, marketplace, etc.)
- Migrate vendor templates to modules (tenancy, billing, orders, messaging, etc.)
- Migrate storefront templates to modules (catalog, customers, orders, cart, checkout, cms)
- Migrate public templates to modules (billing, marketplace, cms)
- Keep shared templates in app/templates/ (base.html, errors/, partials/, macros/)
- Migrate letzshop partials to marketplace module

Static Files Migration:
- Migrate admin JS to modules: tenancy (23 files), core (5 files), monitoring (1 file)
- Migrate vendor JS to modules: tenancy (4 files), core (2 files)
- Migrate shared JS: vendor-selector.js to core, media-picker.js to cms
- Migrate storefront JS: storefront-layout.js to core
- Keep framework JS in static/ (api-client, utils, money, icons, log-config, lib/)
- Update all template references to use module_static paths

Naming Consistency:
- Rename static/platform/ to static/public/
- Rename app/templates/platform/ to app/templates/public/
- Update all extends and static references

Documentation:
- Update module-system.md with shared templates documentation
- Update frontend-structure.md with new module JS organization

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:34:16 +01:00
843703258f chore: delete empty app/routes directory
The legacy route files were migrated to modules. The directory only
contained an empty __init__.py. Updated docs to reflect new location.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:23:26 +01:00
6d7accfa25 fix: resolve circular import in module system
The circular import occurred because:
1. app.modules.base imported FrontendType from models.database.admin_menu_config
2. This triggered models/database/__init__.py which runs model discovery
3. Model discovery imported module definitions
4. Module definitions imported from app.modules.base (still initializing)

Solution: Move FrontendType and MANDATORY_MENU_ITEMS to a new
app/modules/enums.py file. The models file re-exports them for
backward compatibility with existing imports.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:21:07 +01:00
66f9600286 fix: remove broken dev_tools router references after API route migration
The dev_tools API routes were moved to the monitoring module, but several
files still tried to import the non-existent admin_router. This caused
warnings during app startup.

Changes:
- Remove _get_admin_router() from definition.py
- Clear routes/__init__.py and routes/api/__init__.py of broken imports
- Update exceptions.py to import from monitoring.exceptions
- Update code_quality_service.py to import from monitoring.exceptions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:18:02 +01:00
7639ca602b refactor: migrate messaging and media routes to modules
Messaging module (communication):
- vendor_messages.py: Conversation and message management
- vendor_notifications.py: Vendor notifications
- vendor_email_settings.py: SMTP and provider configuration
- vendor_email_templates.py: Email template customization

CMS module (content management):
- vendor_media.py: Media library management
- vendor_content_pages.py: Content page overrides

All routes auto-discovered via is_self_contained=True.
Deleted 5 legacy files from app/api/v1/vendor/.
app/api/v1/vendor/ now empty except for __init__.py (auto-discovery only).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:21:25 +01:00
da3f28849e refactor: migrate vendor auth, profile, team, dashboard, settings to modules
Tenancy module (identity & organizational hierarchy):
- vendor_auth.py: login, logout, /me endpoints
- vendor_profile.py: vendor profile get/update
- vendor_team.py: team management, roles, permissions, invitations

Core module (foundational non-domain features):
- vendor_dashboard.py: dashboard statistics
- vendor_settings.py: localization, business info, letzshop settings

All routes auto-discovered via is_self_contained=True.
Deleted 5 legacy files from app/api/v1/vendor/.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:09:41 +01:00
d747f9ebaa docs: add tenancy module migration plan and session notes
DOCUMENTATION:
- docs/architecture/tenancy-module-migration.md
  - Complete migration plan for tenancy module
  - Files to migrate: routes, services, models, schemas
  - Files to keep in root (framework level)
  - Files for other modules (messaging, cms, monitoring, core)
  - Target module structure
  - Recommended migration order

- docs/proposals/SESSION_NOTE_2026-01-31_tenancy-module-consolidation.md
  - Session summary and key decisions
  - Module ownership assignments
  - Next actions and priorities

Key principle: Tenancy owns identity and organizational hierarchy.
Everything else belongs to feature modules.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 14:52:13 +01:00
23d59492b7 refactor: move vendor info endpoint to tenancy module
MIGRATION:
- Move app/api/v1/vendor/info.py to app/modules/tenancy/routes/api/vendor.py
- Change endpoint path from GET /{vendor_code} to GET /info/{vendor_code}
- Remove catch-all route ordering dependency

TENANCY MODULE SETUP:
- Mark tenancy module as is_self_contained=True
- Add routes/api/vendor.py with vendor_router
- Add exceptions.py with TenancyException hierarchy
- Add placeholder __init__.py files for services, models, schemas

FRONTEND UPDATES:
- Update static/vendor/js/login.js to use new /vendor/info/{vendor_code} path
- Update static/vendor/js/init-alpine.js to use new /vendor/info/{vendor_code} path

The new path is more explicit and eliminates the need for catch-all route
ordering in the vendor router aggregation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 14:41:05 +01:00
401db56258 refactor: migrate remaining routes to modules and enforce auto-discovery
MIGRATION:
- Delete app/api/v1/vendor/analytics.py (duplicate - analytics module already auto-discovered)
- Move usage routes from app/api/v1/vendor/usage.py to billing module
- Move onboarding routes from app/api/v1/vendor/onboarding.py to marketplace module
- Move features routes to billing module (admin + vendor)
- Move inventory routes to inventory module (admin + vendor)
- Move marketplace/letzshop routes to marketplace module
- Move orders routes to orders module
- Delete legacy letzshop service files (moved to marketplace module)

DOCUMENTATION:
- Add docs/development/migration/module-autodiscovery-migration.md with full migration history
- Update docs/architecture/module-system.md with Entity Auto-Discovery Reference section
- Add detailed sections for each entity type: routes, services, models, schemas, tasks,
  exceptions, templates, static files, locales, configuration

ARCHITECTURE VALIDATION:
- Add MOD-016: Routes must be in modules, not app/api/v1/
- Add MOD-017: Services must be in modules, not app/services/
- Add MOD-018: Tasks must be in modules, not app/tasks/
- Add MOD-019: Schemas must be in modules, not models/schema/
- Update scripts/validate_architecture.py with _validate_legacy_locations method
- Update .architecture-rules/module.yaml with legacy location rules

These rules enforce that all entities must be in self-contained modules.
Legacy locations now trigger ERROR severity violations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 14:25:59 +01:00
e2cecff014 refactor: migrate vendor billing, invoices, payments to module auto-discovery
Billing module:
- Create vendor_checkout.py (checkout, portal, cancel, reactivate, change-tier)
- Create vendor_addons.py (addon management routes)
- Update vendor.py to aggregate new routers

Orders module:
- Create vendor_invoices.py (invoice settings, CRUD, PDF generation)
- Update vendor.py to aggregate invoices router

Payments module:
- Restructure routes from routes/ to routes/api/
- Add require_module_access dependency
- Set is_self_contained=True for auto-discovery

Remove legacy files:
- app/api/v1/vendor/billing.py
- app/api/v1/vendor/invoices.py
- app/api/v1/vendor/payments.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 13:49:58 +01:00
6f278131a3 refactor: migrate products and vendor_products to module auto-discovery
- Move admin/products.py to marketplace module as admin_products.py
  (marketplace product catalog browsing)
- Move admin/vendor_products.py to catalog module as admin.py
  (vendor catalog management)
- Move vendor/products.py to catalog module as vendor.py
  (vendor's own product catalog)
- Update marketplace admin router to include products routes
- Update catalog module routes/api/__init__.py with lazy imports
- Remove legacy imports from admin and vendor API init files

All product routes now auto-discovered via module system.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 12:49:11 +01:00
db56b34894 refactor: switch to full auto-discovery for module API routes
- Enhanced route discovery system with ROUTE_CONFIG support for custom
  prefix, tags, and priority
- Added get_admin_api_routes() and get_vendor_api_routes() helpers that
  return routes sorted by priority
- Added fallback discovery for routes/{frontend}.py when routes/api/
  doesn't exist
- Updated CMS module with ROUTE_CONFIG (prefix: /content-pages,
  priority: 100) to register last for catch-all routes
- Moved customers routes from routes/ to routes/api/ directory
- Updated orders module to aggregate exception routers into main routers
- Removed manual module router imports from admin and vendor API init
  files, replaced with auto-discovery loop

Modules now auto-discovered: billing, inventory, orders, marketplace,
cms, customers, analytics, loyalty, messaging, monitoring, dev-tools

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 12:42:25 +01:00
9fb3588030 docs: add plan for self-contained module routes migration
Comprehensive plan to:
- Migrate 28 API route files to their respective modules
- Remove all legacy re-export files
- Migrate page routes to modules
- Keep 18 platform core routes in legacy location

Modules affected: billing, catalog, cms, messaging, monitoring,
dev_tools, marketplace, analytics, payments, orders, inventory

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:31:49 +01:00
0a82c846ce refactor(customers): remove legacy route files, fully self-contained
- Delete app/api/v1/admin/customers.py (no backward compatibility)
- Delete app/api/v1/vendor/customers.py (no backward compatibility)
- Remove legacy router aliases from module routes
- Routes now fully self-contained in app/modules/customers/routes/

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:29:38 +01:00
e0b69f5a7d refactor(customers): migrate routes to module with auto-discovery
- Move customer route implementations to app/modules/customers/routes/
- Convert legacy app/api/v1/{admin,vendor}/customers.py to re-exports
- Update router registrations to use module routers with access control
- Fix CustomerListResponse pagination (page/per_page/total_pages)
- Update URL routing docs to use storefront consistently
- Fix mkdocs.yml nav references (shop -> storefront)
- Fix broken doc links in logging.md and cdn-fallback-strategy.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:24:10 +01:00
7245f79f7b refactor: rename shop to storefront for consistency
Rename all "shop" directories and references to "storefront" to match
the API and route naming convention already in use.

Renamed directories:
- app/templates/shop/ → app/templates/storefront/
- static/shop/ → static/storefront/
- app/templates/shared/macros/shop/ → .../macros/storefront/
- docs/frontend/shop/ → docs/frontend/storefront/

Renamed files:
- shop.css → storefront.css
- shop-layout.js → storefront-layout.js

Updated references in:
- app/routes/storefront_pages.py (21 template references)
- app/modules/cms/routes/pages/vendor.py
- app/templates/storefront/base.html (static paths)
- All storefront templates (extends/includes)
- docs/architecture/frontend-structure.md

This aligns the template/static naming with:
- Route file: storefront_pages.py
- API directory: app/api/v1/storefront/
- Module routes: */routes/api/storefront.py
- URL paths: /storefront/*

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:58:28 +01:00
9decb9c29e refactor(js): move media.js to CMS module
Media library management is part of content management (CMS).
This matches the Python pattern where:
- Core media service (upload, storage) stays in platform
- Media library UI (browsing, organizing) goes to CMS module
- Media picker component stays shared (used by products, CMS, etc.)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:39:16 +01:00
1169f1455f refactor(js): move components.js to dev_tools module
components.js is a UI components library reference for developers,
so it belongs in dev_tools alongside icons-page.js, testing-*.js,
and code-quality-*.js.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:31:20 +01:00
33e8ec56b4 refactor(js): move icons-page.js to dev_tools module
icons-page.js is a dev tool for browsing available icons, so it
belongs in dev_tools alongside testing-*.js and code-quality-*.js.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:30:08 +01:00
aebc309738 docs: update architecture docs with JS module organization
Update frontend-structure.md:
- Add "Module Static Files" section explaining the new organization
- Document how module static files are served (/static/modules/{module}/)
- Add table showing which JS files belong to which module
- Explain platform vs module static file distinction
- Document user type distinction (admin users vs platform users vs customers)

Update module-system.md:
- Expand static directory structure example
- Add "Module Static Files" section with referencing examples
- Add table for module vs platform static file decisions
- Cross-reference to frontend-structure.md for details

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:25:13 +01:00
baf70d6eb1 fix(js): move platform user files back to static/admin/js
users.js, user-detail.js, user-edit.js, user-create.js are for
managing platform/vendor users, not shop customers. Move them
back to static/admin/js/ where other platform admin files reside.

The customers module retains customers.js which manages actual
shop customers (people who buy from vendors).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:22:33 +01:00
0b4291d893 refactor(js): migrate JavaScript files to module directories
Move 47 JS files from static/{admin,vendor,shared}/js/ to their
respective module directories app/modules/*/static/*/js/:

- Orders: orders.js, order-detail.js
- Catalog: products.js (renamed from vendor-products.js), product-*.js
- Inventory: inventory.js (admin & vendor)
- Customers: customers.js, users.js, user-*.js
- Billing: billing-history.js, subscriptions.js, subscription-tiers.js,
  billing.js, invoices.js, feature-store.js, upgrade-prompts.js
- Messaging: messages.js, notifications.js, email-templates.js
- Marketplace: marketplace*.js, letzshop*.js, onboarding.js
- Monitoring: monitoring.js, background-tasks.js, imports.js, logs.js
- Dev Tools: testing-*.js, code-quality-*.js

Update 39 templates to reference new module static paths using
url_for('{module}_static', path='...') pattern.

Files staying in static/ (platform core):
- admin: dashboard, login, platforms, vendors, companies, admin-users,
  settings, components, init-alpine, module-config
- vendor: dashboard, login, profile, settings, team, media, init-alpine
- shared: api-client, utils, money, icons, log-config, vendor-selector,
  media-picker

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:08:20 +01:00
434db1560a chore: add module exceptions, locales, and fix architecture warnings
- Create module-specific exceptions for cart, catalog, checkout
- Add locales (en, de, fr, lb) for cart, catalog, checkout modules
- Add missing lb.json for existing module locales
- Add noqa comments for legitimate MOD-004 violations (core services)
- Fix validator to use correct lb.json locale code (was lu.json)
- Add noqa support for MOD-004 rule in validator

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:26:13 +01:00
cad862f469 refactor(api): introduce UserContext schema for API dependency injection
Replace direct User database model imports in API endpoints with UserContext
schema, following the architecture principle that API routes should not import
database models directly.

Changes:
- Create UserContext schema in models/schema/auth.py with from_user() factory
- Update app/api/deps.py to return UserContext from all auth dependencies
- Add _get_user_model() helper for functions needing User model access
- Update 58 API endpoint files to use UserContext instead of User
- Add noqa comments for 4 legitimate edge cases (enums, internal helpers)

Architecture validation: 0 errors (down from 61), 11 warnings remain

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 20:47:33 +01:00
1ad30bd77e docs: update models-structure with hybrid architecture patterns
Document the current architecture for models and schemas:
- CORE models (models/database/) vs module models (app/modules/*/models/)
- Three schema patterns: dedicated files, inline, and no-schema
- Data flow diagram showing services access DB directly
- Gap analysis table showing model-schema alignment
- Import guidelines with canonical vs legacy re-exports
- Checklists for creating new models and schemas

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 20:09:16 +01:00
d7de7238ff chore: remove legacy feature.py re-export
Feature is now only in app/modules/billing/models/ (canonical location).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 19:54:15 +01:00
0f9b80c634 refactor: migrate Feature to billing module and split ProductMedia to catalog
- Move Feature model from models/database/ to app/modules/billing/models/
  (tightly coupled to SubscriptionTier for tier-based access control)
- Move ProductMedia from models/database/media.py to app/modules/catalog/models/
  (product-specific media associations belong with catalog)
- Keep MediaFile as CORE in models/database/media.py (cross-cutting file storage)
- Convert legacy feature.py to re-export for backwards compatibility
- Update all imports to use canonical module locations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 19:32:38 +01:00
b9f08b853f refactor: clean up legacy models and migrate remaining schemas
Delete empty stub files from models/database/:
- audit.py, backup.py, configuration.py, monitoring.py
- notification.py, payment.py, search.py, task.py

Delete re-export files:
- models/database/subscription.py → app.modules.billing.models
- models/database/architecture_scan.py → app.modules.dev_tools.models
- models/database/test_run.py → app.modules.dev_tools.models
- models/schema/subscription.py → app.modules.billing.schemas
- models/schema/marketplace.py (empty)
- models/schema/monitoring.py (empty)

Migrate schemas to canonical module locations:
- billing.py → app/modules/billing/schemas/
- vendor_product.py → app/modules/catalog/schemas/
- homepage_sections.py → app/modules/cms/schemas/

Keep as CORE (framework-level, used everywhere):
- models/schema/: admin, auth, base, company, email, image, media, team, vendor*
- models/database/: admin*, base, company, email, feature, media, platform*, user, vendor*

Update 30+ files to use canonical import locations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 18:45:46 +01:00
1ef50893a1 refactor: migrate schemas to canonical module locations
Migrate remaining legacy schemas to their respective modules:

Marketplace module (app/modules/marketplace/schemas/):
- letzshop.py: Letzshop credentials, orders, fulfillment, sync
- onboarding.py: Vendor onboarding wizard schemas

Catalog module (app/modules/catalog/schemas/):
- product.py: ProductCreate, ProductUpdate, ProductResponse

Payments module (app/modules/payments/schemas/):
- payment.py: PaymentConfig, Stripe, transactions, balance

Delete legacy files:
- models/schema/letzshop.py
- models/schema/onboarding.py
- models/schema/product.py
- models/schema/payment.py
- models/schema/marketplace_product.py (re-export)
- models/schema/marketplace_import_job.py (re-export)
- models/schema/search.py (empty)

Update imports across 19 files to use canonical locations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:16:49 +01:00
0c63f387aa refactor: migrate models to canonical module locations
- Move Product/ProductTranslation to app/modules/catalog/models/
- Move VendorOnboarding to app/modules/marketplace/models/
- Delete legacy re-export files for marketplace models:
  - letzshop.py, marketplace.py, marketplace_product.py
  - marketplace_product_translation.py, marketplace_import_job.py
- Delete legacy product.py, product_translation.py, onboarding.py
- Update all imports across services, tasks, tests to use module locations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:45:32 +01:00
a123341aa8 fix: update test patch paths for module routes
Update test files to use new module route paths:
- test_password_reset.py: app.api.v1.shop.auth -> app.modules.customers.routes.api.storefront
- test_addresses.py: app.api.v1.shop.addresses -> app.modules.customers.routes.api.storefront
- test_orders.py: app.api.v1.shop.orders -> app.modules.orders.routes.api.storefront

Note: Some tests still fail due to patching built-in functions incorrectly.
These tests need further refactoring to match the new module architecture.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 10:16:28 +01:00
0e041a33ac fix: correct module definitions for cart, catalog, checkout
- Fix cart to import from app.modules.base instead of non-existent
  app.modules.core.module_registry
- Change 'dependencies' to 'requires' (correct attribute name)
- Remove invalid 'provides_*' attributes that don't exist in
  ModuleDefinition dataclass

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 09:44:00 +01:00
eeafe6389f fix: resolve all remaining legacy import issues
- Update models/database/__init__.py to import from module locations
- Update models/schema/__init__.py to remove deleted modules
- Update models/__init__.py to import Inventory from module
- Remove duplicate AdminNotification from models/database/admin.py
- Fix monitoring module to import AdminNotification from messaging
- Update stats schema imports in admin/vendor API
- Update notification schema imports
- Add order_item_exception.py schema to orders module
- Fix app/api/v1/__init__.py to use storefront instead of shop
- Add cms_admin_pages import to main.py
- Fix password_reset_token imports
- Fix AdminNotification test imports

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 09:21:29 +01:00
a55eb78c64 refactor: delete legacy re-export files for migrated modules
All imports have been updated to use canonical module locations.
Delete 15 legacy re-export files that are no longer needed:

Database models (7 files):
- models/database/order.py
- models/database/inventory.py
- models/database/inventory_transaction.py
- models/database/message.py
- models/database/invoice.py
- models/database/order_item_exception.py
- models/database/password_reset_token.py

Schema models (8 files):
- models/schema/customer.py
- models/schema/order.py
- models/schema/order_item_exception.py
- models/schema/inventory.py
- models/schema/message.py
- models/schema/invoice.py
- models/schema/notification.py
- models/schema/stats.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 09:03:38 +01:00
4adc35a674 refactor: update test imports to use module locations
Update all test files to import from canonical module locations:
- Integration tests: orders, inventory, messages, invoices
- Unit tests: services and models
- Fixtures: customer, vendor, message fixtures

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 09:02:50 +01:00
dad2ebc677 refactor: update services, alembic, scripts to use module imports
Update remaining application code to use canonical module locations:
- app/services/letzshop/order_service.py
- app/services/platform_health_service.py
- alembic/env.py (inventory and order models)
- scripts/investigate_order.py, verify_setup.py, seed_demo.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 08:37:47 +01:00
2559b46935 refactor: update admin/vendor API imports to use module locations
Update all admin and vendor API routes to import schemas from
canonical module locations instead of legacy re-export files:
- messages: use app.modules.messaging.models/schemas
- customers: use app.modules.customers.schemas
- orders: use app.modules.orders.schemas
- inventory: use app.modules.inventory.schemas
- invoices: use app.modules.orders.schemas

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 08:36:33 +01:00
d48dc85d5f refactor: update module imports to use module locations
Update all module files to import from canonical module locations
instead of legacy re-export files:
- checkout, orders, customers routes: use module schemas
- catalog, marketplace schemas: use inventory module schemas
- marketplace, customers, inventory, analytics services: use module models

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 08:35:01 +01:00
88a4184564 refactor: delete legacy app/services/cart_service.py
No remaining imports from legacy location - safe to delete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 08:25:56 +01:00
6026f6ab89 refactor: delete legacy models/schema/cart.py
No remaining imports from legacy location - safe to delete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 08:25:44 +01:00
7437c70249 refactor: delete legacy models/database/cart.py
Update import in alembic/env.py to use app.modules.cart.models,
then delete the legacy re-export file.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:18:45 +01:00