refactor: reorganize backend module boundaries

This commit is contained in:
jxxghp
2026-08-14 19:53:33 +08:00
parent fe0b444ceb
commit 369d7d6448
584 changed files with 2423 additions and 2275 deletions

View File

@@ -29,17 +29,17 @@ from app.chain.site import site_interaction_manager
from app.chain.skills import skills_interaction_manager
from app.chain.subscribe import subscribe_interaction_manager
from app.command import Command
from app.platform.config import global_vars, settings
from app.platform.events import Event, EventManager
from app.runtime.config import global_vars, settings
from app.runtime.events import Event, EventManager
from app.db import get_async_db
from app.db.agentchat_oper import AgentChatOper
from app.db.models import User
from app.db.models.agentchat import AgentChat
from app.db.user_oper import UserOper, get_current_active_user
from app.messaging.agent import attach_web_agent_edit_queue, detach_web_agent_edit_queue
from app.messaging.interaction import agent_interaction_manager, media_interaction_manager
from app.platform.localization import LocaleHelper
from app.platform.log import logger
from app.application.messaging.agent import attach_web_agent_edit_queue, detach_web_agent_edit_queue
from app.application.messaging.interaction import agent_interaction_manager, media_interaction_manager
from app.runtime.localization import LocaleHelper
from app.runtime.log import logger
from app.schemas.types import EventType, MessageChannel
router = ResponseAPIRouter()

View File

@@ -6,7 +6,7 @@ from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.anilist import AniListChain
from app.domain.context import MediaInfo
from app.security.access import verify_token
from app.application.security.access import verify_token
router = ResponseAPIRouter()

View File

