tia/CLAUDE.md

3.2 KiB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Commands

# Development
pnpm dev          # Start dev server at http://localhost:3000
pnpm build        # Production build
pnpm start        # Start production server

# Database (drizzle)
pnpm db:push      # Push schema to database
pnpm db:generate  # Generate drizzle types
pnpm db:studio   # Open DB studio (or use direct SQL)

# Docker
docker-compose -f docker-compose.dev.yml up -d    # Start local Postgres

Note: Running from /Users/manohar_air/MyProjects/Tia/tia directory.

Architecture

Tech Stack

  • Framework: Next.js 16 with App Router (src/app/)
  • Database: PostgreSQL 16 with pgvector + Drizzle ORM
  • Auth: NextAuth v5 (beta) with magic links
  • AI: LiteLLM gateway → MiniMax model (minimax-2.7)
  • Storage: Cloudflare R2 for media uploads
  • Styling: Tailwind CSS v4

Project Structure

src/
├── app/                    # Next.js App Router pages
│   ├── api/               # API routes (auth, logs, ai, growth, etc.)
│   ├── page.tsx            # Home (Quick Log + AI card)
│   ├── ai/               # AI chat page with sidebar
│   ├── medical/           # Vaccination tracking
│   ├── growth/           # Growth charts
│   ├── memories/         # Photo gallery
│   ├── menu/            # Navigation menu
│   ├── onboarding/      # First-time setup
│   └── login/           # Magic link login
├── libs/                  # Shared utilities (if any)
└── styles/               # Global styles
drizzle/                  # Database migrations
docs/                     # Design docs

Database

  • Migrations: SQL files in drizzle/ (not using drizzle-kit push)
  • Apply: psql directly or via docker-compose exec
  • RLS: Row-level security for multi-family isolation

Data Models

  • Family: Parent account container
  • Members: Adults in family (mom, dad, etc.)
  • Children: Baby profiles with birth date
  • Logs: Feed, sleep, diaper entries with timestamps
  • Vaccinations: IAP schedule tracking
  • Growth: Weight/height over time
  • Memories: Photos with vision AI tags

Key Patterns

Offline Queue: Uses localStorage (tia_offline_queue) for failed API calls, retries when online.

Chat Sessions: Stored in localStorage (tia_chat_sessions) as array of sessions with messages. Shared between home page AI card and /ai page.

API Routes: Return standard JSON { entries: [...] } format for lists.

AI Integration:

  • Route: /api/ai → LiteLLM at https://llm.manohargupta.com
  • Model: minimax-2.7
  • See /docs/debugging.md for troubleshooting

Environment Variables

Set in .env.local for development, or in Dokploy dashboard for production.

See .env.example for all required vars. Key ones:

  • DATABASE_URL - PostgreSQL connection
  • AUTH_SECRET - NextAuth secret
  • LITELLM_BASE_URL - AI gateway URL
  • LITELLM_API_KEY - AI API key
  • R2_ACCOUNT_ID - Cloudflare R2 account ID
  • R2_ACCESS_KEY_ID - R2 access key
  • R2_SECRET_ACCESS_KEY - R2 secret key
  • R2_BUCKET_NAME - R2 bucket name