summaryrefslogtreecommitdiff
path: root/IMPLEMENTOR.md
blob: ba77c2bbfe618503e88aa0f7c66fd1eb8d524ac2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Implementation Plan: Timeline Feature

## Phase 1: Database Layer (Store)
**Goal:** Enable fetching data by date range.

1.  **Update Interface:** Modify `internal/store/store.go` to add:
    *   `GetTasksByDateRange(start, end time.Time) ([]models.Task, error)`
    *   `GetMealsByDateRange(start, end time.Time) ([]models.Meal, error)`
    *   `GetCardsByDateRange(start, end time.Time) ([]models.Card, error)`
2.  **Update Implementation:** Modify `internal/store/sqlite.go` to implement these methods using SQL queries.
3.  **Test:** Create/Update `internal/store/store_test.go` to verify the queries work correctly.

## Phase 2: Core Logic & Models
**Goal:** Aggregate and normalize data into a timeline structure.

1.  **Create Models:** Create `internal/models/timeline.go` with `TimelineItem` and `TimelineItemType`.
2.  **Create Logic:** Create `internal/handlers/timeline_logic.go`.
    *   Implement `BuildTimeline(store Store, calendarClient *api.GoogleCalendarClient, start, end time.Time)`.
    *   **Logic:**
        *   Fetch Tasks, Meals, Cards from Store.
        *   Fetch Events from Calendar Client.
        *   Convert all to `TimelineItem`.
        *   **Apply Meal Defaults:**
            *   If `MealType` == "breakfast" -> Set time to 08:00
            *   If `MealType` == "lunch" -> Set time to 12:00
            *   If `MealType` == "dinner" -> Set time to 19:00
            *   Else -> Set time to 12:00
        *   Sort items by `Time`.
3.  **Test:** Create `internal/handlers/timeline_logic_test.go` to test merging and sorting (TDD).

## Phase 3: HTTP Handler & Routing
**Goal:** Expose the timeline via HTTP.

1.  **Create Handler:** Create `internal/handlers/timeline.go`.
    *   Inject `Store` and `GoogleCalendarClient`.
    *   Parse query params (`start`, `days`).
    *   Call `BuildTimeline`.
    *   Render template.
2.  **Register Route:** Update `cmd/dashboard/main.go` to map `/timeline` to the new handler.

## Phase 4: UI
**Goal:** Visualize the timeline.

1.  **Create Template:** Create `web/templates/partials/timeline-tab.html`.
    *   Iterate over items grouped by day.
    *   Show time, icon, title, and details.
2.  **Update Main View:** Update `web/templates/index.html` to add the "Timeline" tab and HTMX trigger.