@@ -16,8 +16,8 @@ from app.api.openai_utils import (
build_prompt,
build_session_id,
)
from app.platform.config import settings
from app.security.access import anthropic_api_key_header
from app.runtime.config import settings
from app.application.security.access import anthropic_api_key_header
from app.schemas.types import MessageChannel
ANTHROPIC_ERROR_RESPONSES = {

View File

@@ -5,8 +5,8 @@ from pydantic import BaseModel
from app import schemas
from app.api.response import RAW_RESPONSE_OPENAPI_KEY, ResponseAPIRouter
from app.security.auth import build_token_response, consume_plugin_auth_ticket
from app.extensions.plugin_manager import PluginManager
from app.application.security.auth import build_token_response, consume_plugin_auth_ticket
from app.runtime.extensions.plugin_manager import PluginManager
from app.db.models.passkey import PassKey
from app.db.models.user import User

View File

@@ -6,7 +6,7 @@ from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.bangumi import BangumiChain
from app.domain.context import MediaInfo
from app.security.access import verify_token
from app.application.security.access import verify_token
router = ResponseAPIRouter()

View File

@@ -8,14 +8,14 @@ from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.dashboard import DashboardChain
from app.chain.storage import StorageChain
from app.platform.config import settings
from app.security.access import verify_apitoken
from app.runtime.config import settings
from app.application.security.access import verify_apitoken
from app.db import get_db
from app.db.models.transferhistory import TransferHistory
from app.db.user_oper import get_current_active_superuser
from app.services.directory import DirectoryHelper
from app.application.directory import DirectoryHelper
from app.scheduler import Scheduler
from app.infrastructure.system import SystemUtils
from app.adapters.system.host import SystemUtils
router = ResponseAPIRouter()

View File

@@ -7,8 +7,8 @@ from app.api.response import ResponseAPIRouter
from app.chain.bangumi import BangumiChain
from app.chain.douban import DoubanChain
from app.chain.tmdb import TmdbChain
from app.platform.events import eventmanager
from app.security.access import verify_token
from app.runtime.events import eventmanager
from app.application.security.access import verify_token
from app.schemas import DiscoverSourceEventData
from app.schemas.types import ChainEventType, MediaType

View File

@@ -6,7 +6,7 @@ from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.douban import DoubanChain
from app.domain.context import MediaInfo
from app.security.access import verify_token
from app.application.security.access import verify_token
from app.schemas import MediaType
router = ResponseAPIRouter()

View File

@@ -9,12 +9,12 @@ from app.chain.media import MediaChain
from app.domain.context import Context, MediaInfo, MusicInfo, SubtitleInfo, TorrentInfo
from app.domain.meta.metamusic import MetaMusic
from app.domain.metainfo import MetaInfo
from app.security.access import verify_token
from app.application.security.access import verify_token
from app.db.models.user import User
from app.db.site_oper import SiteOper
from app.db.systemconfig_oper import SystemConfigOper
from app.db.user_oper import get_current_active_user
from app.services.directory import DirectoryHelper
from app.application.directory import DirectoryHelper
from app.schemas.types import (
MUSIC_ENTITY_RECORDING,
MediaSource,
@@ -23,7 +23,7 @@ from app.schemas.types import (
SystemConfigKey,
)
from app.domain.media import is_music_media_source, normalize_music_type
from app.security.url import SecurityUtils
from app.application.security.url import SecurityUtils
router = ResponseAPIRouter()

View File

@@ -15,9 +15,9 @@ from app.agent.prompt.transfer_redo import (
build_manual_redo_prompt,
)
from app.chain.storage import StorageChain
from app.platform.config import settings, global_vars
from app.platform.events import eventmanager
from app.security.access import verify_token
from app.runtime.config import settings, global_vars
from app.runtime.events import eventmanager
from app.application.security.access import verify_token
from app.db import get_async_db, get_db
from app.db.models import User
from app.db.models.downloadhistory import DownloadHistory, DownloadFiles
@@ -27,10 +27,10 @@ from app.db.user_oper import (
get_current_active_superuser,
get_current_active_superuser_async,
)
from app.platform.progress import ProgressHelper
from app.services.history import clear_transfer_failures
from app.runtime.progress import ProgressHelper
from app.application.history import clear_transfer_failures
from app.schemas.types import EventType
from app.foundation.jieba import cut as jieba_cut
from app.foundation.text import cut as jieba_cut
router = ResponseAPIRouter()

View File

@@ -13,13 +13,13 @@ from app.agent.llm import (
LLMTestTimeout,
render_auth_result_html,
)
from app.platform.config import settings
from app.runtime.config import settings
from app.db.models import User
from app.db.user_oper import (
get_current_active_superuser_async,
get_current_active_user_async,
)
from app.platform.log import logger
from app.runtime.log import logger
router = ResponseAPIRouter()

View File

@@ -8,11 +8,11 @@ from fastapi.responses import JSONResponse
from app import schemas
from app.api.response import RAW_RESPONSE_OPENAPI_KEY, ResponseAPIRouter
from app.chain.user import MfaRequired, UserChain
from app.security import access as security
from app.platform.config import settings
from app.application.security import access as security
from app.runtime.config import settings
from app.db.systemconfig_oper import SystemConfigOper
from app.infrastructure.sites import SitesHelper # noqa
from app.services.image import WallpaperHelper
from app.application.site.sites import SitesHelper # pylint: disable=no-name-in-module
from app.application.image import WallpaperHelper
from app.schemas.types import SystemConfigKey
router = ResponseAPIRouter()

View File

@@ -6,8 +6,8 @@ from fastapi.responses import JSONResponse, Response
from app import schemas
from app.api.response import RAW_RESPONSE_OPENAPI_KEY, ResponseAPIRouter
from app.agent.tools.manager import moviepilot_tool_manager
from app.security.access import verify_apikey
from app.platform.log import logger
from app.application.security.access import verify_apikey
from app.runtime.log import logger
# 导入版本号
try:

View File

@@ -10,12 +10,12 @@ from app.api.response import ResponseAPIRouter
from app.chain.media import MediaChain
from app.chain.scraping import ScrapingChain
from app.chain.tmdb import TmdbChain
from app.platform.config import settings
from app.runtime.config import settings
from app.domain.context import Context, MusicInfo
from app.domain.meta.metabase import MetaBase
from app.domain.meta.metamusic import MetaMusic
from app.domain.metainfo import MetaInfo, MetaInfoPath
from app.security.access import verify_token, verify_apitoken
from app.application.security.access import verify_token, verify_apitoken
from app.db.models import User
from app.db.user_oper import get_current_active_user, get_current_active_superuser
from app.schemas import MediaType

View File

@@ -9,12 +9,12 @@ from app.chain.download import DownloadChain
from app.chain.mediaserver import MediaServerChain
from app.domain.context import MediaInfo
from app.domain.metainfo import MetaInfo
from app.security.access import verify_token
from app.application.security.access import verify_token
from app.db import get_async_db
from app.db.mediaserver_oper import MediaServerOper
from app.db.models import MediaServerItem
from app.db.systemconfig_oper import SystemConfigOper
from app.services.mediaserver import MediaServerHelper
from app.application.mediaserver import MediaServerHelper
from app.schemas import MediaType, NotExistMediaInfo
from app.schemas.types import MediaSource, SystemConfigKey
from app.domain.media import build_media_key, resolve_media_identity

View File

@@ -10,15 +10,15 @@ from starlette.responses import PlainTextResponse
from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.message import MessageChain
from app.platform.config import settings, global_vars
from app.security.access import verify_token, verify_apitoken
from app.runtime.config import settings, global_vars
from app.application.security.access import verify_token, verify_apitoken
from app.db import get_async_db
from app.db.models import User
from app.db.message_oper import MessageOper
from app.db.systemconfig_oper import SystemConfigOper
from app.db.user_oper import get_current_active_superuser
from app.extensions.service_registry import ServiceConfigHelper
from app.platform.log import logger
from app.runtime.extensions.service_registry import ServiceConfigHelper
from app.runtime.log import logger
from app.modules.wechat.WXBizMsgCrypt3 import WXBizMsgCrypt
from app.schemas.types import MessageChannel, SystemConfigKey

View File

@@ -7,28 +7,28 @@ import json
from datetime import timedelta
from typing import Any, Annotated, Optional
from app.infrastructure.sites import SitesHelper
from app.application.site.sites import SitesHelper # pylint: disable=no-name-in-module
from fastapi import Depends, HTTPException, Body, Request, Response
from sqlalchemy.ext.asyncio import AsyncSession
from app import schemas
from app.api.response import RAW_RESPONSE_OPENAPI_KEY, ResponseAPIRouter
from app.security import access as security
from app.platform.config import settings
from app.application.security import access as security
from app.runtime.config import settings
from app.db import get_async_db
from app.db.models.passkey import PassKey
from app.db.models.user import User
from app.db.systemconfig_oper import SystemConfigOper
from app.db.user_oper import get_current_active_user, get_current_active_user_async
from app.security.passkey import (
from app.application.security.passkey import (
PassKeyHelper,
PassKeyRegistrationOriginMismatchError,
PassKeyRegistrationVerificationError,
PasskeyChallengeStore,
)
from app.platform.log import logger
from app.runtime.log import logger
from app.schemas.types import SystemConfigKey
from app.security.otp import OtpUtils
from app.application.security.otp import OtpUtils
router = ResponseAPIRouter()

View File

@@ -8,7 +8,7 @@ from app.chain.media import MediaChain
from app.chain.recommend import RecommendChain
from app.schemas.types import MediaSource, MediaType
from app.domain.context import MusicAlbumInfo, MusicArtistInfo, MusicInfo
from app.security.access import verify_token
from app.application.security.access import verify_token
from app.db.models.user import User
from app.db.user_oper import get_current_active_superuser_async
from app.modules.listenbrainz import (

View File

@@ -4,7 +4,7 @@ from fastapi import Depends
from app import schemas
from app.api.response import ResponseAPIRouter
from app.extensions.module_manager import ModuleManager
from app.runtime.extensions.module_manager import ModuleManager
from app.db.models import User
from app.db.user_oper import get_current_active_superuser
from app.modules.wechatclawbot.wechatclawbot import WechatClawBot

View File

@@ -17,8 +17,8 @@ from app.api.openai_utils import (
)
from app.agent.callback import StreamingHandler
from app.agent.orchestrator import MoviePilotAgent
from app.platform.config import settings
from app.security.access import openai_bearer_scheme
from app.runtime.config import settings
from app.application.security.access import openai_bearer_scheme
from app.schemas.types import MessageChannel
OPENAI_ERROR_RESPONSES = {

View File

@@ -13,11 +13,11 @@ from starlette.responses import StreamingResponse
from app import schemas
from app.api.response import ResponseAPIRouter
from app.command import Command
from app.platform.cache import async_fresh
from app.platform.config import settings
from app.platform.events import eventmanager
from app.extensions.plugin_manager import PluginManager
from app.security.access import (
from app.runtime.cache import async_fresh
from app.runtime.config import settings
from app.runtime.events import eventmanager
from app.runtime.extensions.plugin_manager import PluginManager
from app.application.security.access import (
resource_token_cookie,
verify_apikey,
verify_resource_token,
@@ -30,9 +30,9 @@ from app.db.user_oper import (
get_current_active_superuser_async,
)
from app.factory import app
from app.integrations.server import MoviePilotServerHelper
from app.integrations.market import PluginHelper
from app.platform.log import logger
from app.adapters.external.server import MoviePilotServerHelper
from app.adapters.external.market import PluginHelper
from app.runtime.log import logger
from app.scheduler import Scheduler
from app.schemas.event import PluginDataResetEventData
from app.schemas.types import ChainEventType, SystemConfigKey

View File

@@ -5,8 +5,8 @@ from fastapi import Depends, HTTPException, status
from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.recommend import RecommendChain
from app.platform.events import eventmanager
from app.security.access import verify_token
from app.runtime.events import eventmanager
from app.application.security.access import verify_token
from app.modules.themoviedb.tmdbv3api.exceptions import TMDbException
from app.schemas import RecommendSourceEventData
from app.schemas.types import ChainEventType

View File

@@ -10,12 +10,12 @@ from fastapi.responses import StreamingResponse
from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.search import SearchChain
from app.security.access import verify_resource_token, verify_token
from app.platform.localization import LocaleHelper
from app.platform.log import logger
from app.application.security.access import verify_resource_token, verify_token
from app.runtime.localization import LocaleHelper
from app.runtime.log import logger
from app.schemas.types import MediaSource, MediaType
from app.domain.media import normalize_music_type, resolve_media_identity
from app.security.url import SecurityUtils
from app.application.security.url import SecurityUtils
router = ResponseAPIRouter()

View File

@@ -11,9 +11,9 @@ from app.api.endpoints.plugin import register_plugin_api
from app.chain.site import SiteChain
from app.chain.torrents import TorrentsChain
from app.command import Command
from app.platform.events import eventmanager
from app.extensions.plugin_manager import PluginManager
from app.security.access import verify_token
from app.runtime.events import eventmanager
from app.runtime.extensions.plugin_manager import PluginManager
from app.application.security.access import verify_token
from app.db import get_db, get_async_db
from app.db.models import User
from app.db.models.site import Site
@@ -28,8 +28,8 @@ from app.db.user_oper import (
get_current_active_superuser,
get_current_active_superuser_async,
)
from app.infrastructure.sites import SitesHelper # noqa
from app.platform.log import logger
from app.application.site.sites import SitesHelper # pylint: disable=no-name-in-module
from app.runtime.log import logger
from app.scheduler import Scheduler
from app.schemas.types import SystemConfigKey, EventType, MediaType
from app.domain.string import StringUtils

View File

@@ -12,15 +12,15 @@ from app.api.response import ResponseAPIRouter
from app.chain.media import MediaChain
from app.chain.storage import StorageChain
from app.chain.transfer import TransferChain
from app.platform.config import settings
from app.security.access import verify_token
from app.runtime.config import settings
from app.application.security.access import verify_token
from app.db.models import User
from app.db.user_oper import (
get_current_active_manage_user,
get_current_active_superuser,
get_current_active_superuser_async,
)
from app.platform.progress import ProgressHelper
from app.runtime.progress import ProgressHelper
from app.schemas.types import ProgressKey
from app.domain.string import StringUtils

View File

@@ -8,19 +8,19 @@ from sqlalchemy.orm import Session
from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.subscribe import SubscribeChain
from app.platform.config import settings
from app.runtime.config import settings
from app.domain.context import MediaInfo
from app.platform.events import eventmanager
from app.runtime.events import eventmanager
from app.domain.metainfo import MetaInfo
from app.security.access import verify_token, verify_apitoken
from app.application.security.access import verify_token, verify_apitoken
from app.db import get_async_db, get_db
from app.db.models.subscribe import Subscribe
from app.db.models.subscribehistory import SubscribeHistory
from app.db.models.user import User
from app.db.systemconfig_oper import SystemConfigOper
from app.db.user_oper import get_current_active_user, get_current_active_user_async
from app.integrations.server import MoviePilotServerHelper
from app.platform.log import logger
from app.adapters.external.server import MoviePilotServerHelper
from app.runtime.log import logger
from app.scheduler import Scheduler
from app.schemas.event import SubscribeModifiedEventData
from app.schemas.types import (

View File

@@ -13,7 +13,7 @@ import aiofiles
import anyio
import pillow_avif # noqa 用于自动注册AVIF支持
from anyio import Path as AsyncPath
from app.infrastructure.sites import SitesHelper # noqa # noqa
from app.application.site.sites import SitesHelper # pylint: disable=no-name-in-module
from fastapi import Body, Depends, HTTPException, Header, Request, Response
from fastapi.responses import StreamingResponse
@@ -23,11 +23,11 @@ from app.chain.media import MediaChain
from app.chain.mediaserver import MediaServerChain
from app.chain.search import SearchChain
from app.chain.system import SystemChain
from app.platform.config import global_vars, settings
from app.platform.events import eventmanager
from app.runtime.config import global_vars, settings
from app.runtime.events import eventmanager
from app.domain.metainfo import MetaInfo
from app.extensions.module_manager import ModuleManager
from app.security.access import verify_apitoken, verify_resource_token, verify_token
from app.runtime.extensions.module_manager import ModuleManager
from app.application.security.access import verify_apitoken, verify_resource_token, verify_token
from app.db.models import User
from app.db.systemconfig_oper import SystemConfigOper
from app.db.user_oper import (
@@ -35,27 +35,27 @@ from app.db.user_oper import (
get_current_active_superuser_async,
get_current_active_user_async,
)
from app.services.image import ImageHelper
from app.platform.localization import LocaleHelper
from app.integrations.market import (
from app.application.image import ImageHelper
from app.runtime.localization import LocaleHelper
from app.adapters.external.market import (
PLUGIN_MARKET_WIKI_URL,
extract_plugin_market_repos_from_wiki,
merge_plugin_market_repos,
split_plugin_market_repo_urls,
)
from app.messaging.message import MessageHelper
from app.platform.progress import ProgressHelper
from app.services.filter import RuleHelper
from app.integrations.server import MoviePilotServerHelper
from app.platform.runtime import SystemHelper
from app.platform.log import logger
from app.application.messaging.message import MessageHelper
from app.runtime.progress import ProgressHelper
from app.application.filter import RuleHelper
from app.adapters.external.server import MoviePilotServerHelper
from app.runtime.state import SystemHelper
from app.runtime.log import logger
from app.scheduler import Scheduler
from app.schemas import ConfigChangeEventData
from app.schemas.types import SystemConfigKey, EventType
from app.foundation.crypto import HashUtils
from app.foundation.http import RequestUtils, AsyncRequestUtils
from app.infrastructure import rust as rust_accel
from app.security.url import SecurityUtils
from app.adapters.network.http import RequestUtils, AsyncRequestUtils
from app.adapters.system import rust as rust_accel
from app.application.security.url import SecurityUtils
from app.foundation.url import UrlUtils
from version import APP_VERSION

View File

@@ -5,8 +5,8 @@ from fastapi import Depends
from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.tmdb import TmdbChain
from app.platform.config import settings
from app.security.access import verify_token
from app.runtime.config import settings
from app.application.security.access import verify_token
from app.db.models.user import User
from app.db.systemconfig_oper import SystemConfigOper
from app.db.user_oper import get_current_active_superuser_async

View File

@@ -6,7 +6,7 @@ from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.media import MediaChain
from app.chain.torrents import TorrentsChain
from app.platform.config import settings
from app.runtime.config import settings
from app.domain.context import MediaInfo, MusicInfo
from app.domain.meta.metamusic import MetaMusic
from app.domain.metainfo import MetaInfo

View File

@@ -8,8 +8,8 @@ from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.media import MediaChain
from app.chain.transfer import TransferChain
from app.platform.config import settings, global_vars
from app.security.access import verify_token, verify_apitoken
from app.runtime.config import settings, global_vars
from app.application.security.access import verify_token, verify_apitoken
from app.db import get_db
from app.db.models import User
from app.db.models.transferhistory import TransferHistory
@@ -17,8 +17,8 @@ from app.db.user_oper import (
get_current_active_manage_user,
get_current_active_superuser,
)
from app.services.directory import DirectoryHelper
from app.platform.log import logger
from app.application.directory import DirectoryHelper
from app.runtime.log import logger
from app.schemas import (
MediaType,
FileItem,

View File

@@ -7,7 +7,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from app import schemas
from app.api.response import ResponseAPIRouter
from app.security.access import get_password_hash
from app.application.security.access import get_password_hash
from app.db import get_async_db
from app.db.models.user import User
from app.db.user_oper import (

View File

@@ -5,7 +5,7 @@ from fastapi import BackgroundTasks, Request, Depends
from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.webhook import WebhookChain
from app.security.access import verify_apitoken
from app.application.security.access import verify_apitoken
router = ResponseAPIRouter()

View File

@@ -9,8 +9,8 @@ from sqlalchemy.orm import Session
from app import schemas
from app.api.response import ResponseAPIRouter
from app.chain.workflow import WorkflowChain
from app.platform.config import global_vars
from app.extensions.plugin_manager import PluginManager
from app.runtime.config import global_vars
from app.runtime.extensions.plugin_manager import PluginManager
from app.workflow import WorkFlowManager
from app.db import get_async_db, get_db
from app.db.models import Workflow, User
@@ -20,7 +20,7 @@ from app.db.user_oper import (
get_current_active_manage_user_async,
)
from app.db.workflow_oper import WorkflowOper
from app.integrations.server import MoviePilotServerHelper
from app.adapters.external.server import MoviePilotServerHelper
from app.scheduler import Scheduler
from app.schemas.types import EventType, EVENT_TYPE_NAMES