架构规则与指南
To maintain code quality, maintainability, and hexagonal separation, all code contributions MUST follow these rules:
1. Strict Layering Boundaries
use_cases/: Pure business logic. MUST NOT importfastapi,sqlalchemy, or provider implementations directly.routers/: Transport layer. Translates HTTP requests to use case inputs and maps domain exceptions to HTTP status codes.concurrency.py: Blocking synchronous operations (SQLAlchemy, Pandas, yfinance) MUST be executed viarun_sync().
2. Identifier Strategy
- Always use
(asset_id, ticker, exchange, currency)resolution viaDatabaseService.get_asset_context(). - Do not assume a ticker uniquely identifies a stock globally (
TSLAcan be a stock or an ETP). Always respect ISIN mappings.
3. Data Integrity & Validation
- All provider inputs MUST pass through
ValidationLayerchecks before being exposed to end users. - Do not mask symptoms by returning dummy fallbacks or swallowing exceptions silently.