From 1c48ee6512d5570e6d732890298829080b37868b Mon Sep 17 00:00:00 2001 From: David Date: Thu, 23 Oct 2025 14:22:15 +0200 Subject: [PATCH] feature claude --- .claude/settings.local.json | 16 +++++++- CLAUDE.md | 74 +++++++++++++++++++++++++++---------- 2 files changed, 70 insertions(+), 20 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 496b472..c25fee6 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -5,7 +5,21 @@ "Bash(PGPASSWORD=xpeditis_dev_password psql -h localhost -p 5432 -U xpeditis -d xpeditis_dev -c \"\nINSERT INTO organizations (id, name, type, address_street, address_city, address_postal_code, address_country, is_active)\nVALUES (\n ''00000000-0000-0000-0000-000000000001'',\n ''Default Organization'',\n ''FREIGHT_FORWARDER'',\n ''123 Main Street'',\n ''New York'',\n ''10001'',\n ''US'',\n true\n);\nSELECT id, name FROM organizations;\")", "Bash(PGPASSWORD=xpeditis_dev_password psql -h localhost -p 5432 -U xpeditis -d xpeditis_dev -c \"SELECT id, name FROM organizations WHERE id = ''00000000-0000-0000-0000-000000000001'';\")", "Bash(PGPASSWORD=xpeditis_dev_password psql -h localhost -p 5432 -U xpeditis -d xpeditis_dev -c \"\nINSERT INTO organizations (id, name, type, address_street, address_city, address_postal_code, address_country, is_active)\nVALUES (\n ''a1234567-0000-4000-8000-000000000001'',\n ''Test Organization'',\n ''FREIGHT_FORWARDER'',\n ''123 Main Street'',\n ''New York'',\n ''10001'',\n ''US'',\n true\n)\nON CONFLICT (id) DO NOTHING;\nSELECT id, name FROM organizations LIMIT 2;\")", - "Bash(ACCESS_TOKEN=\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzg1MDVkMi1hMmVlLTQ5NmMtOWNjZC1iNjUyN2FjMzcxODgiLCJlbWFpbCI6InRlc3Q0QHhwZWRpdGlzLmNvbSIsInJvbGUiOiJ1c2VyIiwib3JnYW5pemF0aW9uSWQiOiJhMTIzNDU2Ny0wMDAwLTQwMDAtODAwMC0wMDAwMDAwMDAwMDEiLCJ0eXBlIjoiYWNjZXNzIiwiaWF0IjoxNzYxMDczOTg4LCJleHAiOjE3NjEwNzQ4ODh9.-kmaFPj8vbhyEKQJr-kuM-WR_HvrYt6547BfLg0-HQs\")" + "Bash(ACCESS_TOKEN=\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzg1MDVkMi1hMmVlLTQ5NmMtOWNjZC1iNjUyN2FjMzcxODgiLCJlbWFpbCI6InRlc3Q0QHhwZWRpdGlzLmNvbSIsInJvbGUiOiJ1c2VyIiwib3JnYW5pemF0aW9uSWQiOiJhMTIzNDU2Ny0wMDAwLTQwMDAtODAwMC0wMDAwMDAwMDAwMDEiLCJ0eXBlIjoiYWNjZXNzIiwiaWF0IjoxNzYxMDczOTg4LCJleHAiOjE3NjEwNzQ4ODh9.-kmaFPj8vbhyEKQJr-kuM-WR_HvrYt6547BfLg0-HQs\")", + "Bash(npm run dev:*)", + "Bash(curl -s -X POST http://localhost:4000/api/v1/auth/register -H \"Content-Type: application/json\" -d '{\"\"\"\"email\"\"\"\":\"\"\"\"finaltest@xpeditis.com\"\"\"\",\"\"\"\"password\"\"\"\":\"\"\"\"TestPassword123\"\"\"\",\"\"\"\"firstName\"\"\"\":\"\"\"\"Final\"\"\"\",\"\"\"\"lastName\"\"\"\":\"\"\"\"Test\"\"\"\",\"\"\"\"organizationId\"\"\"\":\"\"\"\"a1234567-0000-4000-8000-000000000001\"\"\"\"}')", + "Bash(curl -s -X POST http://localhost:4000/api/v1/auth/login -H \"Content-Type: application/json\" -d '{\"\"email\"\":\"\"test4@xpeditis.com\"\",\"\"password\"\":\"\"SecurePassword123\"\"}')", + "Bash(TOKEN=\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzg1MDVkMi1hMmVlLTQ5NmMtOWNjZC1iNjUyN2FjMzcxODgiLCJlbWFpbCI6InRlc3Q0QHhwZWRpdGlzLmNvbSIsInJvbGUiOiJ1c2VyIiwib3JnYW5pemF0aW9uSWQiOiJhMTIzNDU2Ny0wMDAwLTQwMDAtODAwMC0wMDAwMDAwMDAwMDEiLCJ0eXBlIjoiYWNjZXNzIiwiaWF0IjoxNzYxMDc1MDI3LCJleHAiOjE3NjEwNzU5Mjd9.dl2mLi0LrXcl-PwdkijW1ZQ3muboTgX9gGU65mlAq1U\")", + "Bash(echo \"Test 1: GET /auth/me\" curl -s -X GET http://localhost:4000/api/v1/auth/me -H \"Authorization: Bearer $TOKEN\")", + "Bash(echo \"Test 2: GET /users\" curl -s -o /dev/null -w \"Status: %{http_code}\\n\" -X GET http://localhost:4000/api/v1/api/v1/users -H \"Authorization: Bearer $TOKEN\")", + "Bash(echo \"Test 3: GET /bookings\" curl -s -o /dev/null -w \"Status: %{http_code}\\n\" -X GET http://localhost:4000/api/v1/api/v1/bookings -H \"Authorization: Bearer $TOKEN\")", + "Bash(echo \"Test 4: GET /dashboard/kpis\" curl -s -o /dev/null -w \"Status: %{http_code}\\n\" -X GET http://localhost:4000/api/v1/api/v1/dashboard/kpis -H \"Authorization: Bearer $TOKEN\")", + "Bash(echo \"Test 5: GET /notifications\" curl -s -o /dev/null -w \"Status: %{http_code}\\n\" -X GET http://localhost:4000/api/v1/api/v1/notifications -H \"Authorization: Bearer $TOKEN\")", + "Bash(echo \"Test 6: GET /organizations\" curl -s -o /dev/null -w \"Status: %{http_code}\\n\" -X GET http://localhost:4000/api/v1/api/v1/organizations -H \"Authorization: Bearer $TOKEN\")", + "Bash(curl:*)", + "Bash(cp:*)", + "Bash(TOKEN=\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJlMGM4NzQ2Mi1hNThlLTQ2ODgtOTE5OS0xYzMyM2Q4MDA1N2IiLCJlbWFpbCI6InRlc3Rmcm9udGVuZEB4cGVkaXRpcy5jb20iLCJyb2xlIjoidXNlciIsIm9yZ2FuaXphdGlvbklkIjoiYTEyMzQ1NjctMDAwMC00MDAwLTgwMDAtMDAwMDAwMDAwMDAxIiwidHlwZSI6ImFjY2VzcyIsImlhdCI6MTc2MTA3NTk3OCwiZXhwIjoxNzYxMDc2ODc4fQ.UOfZG-koAfETtmyxXtlpRfibtO4bD9i_KqQ1Ex6mbh8\")", + "Bash(PGPASSWORD=xpeditis_dev_password psql -h localhost -p 5432 -U xpeditis -d xpeditis_dev -c \"SELECT id, name FROM organizations LIMIT 5;\")" ], "deny": [], "ask": [] diff --git a/CLAUDE.md b/CLAUDE.md index c508ea9..17ce35d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -19,7 +19,9 @@ cd apps/backend && npm install cd ../frontend && npm install # Start infrastructure (PostgreSQL + Redis) -docker-compose up -d +docker-compose up -d # Development (uses docker-compose.yml) +# OR +docker-compose -f docker-compose.dev.yml up -d # Run database migrations cd apps/backend @@ -39,6 +41,32 @@ cd apps/frontend && npm run dev - Backend API: http://localhost:4000 - API Docs (Swagger): http://localhost:4000/api/docs +### Monorepo Scripts (from root) + +```bash +# Development +npm run backend:dev # Start backend dev server +npm run frontend:dev # Start frontend dev server + +# Testing +npm run backend:test # Run backend unit tests +npm run frontend:test # Run frontend tests +npm run backend:lint # Lint backend code +npm run frontend:lint # Lint frontend code + +# Code Quality +npm run format # Format all code (Prettier) +npm run format:check # Check formatting + +# Build +npm run backend:build # Build backend for production +npm run frontend:build # Build frontend for production + +# Utilities +npm run install:all # Install deps for all workspaces +npm run clean # Clean all node_modules and build artifacts +``` + ### Testing Commands #### Backend Tests @@ -136,22 +164,6 @@ npm run build npm start ``` -### Code Quality - -```bash -# Format all code -npm run format # From root - -# Check formatting -npm run format:check - -# Lint backend -npm run backend:lint - -# Lint frontend -npm run frontend:lint -``` - ## Architecture ### Hexagonal Architecture (Ports & Adapters) @@ -192,6 +204,27 @@ apps/backend/src/ 3. **TypeScript path aliases**: Use `@domain/*`, `@application/*`, `@infrastructure/*` 4. **Testing**: Domain tests must run without NestJS TestingModule +### Frontend Architecture (Next.js 14 App Router) + +``` +apps/frontend/src/ +├── app/ # Next.js 14 App Router pages (routing) +├── components/ # React components +│ ├── ui/ # shadcn/ui components (Button, Dialog, etc.) +│ └── features/ # Feature-specific components +├── hooks/ # Custom React hooks +├── lib/ # Utilities and API client +├── types/ # TypeScript type definitions +└── utils/ # Helper functions +``` + +**Frontend Patterns**: +- Server Components by default, Client Components when needed (`"use client"`) +- React Hook Form + Zod for form validation +- TanStack Query for server state management +- Zustand for client state management +- shadcn/ui for accessible UI components + ### Tech Stack **Backend**: @@ -211,6 +244,7 @@ apps/backend/src/ - TanStack Table (data grids) - React Hook Form + Zod (forms) - Socket.IO (real-time updates) +- Tailwind CSS + shadcn/ui **Infrastructure**: - Docker + Docker Compose @@ -325,7 +359,7 @@ NEXT_PUBLIC_API_URL=http://localhost:4000 NEXT_PUBLIC_WS_URL=ws://localhost:4000 ``` -See `.env.example` files for all available variables. +See `apps/backend/.env.example` and `apps/frontend/.env.example` for all available variables. ## API Documentation @@ -424,7 +458,7 @@ docker build -t xpeditis-backend:latest -f apps/backend/Dockerfile . docker build -t xpeditis-frontend:latest -f apps/frontend/Dockerfile . # Run with Docker Compose -docker-compose -f docker/docker-compose.prod.yml up -d +docker-compose -f docker/portainer-stack-production.yml up -d ``` ### Production Deployment (AWS) @@ -443,6 +477,8 @@ See [DEPLOYMENT.md](DEPLOYMENT.md) for complete instructions: - Deploy to staging/production via Portainer - Run smoke tests post-deployment +See [docker/PORTAINER_DEPLOYMENT_GUIDE.md](docker/PORTAINER_DEPLOYMENT_GUIDE.md) for Portainer setup. + ## Performance Targets - Rate search: <2s for 90% of requests (with cache)