Initial project setup for PhaseFlow

Set up Next.js 16 project with TypeScript for a training decision app
that integrates menstrual cycle phases with Garmin biometrics for
Hashimoto's thyroiditis management.

Stack: Next.js 16, React 19, Tailwind/shadcn, PocketBase, Drizzle,
Zod, Resend, Vitest, Biome, Lefthook, Nix dev environment.

Includes:
- 7 page routes (dashboard, login, settings, calendar, history, plan)
- 12 API endpoints (garmin, user, cycle, calendar, overrides, cron)
- Core lib utilities (decision engine, cycle phases, nutrition, ICS)
- Type definitions and component scaffolding
- Python script for Garmin token bootstrapping
- Initial unit tests for cycle utilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-09 16:50:39 +00:00
commit f15e093254
63 changed files with 6061 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
// ABOUTME: API route for ICS calendar feed generation.
// ABOUTME: Returns subscribable iCal feed with cycle phases and warnings.
import { type NextRequest, NextResponse } from "next/server";
interface RouteParams {
params: Promise<{
userId: string;
token: string;
}>;
}
export async function GET(_request: NextRequest, { params }: RouteParams) {
const { userId, token } = await params;
void token; // Token will be used for validation
// TODO: Implement ICS feed generation
// Validate token, generate ICS content, return with correct headers
return new NextResponse(`ICS feed for user ${userId} not implemented`, {
status: 501,
headers: {
"Content-Type": "text/calendar; charset=utf-8",
},
});
}

View File

