Full-stack self-hosted finance app with FastAPI backend and React frontend. Features: - Accounts, transactions, budgets, investments with GBP base currency - CSV import with auto-detection for 10 UK bank formats - ML predictions: spending forecast, net worth projection, Monte Carlo - 7 selectable themes (Obsidian, Arctic, Midnight, Vault, Terminal, Synthwave, Ledger) - Receipt/document attachments on transactions (JPEG, PNG, WebP, PDF) - AES-256-GCM field encryption, RS256 JWT, TOTP 2FA, RLS, audit log - Encrypted nightly backups + key rotation script - Mobile-responsive layout with bottom nav Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""
|
|
APScheduler background jobs. Starts with the FastAPI lifespan.
|
|
"""
|
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
|
from apscheduler.triggers.cron import CronTrigger
|
|
|
|
import structlog
|
|
|
|
logger = structlog.get_logger()
|
|
_scheduler: AsyncIOScheduler | None = None
|
|
|
|
|
|
async def start_scheduler() -> None:
|
|
global _scheduler
|
|
from app.workers.snapshot import snapshot_job
|
|
from app.workers.price_sync import price_sync_job
|
|
from app.workers.fx_sync import fx_sync_job
|
|
_scheduler = AsyncIOScheduler()
|
|
|
|
_scheduler.add_job(snapshot_job, CronTrigger(hour=2, minute=0), id="nw_snapshot")
|
|
_scheduler.add_job(price_sync_job, CronTrigger(minute="*/15"), id="price_sync")
|
|
_scheduler.add_job(fx_sync_job, CronTrigger(minute=0), id="fx_sync")
|
|
# _scheduler.add_job(backup_job, CronTrigger(hour=3), id="backup")
|
|
# _scheduler.add_job(ml_retrain_job, CronTrigger(day_of_week="sun", hour=1), id="ml_retrain")
|
|
|
|
_scheduler.start()
|
|
logger.info("scheduler_started")
|
|
|
|
|
|
async def stop_scheduler() -> None:
|
|
if _scheduler and _scheduler.running:
|
|
_scheduler.shutdown(wait=False)
|
|
logger.info("scheduler_stopped")
|