Complete implementation of Phase 1 enhancements including: Backend: - UserProfile model for storing user preferences (timezone, trading style, risk tolerance) - DailyRoutine model for scheduling routines (morning, active_trading, evening) - RoutineExecution model for tracking routine execution history - Notification model for managing all types of notifications - DailyChecklist model for daily task tracking with completion percentage - HabitTracker model for tracking habits and streaks Services: - RoutineService: Handles routine execution with task registry pattern - RoutineScheduler: Async scheduler for automated routine execution - NotificationService: Comprehensive notification creation and delivery system - Support for price alerts, news, routines, reminders, and performance notifications API Endpoints (daily_helper router): - User profile: CRUD operations, get/update preferences - Daily routines: Create, list, execute, track history - Notifications: CRUD, mark read, batch operations - Daily checklists: CRUD, item management, completion tracking - Habits: Create, track, log completions, manage streaks - Dashboard: Summary endpoint for daily helper overview Frontend Components: - UserProfileSetup: Complete user profile configuration with preferences - NotificationCenter: Bell icon with dropdown, notification management - HabitTracker: Habit creation, streak tracking, gamification with fire emojis - DailyChecklistPanel: Checklist management with completion percentage Schemas: - Full Pydantic schemas for request/response validation - Type-safe API contracts Features: - Timezone support for international users - Trading style and risk tolerance preferences - Automated routine execution with task registry - Real-time notifications with priority levels - Habit streaks with motivational badges - Daily checklist with persistent state - Completion percentage tracking - Notes and metadata support All components are production-ready with error handling and user feedback.
78 lines
2.3 KiB
Python
78 lines
2.3 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.config import settings
|
|
from app.api import market, ai, trading, news, stream, ohlcv
|
|
from app.api import admin, stream_sse, decisions
|
|
from app.streaming.live_store import periodic_flush, periodic_maintenance
|
|
import asyncio
|
|
|
|
# Newly added routers
|
|
from app.api import account, performance, status, settings_api, prompts, daily_helper
|
|
|
|
app = FastAPI(
|
|
title=settings.APP_NAME,
|
|
version=settings.APP_VERSION,
|
|
description="AI-Powered Gold Trading Scenario Simulator",
|
|
)
|
|
|
|
# CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.CORS_ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(market.router, prefix="/api")
|
|
app.include_router(ai.router, prefix="/api")
|
|
app.include_router(trading.router, prefix="/api")
|
|
app.include_router(news.router, prefix="/api")
|
|
app.include_router(stream.router, prefix="/api")
|
|
app.include_router(ohlcv.router, prefix="/api")
|
|
app.include_router(admin.router, prefix="/api")
|
|
app.include_router(stream_sse.router, prefix="/api")
|
|
app.include_router(decisions.router, prefix="/api")
|
|
# New
|
|
app.include_router(account.router, prefix="/api")
|
|
app.include_router(account.router_positions, prefix="/api")
|
|
app.include_router(performance.router, prefix="/api")
|
|
app.include_router(status.router, prefix="/api")
|
|
app.include_router(settings_api.router, prefix="/api")
|
|
app.include_router(prompts.router, prefix="/api")
|
|
app.include_router(daily_helper.router)
|
|
|
|
|
|
@app.on_event("startup")
|
|
async def _startup():
|
|
# Schedule periodic parquet flush in background
|
|
asyncio.create_task(periodic_flush(interval_sec=60))
|
|
# Schedule retention+compaction maintenance every 15 minutes
|
|
asyncio.create_task(periodic_maintenance(retention_days=7, compact_threshold_files=20, interval_sec=900))
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"name": settings.APP_NAME,
|
|
"version": settings.APP_VERSION,
|
|
"status": "running",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {"status": "healthy"}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run(
|
|
"app.main:app",
|
|
host=settings.HOST,
|
|
port=settings.PORT,
|
|
reload=settings.DEBUG,
|
|
)
|