Implement Phase 1: Daily Helper Foundation
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.
This commit is contained in:
@@ -209,3 +209,178 @@ class CorrelationAnalysisResponse(BaseModel):
|
||||
correlations: List[NewsPriceCorrelation]
|
||||
significant_events: int
|
||||
avg_price_impact: float
|
||||
|
||||
|
||||
# Phase 1: Daily Helper Schemas
|
||||
|
||||
class UserProfileCreate(BaseModel):
|
||||
email: Optional[str] = None
|
||||
username: Optional[str] = None
|
||||
timezone: str = "UTC"
|
||||
preferred_trading_start: str = "09:00"
|
||||
preferred_trading_end: str = "17:00"
|
||||
risk_tolerance: str = "moderate"
|
||||
trading_style: str = "day_trader"
|
||||
daily_target: Optional[float] = None
|
||||
max_loss: Optional[float] = None
|
||||
|
||||
|
||||
class UserProfileUpdate(BaseModel):
|
||||
timezone: Optional[str] = None
|
||||
preferred_trading_start: Optional[str] = None
|
||||
preferred_trading_end: Optional[str] = None
|
||||
risk_tolerance: Optional[str] = None
|
||||
trading_style: Optional[str] = None
|
||||
daily_target: Optional[float] = None
|
||||
max_loss: Optional[float] = None
|
||||
notifications_enabled: Optional[bool] = None
|
||||
email_reports: Optional[bool] = None
|
||||
sms_enabled: Optional[bool] = None
|
||||
push_notifications: Optional[bool] = None
|
||||
phone_number: Optional[str] = None
|
||||
|
||||
|
||||
class UserProfileResponse(BaseModel):
|
||||
id: int
|
||||
email: Optional[str]
|
||||
username: Optional[str]
|
||||
timezone: str
|
||||
preferred_trading_start: str
|
||||
preferred_trading_end: str
|
||||
risk_tolerance: str
|
||||
trading_style: str
|
||||
daily_target: Optional[float]
|
||||
max_loss: Optional[float]
|
||||
notifications_enabled: bool
|
||||
email_reports: bool
|
||||
sms_enabled: bool
|
||||
push_notifications: bool
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class DailyRoutineCreate(BaseModel):
|
||||
routine_type: str # morning, active_trading, evening
|
||||
scheduled_time: str # HH:MM
|
||||
tasks: List[str] = []
|
||||
enabled: bool = True
|
||||
|
||||
|
||||
class DailyRoutineUpdate(BaseModel):
|
||||
scheduled_time: Optional[str] = None
|
||||
tasks: Optional[List[str]] = None
|
||||
enabled: Optional[bool] = None
|
||||
|
||||
|
||||
class DailyRoutineResponse(BaseModel):
|
||||
id: int
|
||||
routine_type: str
|
||||
scheduled_time: str
|
||||
tasks: List[str]
|
||||
enabled: bool
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class RoutineExecutionResponse(BaseModel):
|
||||
id: int
|
||||
routine_id: int
|
||||
executed_at: datetime
|
||||
completion_status: str
|
||||
tasks_completed: List[str]
|
||||
execution_notes: Optional[str]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class NotificationCreate(BaseModel):
|
||||
notification_type: str
|
||||
title: str
|
||||
message: str
|
||||
priority: str = "normal"
|
||||
delivery_method: str = "push"
|
||||
data: Optional[dict] = None
|
||||
|
||||
|
||||
class NotificationResponse(BaseModel):
|
||||
id: int
|
||||
notification_type: str
|
||||
title: str
|
||||
message: str
|
||||
priority: str
|
||||
delivery_method: str
|
||||
read: bool
|
||||
created_at: datetime
|
||||
read_at: Optional[datetime]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class NotificationListResponse(BaseModel):
|
||||
notifications: List[NotificationResponse]
|
||||
unread_count: int
|
||||
total_count: int
|
||||
|
||||
|
||||
class ChecklistItem(BaseModel):
|
||||
id: str
|
||||
title: str
|
||||
completed: bool = False
|
||||
completed_at: Optional[datetime] = None
|
||||
|
||||
|
||||
class DailyChecklistCreate(BaseModel):
|
||||
checklist_type: str # morning, active_trading, evening, all
|
||||
items: Optional[List[ChecklistItem]] = None
|
||||
notes: Optional[str] = None
|
||||
|
||||
|
||||
class DailyChecklistUpdate(BaseModel):
|
||||
items: Optional[List[ChecklistItem]] = None
|
||||
notes: Optional[str] = None
|
||||
|
||||
|
||||
class DailyChecklistResponse(BaseModel):
|
||||
id: int
|
||||
checklist_date: str # ISO date string
|
||||
checklist_type: str
|
||||
items: List[ChecklistItem]
|
||||
completion_percentage: float
|
||||
notes: Optional[str]
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class HabitTrackerCreate(BaseModel):
|
||||
habit_name: str
|
||||
frequency: str = "daily" # daily, weekly
|
||||
|
||||
|
||||
class HabitTrackerResponse(BaseModel):
|
||||
id: int
|
||||
habit_name: str
|
||||
frequency: str
|
||||
current_streak: int
|
||||
longest_streak: int
|
||||
total_completions: int
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class HabitCompletionRequest(BaseModel):
|
||||
habit_id: int
|
||||
completion_date: Optional[str] = None # ISO date string, defaults to today
|
||||
|
||||
Reference in New Issue
Block a user