92 lines
No EOL
3 KiB
Markdown
92 lines
No EOL
3 KiB
Markdown
# CLAUDE.md
|
|
|
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
|
|
## Commands
|
|
|
|
```bash
|
|
# 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
|
|
|
|
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 |