My-Weekly-ToDo-List/.planning/phases/03-calendar-integration/03-01-PLAN.md
mARTin 3eaf97ed9c docs(03): create phase plan
Phase 3: Calendar Integration
- [2] plan(s) in [1] wave(s)
- [2] parallel, [0] sequential
- Ready for execution
2026-01-25 12:13:20 +01:00

141 lines
5.8 KiB
Markdown

---
phase: 03-calendar-integration
plan: 01
type: execute
wave: 1
depends_on: []
files_modified: [src/lib/google-calendar.ts, src/lib/apple-calendar.ts, src/app/api/calendar/google/oauth/route.ts, src/app/api/calendar/apple/oauth/route.ts]
autonomous: true
must_haves:
truths:
- "User can connect their Google Calendar account"
- "User can connect their Apple Calendar account"
- "Connected calendars appear in user's calendar settings"
artifacts:
- path: "src/lib/google-calendar.ts"
provides: "Google Calendar OAuth flow and API wrapper"
min_lines: 20
- path: "src/lib/apple-calendar.ts"
provides: "Apple Calendar OAuth flow and API wrapper"
min_lines: 20
- path: "src/app/api/calendar/google/oauth/route.ts"
provides: "Google OAuth callback endpoint"
exports: ["GET"]
- path: "src/app/api/calendar/apple/oauth/route.ts"
provides: "Apple OAuth callback endpoint"
exports: ["GET"]
key_links:
- from: "src/app/api/calendar/google/oauth/route.ts"
to: "src/lib/google-calendar.ts"
via: "import and use"
pattern: "import.*google-calendar"
- from: "src/app/api/calendar/apple/oauth/route.ts"
to: "src/lib/apple-calendar.ts"
via: "import and use"
pattern: "import.*apple-calendar"
---
<objective>
Implement the calendar integration system allowing users to connect Google and Apple calendar accounts with OAuth.
Purpose: Enable users to view and synchronize their calendar events with the weekly task view.
Output: Google Calendar and Apple Calendar OAuth flows with API wrappers for calendar event retrieval.
</objective>
<execution_context>
@~/.config/opencode/get-shit-done/workflows/execute-plan.md
@~/.config/opencode/get-shit-done/templates/summary.md
</documentation>
</execution_context>
<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/REQUIREMENTS.md
# Relevant context from previous phases
@.planning/phases/01-setup-and-authentication/01-01-PLAN.md
@.planning/phases/01-setup-and-authentication/01-02-PLAN.md
@.planning/phases/02-task-management/02-01-PLAN.md
</context>
<tasks>
<task type="auto">
<name>Implement Google Calendar OAuth Wrapper</name>
<files>src/lib/google-calendar.ts</files>
<action>Create a TypeScript module that implements Google Calendar OAuth flow using the Google API Client Library for JavaScript. Include functions for:
- Initializing OAuth with client ID and scopes
- Handling authorization redirects
- Retrieving user calendar list
- Fetching upcoming events for a specified time period
Reference the authentication setup from Phase 1 and the API patterns used in Phase 2.</action>
<verify>npm test passes and the module exports required functions without error</verify>
<done>Module exports initializeOAuth, getUserCalendars, and getUpcomingEvents functions</done>
</task>
<task type="auto">
<name>Implement Apple Calendar OAuth Wrapper</name>
<files>src/lib/apple-calendar.ts</files>
<action>Create a TypeScript module that implements Apple Calendar OAuth flow using the Apple Developer API. Include functions for:
- Initializing OAuth with client ID and scopes
- Handling authorization redirects
- Retrieving user calendar list
- Fetching upcoming events for a specified time period
Reference the authentication setup from Phase 1 and the API patterns used in Phase 2.</action>
<verify>npm test passes and the module exports required functions without error</verify>
<done>Module exports initializeOAuth, getUserCalendars, and getUpcomingEvents functions</done>
</task>
<task type="auto">
<name>Create Google Calendar OAuth Endpoint</name>
<files>src/app/api/calendar/google/oauth/route.ts</files>
<action>Create an API route that handles the Google OAuth callback. The route should:
- Receive the authorization code from Google's OAuth redirect
- Exchange the code for an access token using the Google API
- Store the token in the database associated with the user
- Redirect to the calendar settings page or dashboard with success message
Follow the API endpoint pattern established in Phase 2 and authentication flow from Phase 1.</action>
<verify>curl -X GET http://localhost:3000/api/calendar/google/oauth returns a successful redirect</verify>
<done>Route successfully handles Google OAuth and stores token in DB for user</done>
</task>
<task type="auto">
<name>Create Apple Calendar OAuth Endpoint</name>
<files>src/app/api/calendar/apple/oauth/route.ts</files>
<action>Create an API route that handles the Apple OAuth callback. The route should:
- Receive the authorization code from Apple's OAuth redirect
- Exchange the code for an access token using the Apple API
- Store the token in the database associated with the user
- Redirect to the calendar settings page or dashboard with success message
Follow the API endpoint pattern established in Phase 2 and authentication flow from Phase 1.</action>
<verify>curl -X GET http://localhost:3000/api/calendar/apple/oauth returns a successful redirect</verify>
<done>Route successfully handles Apple OAuth and stores token in DB for user</done>
</task>
</tasks>
<verification>
Verify that all components work in concert:
1. Google and Apple OAuth flows work without errors
2. OAuth tokens are stored in database
3. Calendar list can be fetched for connected accounts
4. Events from calendars are retrievable
5. UI for calendar settings shows connected accounts
</verification>
<success_criteria>
- Users can connect Google and Apple calendars via OAuth
- Connected calendars appear in the user's calendar settings
- Calendar events can be retrieved for display in the weekly view
- Tokens are securely stored for accessing calendar data
</success_criteria>
<output>
After completion, create `.planning/phases/03-calendar-integration/03-01-SUMMARY.md`
</output>