2025-12-22 14:09:32 +01:00
|
|
|
# CLAUDE.md — LetsBe Hub
|
|
|
|
|
|
|
|
|
|
## Purpose
|
|
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
You are the engineering assistant for the LetsBe Hub Dashboard.
|
|
|
|
|
This is the admin dashboard and API for managing the LetsBe Cloud platform.
|
2025-12-22 14:09:32 +01:00
|
|
|
|
|
|
|
|
The Hub provides:
|
|
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
- **Admin Dashboard**: Next.js admin UI for platform management
|
|
|
|
|
- **Customer Management**: Create/manage customers and subscriptions
|
|
|
|
|
- **Order Management**: Process and track provisioning orders
|
|
|
|
|
- **Server Monitoring**: View and manage tenant servers
|
|
|
|
|
- **Token Usage Tracking**: Monitor AI token consumption
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
## Tech Stack
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
- **Next.js 15** (App Router)
|
|
|
|
|
- **TypeScript** (strict mode)
|
|
|
|
|
- **Prisma** (PostgreSQL ORM)
|
|
|
|
|
- **TanStack Query** (React Query v5)
|
|
|
|
|
- **Tailwind CSS** + shadcn/ui components
|
|
|
|
|
- **NextAuth.js** (authentication)
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
## Project Structure
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
```
|
|
|
|
|
src/
|
|
|
|
|
├── app/ # Next.js App Router
|
|
|
|
|
│ ├── admin/ # Admin dashboard pages
|
|
|
|
|
│ │ ├── customers/ # Customer management
|
|
|
|
|
│ │ ├── orders/ # Order management
|
|
|
|
|
│ │ ├── servers/ # Server monitoring
|
|
|
|
|
│ │ └── layout.tsx # Admin layout with sidebar
|
|
|
|
|
│ ├── api/v1/ # API routes
|
|
|
|
|
│ │ ├── admin/ # Admin API endpoints
|
|
|
|
|
│ │ └── public/ # Public API endpoints
|
|
|
|
|
│ └── (auth)/ # Authentication pages
|
|
|
|
|
├── components/
|
|
|
|
|
│ ├── admin/ # Admin-specific components
|
|
|
|
|
│ └── ui/ # Reusable UI components
|
|
|
|
|
├── hooks/ # React Query hooks
|
|
|
|
|
├── lib/ # Utilities and shared code
|
|
|
|
|
│ └── prisma.ts # Prisma client singleton
|
|
|
|
|
└── types/ # TypeScript type definitions
|
|
|
|
|
```
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
## API Routes
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
### Admin Endpoints (authenticated)
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
```
|
|
|
|
|
# Customers
|
|
|
|
|
GET /api/v1/admin/customers # List customers
|
|
|
|
|
GET /api/v1/admin/customers/[id] # Get customer detail
|
|
|
|
|
PATCH /api/v1/admin/customers/[id] # Update customer
|
|
|
|
|
|
|
|
|
|
# Orders
|
|
|
|
|
GET /api/v1/admin/orders # List orders
|
|
|
|
|
POST /api/v1/admin/orders # Create order
|
|
|
|
|
GET /api/v1/admin/orders/[id] # Get order detail
|
|
|
|
|
PATCH /api/v1/admin/orders/[id] # Update order
|
|
|
|
|
GET /api/v1/admin/orders/[id]/logs # Get provisioning logs (SSE)
|
|
|
|
|
|
|
|
|
|
# Servers
|
|
|
|
|
GET /api/v1/admin/servers # List servers (derived from orders)
|
|
|
|
|
|
|
|
|
|
# Dashboard
|
|
|
|
|
GET /api/v1/admin/dashboard/stats # Dashboard statistics
|
|
|
|
|
```
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
## Development Commands
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
```bash
|
|
|
|
|
# Install dependencies
|
|
|
|
|
npm install
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
# Start development server
|
|
|
|
|
npm run dev
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
# Run database migrations
|
|
|
|
|
npx prisma migrate dev
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
# Generate Prisma client
|
|
|
|
|
npx prisma generate
|
|
|
|
|
|
|
|
|
|
# Seed database
|
|
|
|
|
npm run db:seed
|
|
|
|
|
|
|
|
|
|
# Type checking
|
|
|
|
|
npm run typecheck
|
|
|
|
|
|
|
|
|
|
# Build for production
|
|
|
|
|
npm run build
|
|
|
|
|
|
|
|
|
|
# App available at http://localhost:3000
|
2025-12-22 14:09:32 +01:00
|
|
|
```
|
|
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
## Key Patterns
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
### React Query Hooks
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
All data fetching uses React Query hooks in `src/hooks/`:
|
|
|
|
|
- `useCustomers()`, `useCustomer(id)` - Customer data
|
|
|
|
|
- `useOrders()`, `useOrder(id)` - Order data
|
|
|
|
|
- `useServers()` - Server list
|
|
|
|
|
- `useDashboardStats()` - Dashboard metrics
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
Mutations follow the pattern:
|
|
|
|
|
- `useCreateOrder()`, `useUpdateOrder()`
|
|
|
|
|
- Automatic cache invalidation via `queryClient.invalidateQueries()`
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
### API Route Pattern
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
```typescript
|
|
|
|
|
export async function GET(request: NextRequest) {
|
|
|
|
|
// Parse query params
|
|
|
|
|
const searchParams = request.nextUrl.searchParams
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
// Database query with Prisma
|
|
|
|
|
const data = await prisma.model.findMany({...})
|
|
|
|
|
|
|
|
|
|
// Return JSON response
|
|
|
|
|
return NextResponse.json(data)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Component Pattern
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
```typescript
|
|
|
|
|
'use client'
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
export function MyComponent() {
|
|
|
|
|
const { data, isLoading, error } = useMyData()
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
if (isLoading) return <Skeleton />
|
|
|
|
|
if (error) return <ErrorMessage error={error} />
|
2025-12-22 14:09:32 +01:00
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
return <div>...</div>
|
|
|
|
|
}
|
2025-12-22 14:09:32 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Coding Conventions
|
|
|
|
|
|
2026-01-06 12:35:01 +01:00
|
|
|
- Use `'use client'` directive for client components
|
|
|
|
|
- All API routes return `NextResponse.json()`
|
|
|
|
|
- Use Prisma for all database operations
|
|
|
|
|
- Follow existing shadcn/ui component patterns
|
|
|
|
|
- Use React Query for server state management
|
|
|
|
|
- TypeScript strict mode - no `any` types
|