Update CLAUDE.md with project architecture and patterns
This commit is contained in:
parent
e7411ee31f
commit
5943ab19eb
1 changed files with 79 additions and 21 deletions
100
CLAUDE.md
100
CLAUDE.md
|
|
@ -1,34 +1,92 @@
|
|||
# AI Integration Debugging Guide
|
||||
# CLAUDE.md
|
||||
|
||||
## Problem: "Invalid model name"
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
# Check available models
|
||||
curl -s "https://llm.manohargupta.com/v1/models" \
|
||||
-H "Authorization: Bearer sk-tiger-gateway-..."
|
||||
# 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
|
||||
```
|
||||
|
||||
Use model name from response: `minimax-2.7` (not `tiger-minimax`)
|
||||
**Note:** Running from `/Users/manohar_air/MyProjects/Tia/tia` directory.
|
||||
|
||||
## Problem: Empty response
|
||||
## Architecture
|
||||
|
||||
Add debug logging and check server health:
|
||||
```bash
|
||||
curl -s "https://llm.manohargupta.com/health"
|
||||
### 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
|
||||
```
|
||||
|
||||
## Problem: Network errors
|
||||
### Database
|
||||
|
||||
- Use full domain: `https://llm.manohargupta.com` (not internal hostname)
|
||||
- Add `https://` prefix
|
||||
- **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
|
||||
|
||||
## Test Script
|
||||
### Data Models
|
||||
|
||||
```bash
|
||||
curl -s -X POST "https://llm.manohargupta.com/v1/chat/completions" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer sk-tiger-gateway-YOUR_KEY" \
|
||||
-d '{"model":"minimax-2.7","messages":[{"role":"user","content":"hi"}]}'
|
||||
```
|
||||
- **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
|
||||
|
||||
See `/docs/debugging.md` for full guide.
|
||||
### 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
|
||||
Loading…
Add table
Reference in a new issue