# Timeline Feature Design ## Objective Create a unified timeline view showing Tasks, Meals, Trello Cards, and Google Calendar Events, sorted chronologically. ## Data Sources 1. **Tasks (Todoist):** From DB `tasks` table. Filter: `due_date` is not null. 2. **Meals (PlanToEat):** From DB `meals` table. Filter: `date` is not null. 3. **Cards (Trello):** From DB `cards` table. Filter: `due_date` is not null. 4. **Google Calendar Events:** From `GoogleCalendarClient` (Live API). ## Backend Logic ### 1. Data Models (`internal/models/timeline.go`) We need a polymorphic structure to hold different item types. ```go type TimelineItemType string const ( ItemTypeTask TimelineItemType = "task" ItemTypeMeal TimelineItemType = "meal" ItemTypeCard TimelineItemType = "card" ItemTypeEvent TimelineItemType = "event" ) type TimelineItem struct { ID string `json:"id"` Type TimelineItemType `json:"type"` Title string `json:"title"` Description string `json:"description"` Time time.Time `json:"time"` AllDay bool `json:"all_day"` URL string `json:"url"` Meta map[string]any `json:"meta"` // Extra data like ProjectName, RecipeURL, etc. } ``` ### 2. Store Extensions (`internal/store/`) Add methods to fetch items by date range. * `GetTasksByDateRange(start, end time.Time) ([]models.Task, error)` * `GetMealsByDateRange(start, end time.Time) ([]models.Meal, error)` * `GetCardsByDateRange(start, end time.Time) ([]models.Card, error)` ### 3. Logic Layer (`internal/handlers/timeline_logic.go`) * **Function:** `BuildTimeline(store Store, calendarClient *api.GoogleCalendarClient, start, end time.Time) ([]TimelineItem, error)` * **Aggregation:** 1. Fetch from Store (Tasks, Meals, Cards). 2. Fetch from Calendar API. 3. Convert all to `TimelineItem`. 4. **Meal Time Defaults:** * Breakfast: 08:00 * Lunch: 12:00 * Dinner: 19:00 * Other: 12:00 5. Sort by `Time`. ### 4. HTTP Handler (`internal/handlers/timeline.go`) * **Route:** `GET /timeline` * **Params:** `start` (default: today), `days` (default: 7) * **Response:** Render `timeline-tab.html` partial. ## UI Design (`web/templates/partials/timeline-tab.html`) * **Structure:** * Container * Loop through Days * Date Header (e.g., "Mon, Jan 2") * List of Items * Time Column (e.g., "14:00") * Content Column (Icon + Title + Subtitle) * **Styling:** * Use existing CSS variables. * Distinct icons/colors for Tasks vs Meals vs Events. ## Files to Modify 1. `internal/models/timeline.go` (New) 2. `internal/store/store.go` (Interface update) 3. `internal/store/sqlite.go` (Implementation update) 4. `internal/handlers/timeline_logic.go` (New) 5. `internal/handlers/timeline.go` (New) 6. `web/templates/partials/timeline-tab.html` (New) 7. `cmd/dashboard/main.go` (Route registration)