@@ -0,0 +1,8 @@
// ABOUTME: API route for regenerating calendar subscription token.
// ABOUTME: Creates new random token, invalidating old calendar URLs.
import { NextResponse } from "next/server";
export async function POST() {
// TODO: Implement token regeneration
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

View File

@@ -0,0 +1,16 @@
// ABOUTME: Cron endpoint for syncing Garmin data.
// ABOUTME: Fetches body battery, HRV, and intensity minutes for all users.
import { NextResponse } from "next/server";
export async function POST(request: Request) {
// Verify cron secret
const authHeader = request.headers.get("authorization");
const expectedSecret = process.env.CRON_SECRET;
if (!expectedSecret || authHeader !== `Bearer ${expectedSecret}`) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
// TODO: Implement Garmin data sync
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

View File

@@ -0,0 +1,16 @@
// ABOUTME: Cron endpoint for sending daily email notifications.
// ABOUTME: Sends morning training decision emails to all users.
import { NextResponse } from "next/server";
export async function POST(request: Request) {
// Verify cron secret
const authHeader = request.headers.get("authorization");
const expectedSecret = process.env.CRON_SECRET;
if (!expectedSecret || authHeader !== `Bearer ${expectedSecret}`) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
// TODO: Implement notification sending
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

View File

@@ -0,0 +1,8 @@
// ABOUTME: API route for current cycle phase information.
// ABOUTME: Returns current cycle day, phase, and phase limits.
import { NextResponse } from "next/server";
export async function GET() {
// TODO: Implement current cycle info
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

View File

@@ -0,0 +1,8 @@
// ABOUTME: API route for logging period start dates.
// ABOUTME: Recalculates all phase dates when period is logged.
import { NextResponse } from "next/server";
export async function POST() {
// TODO: Implement period logging
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

View File

@@ -0,0 +1,8 @@
// ABOUTME: API route for checking Garmin connection status.
// ABOUTME: Returns connection state and token expiry information.
import { NextResponse } from "next/server";
export async function GET() {
// TODO: Implement status check
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

View File

@@ -0,0 +1,13 @@
// ABOUTME: API route for storing Garmin OAuth tokens.
// ABOUTME: Accepts tokens from the bootstrap script and encrypts them for storage.
import { NextResponse } from "next/server";
export async function POST() {
// TODO: Implement token storage
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}
export async function DELETE() {
// TODO: Implement token deletion
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

View File

@@ -0,0 +1,8 @@
// ABOUTME: API route for historical daily logs.
// ABOUTME: Returns paginated list of past training decisions and data.
import { NextResponse } from "next/server";
export async function GET() {
// TODO: Implement history retrieval
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

View File

@@ -0,0 +1,13 @@
// ABOUTME: API route for managing training overrides.
// ABOUTME: Handles flare, stress, sleep, and PMS override toggles.
import { NextResponse } from "next/server";
export async function POST() {
// TODO: Implement override setting
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}
export async function DELETE() {
// TODO: Implement override removal
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

View File

@@ -0,0 +1,8 @@
// ABOUTME: API route for today's training decision and data.
// ABOUTME: Returns complete daily snapshot with decision, biometrics, and nutrition.
import { NextResponse } from "next/server";
export async function GET() {
// TODO: Implement today's data retrieval
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

13
src/app/api/user/route.ts Normal file
View File

@@ -0,0 +1,13 @@
// ABOUTME: API route for user profile management.
// ABOUTME: Handles GET for profile retrieval and PATCH for updates.
import { NextResponse } from "next/server";
export async function GET() {
// TODO: Implement user profile retrieval
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}
export async function PATCH() {
// TODO: Implement user profile update
return NextResponse.json({ message: "Not implemented" }, { status: 501 });
}

11
src/app/calendar/page.tsx Normal file
View File

@@ -0,0 +1,11 @@
// ABOUTME: In-app calendar view showing cycle phases.
// ABOUTME: Displays monthly calendar with color-coded phases and ICS subscription info.
export default function CalendarPage() {
return (
<div className="container mx-auto p-8">
<h1 className="text-2xl font-bold mb-8">Calendar</h1>
{/* Calendar view will be implemented here */}
<p className="text-gray-500">Calendar view placeholder</p>
</div>
);
}

BIN
src/app/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

125
src/app/globals.css Normal file
View File

@@ -0,0 +1,125 @@
@import "tailwindcss";
@import "tw-animate-css";
@custom-variant dark (&:is(.dark *));
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
--color-sidebar-ring: var(--sidebar-ring);
--color-sidebar-border: var(--sidebar-border);
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
--color-sidebar-accent: var(--sidebar-accent);
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
--color-sidebar-primary: var(--sidebar-primary);
--color-sidebar-foreground: var(--sidebar-foreground);
--color-sidebar: var(--sidebar);
--color-chart-5: var(--chart-5);
--color-chart-4: var(--chart-4);
--color-chart-3: var(--chart-3);
--color-chart-2: var(--chart-2);
--color-chart-1: var(--chart-1);
--color-ring: var(--ring);
--color-input: var(--input);
--color-border: var(--border);
--color-destructive: var(--destructive);
--color-accent-foreground: var(--accent-foreground);
--color-accent: var(--accent);
--color-muted-foreground: var(--muted-foreground);
--color-muted: var(--muted);
--color-secondary-foreground: var(--secondary-foreground);
--color-secondary: var(--secondary);
--color-primary-foreground: var(--primary-foreground);
--color-primary: var(--primary);
--color-popover-foreground: var(--popover-foreground);
--color-popover: var(--popover);
--color-card-foreground: var(--card-foreground);
--color-card: var(--card);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) + 4px);
--radius-2xl: calc(var(--radius) + 8px);
--radius-3xl: calc(var(--radius) + 12px);
--radius-4xl: calc(var(--radius) + 16px);
}
:root {
--radius: 0.625rem;
--background: oklch(1 0 0);
--foreground: oklch(0.145 0 0);
--card: oklch(1 0 0);
--card-foreground: oklch(0.145 0 0);
--popover: oklch(1 0 0);
--popover-foreground: oklch(0.145 0 0);
--primary: oklch(0.205 0 0);
--primary-foreground: oklch(0.985 0 0);
--secondary: oklch(0.97 0 0);
--secondary-foreground: oklch(0.205 0 0);
--muted: oklch(0.97 0 0);
--muted-foreground: oklch(0.556 0 0);
--accent: oklch(0.97 0 0);
--accent-foreground: oklch(0.205 0 0);
--destructive: oklch(0.577 0.245 27.325);
--border: oklch(0.922 0 0);
--input: oklch(0.922 0 0);
--ring: oklch(0.708 0 0);
--chart-1: oklch(0.646 0.222 41.116);
--chart-2: oklch(0.6 0.118 184.704);
--chart-3: oklch(0.398 0.07 227.392);
--chart-4: oklch(0.828 0.189 84.429);
--chart-5: oklch(0.769 0.188 70.08);
--sidebar: oklch(0.985 0 0);
--sidebar-foreground: oklch(0.145 0 0);
--sidebar-primary: oklch(0.205 0 0);
--sidebar-primary-foreground: oklch(0.985 0 0);
--sidebar-accent: oklch(0.97 0 0);
--sidebar-accent-foreground: oklch(0.205 0 0);
--sidebar-border: oklch(0.922 0 0);
--sidebar-ring: oklch(0.708 0 0);
}
.dark {
--background: oklch(0.145 0 0);
--foreground: oklch(0.985 0 0);
--card: oklch(0.205 0 0);
--card-foreground: oklch(0.985 0 0);
--popover: oklch(0.205 0 0);
--popover-foreground: oklch(0.985 0 0);
--primary: oklch(0.922 0 0);
--primary-foreground: oklch(0.205 0 0);
--secondary: oklch(0.269 0 0);
--secondary-foreground: oklch(0.985 0 0);
--muted: oklch(0.269 0 0);
--muted-foreground: oklch(0.708 0 0);
--accent: oklch(0.269 0 0);
--accent-foreground: oklch(0.985 0 0);
--destructive: oklch(0.704 0.191 22.216);
--border: oklch(1 0 0 / 10%);
--input: oklch(1 0 0 / 15%);
--ring: oklch(0.556 0 0);
--chart-1: oklch(0.488 0.243 264.376);
--chart-2: oklch(0.696 0.17 162.48);
--chart-3: oklch(0.769 0.188 70.08);
--chart-4: oklch(0.627 0.265 303.9);
--chart-5: oklch(0.645 0.246 16.439);
--sidebar: oklch(0.205 0 0);
--sidebar-foreground: oklch(0.985 0 0);
--sidebar-primary: oklch(0.488 0.243 264.376);
--sidebar-primary-foreground: oklch(0.985 0 0);
--sidebar-accent: oklch(0.269 0 0);
--sidebar-accent-foreground: oklch(0.985 0 0);
--sidebar-border: oklch(1 0 0 / 10%);
--sidebar-ring: oklch(0.556 0 0);
}
@layer base {
* {
@apply border-border outline-ring/50;
}
body {
@apply bg-background text-foreground;
}
}

11
src/app/history/page.tsx Normal file
View File

@@ -0,0 +1,11 @@
// ABOUTME: Historical data view for past training decisions.
// ABOUTME: Shows table of daily logs with biometrics and decisions.
export default function HistoryPage() {
return (
<div className="container mx-auto p-8">
<h1 className="text-2xl font-bold mb-8">History</h1>
{/* History table will be implemented here */}
<p className="text-gray-500">History table placeholder</p>
</div>
);
}

37
src/app/layout.tsx Normal file
View File

@@ -0,0 +1,37 @@
// ABOUTME: Root layout for PhaseFlow application.
// ABOUTME: Configures fonts, metadata, and global styles.
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});
const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});
export const metadata: Metadata = {
title: "PhaseFlow",
description:
"Automated training decisions for Hashimoto's thyroiditis based on menstrual cycle phases and Garmin biometrics",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
</body>
</html>
);
}

13
src/app/login/page.tsx Normal file
View File

@@ -0,0 +1,13 @@
// ABOUTME: Login page for user authentication.
// ABOUTME: Provides email/password login form using PocketBase auth.
export default function LoginPage() {
return (
<div className="flex min-h-screen items-center justify-center">
<div className="w-full max-w-md space-y-8 p-8">
<h1 className="text-2xl font-bold text-center">PhaseFlow Login</h1>
{/* Login form will be implemented here */}
<p className="text-center text-gray-500">Login form placeholder</p>
</div>
</div>
);
}

28
src/app/page.tsx Normal file
View File

@@ -0,0 +1,28 @@
// ABOUTME: Main dashboard page for PhaseFlow.
// ABOUTME: Displays today's training decision, biometrics, and quick actions.
export default function Dashboard() {
return (
<div className="min-h-screen bg-zinc-50 dark:bg-black">
<header className="border-b bg-white dark:bg-zinc-900 px-6 py-4">
<div className="container mx-auto flex justify-between items-center">
<h1 className="text-xl font-bold">PhaseFlow</h1>
<a
href="/settings"
className="text-sm text-zinc-600 hover:text-zinc-900"
>
Settings
</a>
</div>
</header>
<main className="container mx-auto p-6">
<div className="text-center py-12">
<p className="text-zinc-500">Dashboard placeholder</p>
<p className="text-sm text-zinc-400 mt-2">
Connect your Garmin and set your period date to get started.
</p>
</div>
</main>
</div>
);
}

11
src/app/plan/page.tsx Normal file
View File

@@ -0,0 +1,11 @@
// ABOUTME: Exercise plan reference page.
// ABOUTME: Displays the full monthly exercise plan by phase.
export default function PlanPage() {
return (
<div className="container mx-auto p-8">
<h1 className="text-2xl font-bold mb-8">Exercise Plan</h1>
{/* Exercise plan content will be implemented here */}
<p className="text-gray-500">Exercise plan placeholder</p>
</div>
);
}

View File

@@ -0,0 +1,13 @@
// ABOUTME: Garmin connection settings page.
// ABOUTME: Allows users to paste OAuth tokens from the bootstrap script.
export default function GarminSettingsPage() {
return (
<div className="container mx-auto p-8">
<h1 className="text-2xl font-bold mb-8">
Settings &gt; Garmin Connection
</h1>
{/* Garmin token input will be implemented here */}
<p className="text-gray-500">Garmin settings placeholder</p>
</div>
);
}

11
src/app/settings/page.tsx Normal file
View File

@@ -0,0 +1,11 @@
// ABOUTME: User settings page for profile and preferences.
// ABOUTME: Allows configuration of notification time, timezone, and cycle length.
export default function SettingsPage() {
return (
<div className="container mx-auto p-8">
<h1 className="text-2xl font-bold mb-8">Settings</h1>
{/* Settings form will be implemented here */}
<p className="text-gray-500">Settings form placeholder</p>
</div>
);
}