Consolidate 3 separate applications (reports-app, data-entry-app, telegram-bot) into a unified
architecture with single backend and frontend:
Backend Changes:
- Unified FastAPI backend at backend/ with modular structure
- Modules: reports, data_entry, telegram in backend/modules/
- Centralized config.py and main.py with all routers registered
- Single worker mode (--workers 1) for Telegram bot compatibility
- Shared Oracle connection pool and JWT authentication
- Unified requirements.txt and environment configuration
Frontend Changes:
- Single Vue.js SPA with module-based routing
- Unified frontend at src/ with modules in src/modules/{reports,data-entry}/
- Shared components and stores in src/shared/
- Error boundaries for module isolation
- Dual API proxy in Vite for module communication
Infrastructure:
- New unified startup scripts: start-prod.sh, start-test.sh, start-backend.sh
- Environment templates: .env.dev.example, .env.test.example, .env.prod.example
- Updated deployment scripts for Windows IIS
- Simplified SSH tunnel management
Documentation:
- Comprehensive CLAUDE.md with architecture overview
- Module-specific docs in docs/{data-entry,telegram}/
- Architecture decision records in docs/ARCHITECTURE-DECISIONS.md
- Deployment guides consolidated in deployment/windows/docs/
This migration reduces complexity, improves maintainability, and enables easier
deployment while maintaining all existing functionality.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
90 lines
3.3 KiB
Python
90 lines
3.3 KiB
Python
"""
|
|
Cache configuration from environment variables
|
|
"""
|
|
import os
|
|
from dataclasses import dataclass
|
|
from typing import Optional
|
|
|
|
|
|
@dataclass
|
|
class CacheConfig:
|
|
"""Cache configuration loaded from environment variables"""
|
|
|
|
# Core Settings
|
|
enabled: bool
|
|
cache_type: str # 'hybrid', 'memory', 'sqlite', 'disabled'
|
|
sqlite_path: str
|
|
memory_max_size: int
|
|
default_ttl: int
|
|
|
|
# TTL per Cache Type (seconds)
|
|
ttl_schema: int
|
|
ttl_companies: int
|
|
ttl_dashboard_summary: int
|
|
ttl_dashboard_trends: int
|
|
ttl_invoices: int
|
|
ttl_invoices_summary: int
|
|
ttl_treasury: int
|
|
ttl_trial_balance: int
|
|
ttl_calendar_periods: int
|
|
|
|
# Maintenance
|
|
cleanup_interval: int
|
|
|
|
# Event-Based Invalidation
|
|
auto_invalidate_enabled: bool
|
|
check_interval: int
|
|
|
|
# Performance Tracking
|
|
track_performance: bool
|
|
benchmark_on_startup: bool
|
|
|
|
@classmethod
|
|
def from_env(cls) -> 'CacheConfig':
|
|
"""Load configuration from environment variables"""
|
|
return cls(
|
|
# Core Settings
|
|
enabled=os.getenv('CACHE_ENABLED', 'True').lower() == 'true',
|
|
cache_type=os.getenv('CACHE_TYPE', 'hybrid'),
|
|
sqlite_path=os.getenv('CACHE_SQLITE_PATH', './data/cache/roa2web_cache.db'),
|
|
memory_max_size=int(os.getenv('CACHE_MEMORY_MAX_SIZE', '1000')),
|
|
default_ttl=int(os.getenv('CACHE_DEFAULT_TTL', '900')),
|
|
|
|
# TTL per Cache Type
|
|
ttl_schema=int(os.getenv('CACHE_TTL_SCHEMA', '86400')),
|
|
ttl_companies=int(os.getenv('CACHE_TTL_COMPANIES', '1800')),
|
|
ttl_dashboard_summary=int(os.getenv('CACHE_TTL_DASHBOARD_SUMMARY', '1800')),
|
|
ttl_dashboard_trends=int(os.getenv('CACHE_TTL_DASHBOARD_TRENDS', '1800')),
|
|
ttl_invoices=int(os.getenv('CACHE_TTL_INVOICES', '600')),
|
|
ttl_invoices_summary=int(os.getenv('CACHE_TTL_INVOICES_SUMMARY', '900')),
|
|
ttl_treasury=int(os.getenv('CACHE_TTL_TREASURY', '600')),
|
|
ttl_trial_balance=int(os.getenv('CACHE_TTL_TRIAL_BALANCE', '600')),
|
|
ttl_calendar_periods=int(os.getenv('CACHE_TTL_CALENDAR_PERIODS', '3600')),
|
|
|
|
# Maintenance
|
|
cleanup_interval=int(os.getenv('CACHE_CLEANUP_INTERVAL', '3600')),
|
|
|
|
# Event-Based Invalidation
|
|
auto_invalidate_enabled=os.getenv('CACHE_AUTO_INVALIDATE', 'False').lower() == 'true',
|
|
check_interval=int(os.getenv('CACHE_CHECK_INTERVAL', '300')),
|
|
|
|
# Performance Tracking
|
|
track_performance=os.getenv('CACHE_TRACK_PERFORMANCE', 'True').lower() == 'true',
|
|
benchmark_on_startup=os.getenv('CACHE_BENCHMARK_ON_STARTUP', 'True').lower() == 'true',
|
|
)
|
|
|
|
def get_ttl_for_type(self, cache_type: str) -> int:
|
|
"""Get TTL for specific cache type"""
|
|
ttl_map = {
|
|
'schema': self.ttl_schema,
|
|
'companies': self.ttl_companies,
|
|
'dashboard_summary': self.ttl_dashboard_summary,
|
|
'dashboard_trends': self.ttl_dashboard_trends,
|
|
'invoices': self.ttl_invoices,
|
|
'invoices_summary': self.ttl_invoices_summary,
|
|
'treasury': self.ttl_treasury,
|
|
'trial_balance': self.ttl_trial_balance,
|
|
'calendar_periods': self.ttl_calendar_periods,
|
|
}
|
|
return ttl_map.get(cache_type, self.default_ttl)
|