mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 08:52:10 +01:00
updated deps, added claude.md file
This commit is contained in:
114
CLAUDE.md
Normal file
114
CLAUDE.md
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
|
||||||
|
## Development Commands
|
||||||
|
|
||||||
|
**Core Development:**
|
||||||
|
- `pnpm dev` - Start development server (runs custom server.ts with schedulers)
|
||||||
|
- `pnpm dev:next-only` - Start Next.js only with Turbopack (no schedulers)
|
||||||
|
- `pnpm build` - Build production application
|
||||||
|
- `pnpm start` - Run production server
|
||||||
|
|
||||||
|
**Code Quality:**
|
||||||
|
- `pnpm lint` - Run ESLint
|
||||||
|
- `pnpm lint:fix` - Fix ESLint issues automatically
|
||||||
|
- `pnpm format` - Format code with Prettier
|
||||||
|
- `pnpm format:check` - Check formatting without fixing
|
||||||
|
|
||||||
|
**Database:**
|
||||||
|
- `pnpm prisma:generate` - Generate Prisma client
|
||||||
|
- `pnpm prisma:migrate` - Run database migrations
|
||||||
|
- `pnpm prisma:push` - Push schema changes to database
|
||||||
|
- `pnpm prisma:push:force` - Force reset database and push schema
|
||||||
|
- `pnpm prisma:seed` - Seed database with initial data
|
||||||
|
- `pnpm prisma:studio` - Open Prisma Studio database viewer
|
||||||
|
|
||||||
|
**Testing:**
|
||||||
|
- `pnpm test` - Run tests once
|
||||||
|
- `pnpm test:watch` - Run tests in watch mode
|
||||||
|
- `pnpm test:coverage` - Run tests with coverage report
|
||||||
|
|
||||||
|
**Markdown:**
|
||||||
|
- `pnpm lint:md` - Lint Markdown files
|
||||||
|
- `pnpm lint:md:fix` - Fix Markdown linting issues
|
||||||
|
|
||||||
|
## Architecture Overview
|
||||||
|
|
||||||
|
**LiveDash-Node** is a real-time analytics dashboard for monitoring user sessions with AI-powered analysis and processing pipeline.
|
||||||
|
|
||||||
|
### Tech Stack
|
||||||
|
- **Frontend:** Next.js 15 + React 19 + TailwindCSS 4
|
||||||
|
- **Backend:** Next.js API Routes + Custom Node.js server
|
||||||
|
- **Database:** PostgreSQL with Prisma ORM
|
||||||
|
- **Authentication:** NextAuth.js
|
||||||
|
- **AI Processing:** OpenAI API integration
|
||||||
|
- **Visualization:** D3.js, React Leaflet, Recharts
|
||||||
|
- **Scheduling:** Node-cron for background processing
|
||||||
|
|
||||||
|
### Key Architecture Components
|
||||||
|
|
||||||
|
**1. Multi-Stage Processing Pipeline**
|
||||||
|
The system processes user sessions through distinct stages tracked in `SessionProcessingStatus`:
|
||||||
|
- `CSV_IMPORT` - Import raw CSV data into `SessionImport`
|
||||||
|
- `TRANSCRIPT_FETCH` - Fetch transcript content from URLs
|
||||||
|
- `SESSION_CREATION` - Create normalized `Session` and `Message` records
|
||||||
|
- `AI_ANALYSIS` - AI processing for sentiment, categorization, summaries
|
||||||
|
- `QUESTION_EXTRACTION` - Extract questions from conversations
|
||||||
|
|
||||||
|
**2. Database Architecture**
|
||||||
|
- **Multi-tenant design** with `Company` as root entity
|
||||||
|
- **Dual storage pattern**: Raw CSV data in `SessionImport`, processed data in `Session`
|
||||||
|
- **1-to-1 relationship** between `SessionImport` and `Session` via `importId`
|
||||||
|
- **Message parsing** into individual `Message` records with order tracking
|
||||||
|
- **AI cost tracking** via `AIProcessingRequest` with detailed token usage
|
||||||
|
- **Flexible AI model management** through `AIModel`, `AIModelPricing`, and `CompanyAIModel`
|
||||||
|
|
||||||
|
**3. Custom Server Architecture**
|
||||||
|
- `server.ts` - Custom Next.js server with configurable scheduler initialization
|
||||||
|
- Three main schedulers: CSV import, import processing, and session processing
|
||||||
|
- Environment-based configuration via `lib/env.ts`
|
||||||
|
|
||||||
|
**4. Key Processing Libraries**
|
||||||
|
- `lib/scheduler.ts` - CSV import scheduling
|
||||||
|
- `lib/importProcessor.ts` - Raw data to Session conversion
|
||||||
|
- `lib/processingScheduler.ts` - AI analysis pipeline
|
||||||
|
- `lib/transcriptFetcher.ts` - External transcript fetching
|
||||||
|
- `lib/transcriptParser.ts` - Message parsing from transcripts
|
||||||
|
|
||||||
|
### Development Environment
|
||||||
|
|
||||||
|
**Environment Configuration:**
|
||||||
|
Environment variables are managed through `lib/env.ts` with .env.local file support:
|
||||||
|
- Database: PostgreSQL via `DATABASE_URL` and `DATABASE_URL_DIRECT`
|
||||||
|
- Authentication: `NEXTAUTH_SECRET`, `NEXTAUTH_URL`
|
||||||
|
- AI Processing: `OPENAI_API_KEY`
|
||||||
|
- Schedulers: `SCHEDULER_ENABLED`, various interval configurations
|
||||||
|
|
||||||
|
**Key Files to Understand:**
|
||||||
|
- `prisma/schema.prisma` - Complete database schema with enums and relationships
|
||||||
|
- `server.ts` - Custom server entry point
|
||||||
|
- `lib/env.ts` - Environment variable management and validation
|
||||||
|
- `app/` - Next.js App Router structure
|
||||||
|
|
||||||
|
**Testing:**
|
||||||
|
- Uses Vitest for unit testing
|
||||||
|
- Playwright for E2E testing
|
||||||
|
- Test files in `tests/` directory
|
||||||
|
|
||||||
|
### Important Notes
|
||||||
|
|
||||||
|
**Scheduler System:**
|
||||||
|
- Schedulers are optional and controlled by `SCHEDULER_ENABLED` environment variable
|
||||||
|
- Use `pnpm dev:next-only` to run without schedulers for pure frontend development
|
||||||
|
- Three separate schedulers handle different pipeline stages
|
||||||
|
|
||||||
|
**Database Migrations:**
|
||||||
|
- Always run `pnpm prisma:generate` after schema changes
|
||||||
|
- Use `pnpm prisma:migrate` for production-ready migrations
|
||||||
|
- Use `pnpm prisma:push` for development schema changes
|
||||||
|
|
||||||
|
**AI Processing:**
|
||||||
|
- All AI requests are tracked for cost analysis
|
||||||
|
- Support for multiple AI models per company
|
||||||
|
- Time-based pricing management for accurate cost calculation
|
||||||
38
package.json
38
package.json
@ -36,12 +36,12 @@
|
|||||||
"@types/d3-cloud": "^1.2.9",
|
"@types/d3-cloud": "^1.2.9",
|
||||||
"@types/d3-selection": "^3.0.11",
|
"@types/d3-selection": "^3.0.11",
|
||||||
"@types/geojson": "^7946.0.16",
|
"@types/geojson": "^7946.0.16",
|
||||||
"@types/leaflet": "^1.9.18",
|
"@types/leaflet": "^1.9.19",
|
||||||
"@types/node-fetch": "^2.6.12",
|
"@types/node-fetch": "^2.6.12",
|
||||||
"bcryptjs": "^3.0.2",
|
"bcryptjs": "^3.0.2",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"csv-parse": "^5.5.0",
|
"csv-parse": "^5.6.0",
|
||||||
"d3": "^7.9.0",
|
"d3": "^7.9.0",
|
||||||
"d3-cloud": "^1.2.7",
|
"d3-cloud": "^1.2.7",
|
||||||
"d3-selection": "^3.0.0",
|
"d3-selection": "^3.0.0",
|
||||||
@ -49,9 +49,9 @@
|
|||||||
"iso-639-1": "^3.1.5",
|
"iso-639-1": "^3.1.5",
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"lucide-react": "^0.525.0",
|
"lucide-react": "^0.525.0",
|
||||||
"next": "^15.3.2",
|
"next": "^15.3.4",
|
||||||
"next-auth": "^4.24.11",
|
"next-auth": "^4.24.11",
|
||||||
"node-cron": "^4.0.7",
|
"node-cron": "^4.1.1",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
@ -63,34 +63,34 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "^3.3.1",
|
"@eslint/eslintrc": "^3.3.1",
|
||||||
"@eslint/js": "^9.27.0",
|
"@eslint/js": "^9.30.0",
|
||||||
"@playwright/test": "^1.52.0",
|
"@playwright/test": "^1.53.1",
|
||||||
"@tailwindcss/postcss": "^4.1.11",
|
"@tailwindcss/postcss": "^4.1.11",
|
||||||
"@testing-library/dom": "^10.4.0",
|
"@testing-library/dom": "^10.4.0",
|
||||||
"@testing-library/react": "^16.3.0",
|
"@testing-library/react": "^16.3.0",
|
||||||
"@types/bcryptjs": "^2.4.2",
|
"@types/bcryptjs": "^3.0.0",
|
||||||
"@types/node": "^22.15.21",
|
"@types/node": "^24.0.6",
|
||||||
"@types/node-cron": "^3.0.8",
|
"@types/node-cron": "^3.0.11",
|
||||||
"@types/react": "^19.1.5",
|
"@types/react": "^19.1.8",
|
||||||
"@types/react-dom": "^19.1.5",
|
"@types/react-dom": "^19.1.6",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
||||||
"@typescript-eslint/parser": "^8.32.1",
|
"@typescript-eslint/parser": "^8.35.0",
|
||||||
"@vitejs/plugin-react": "^4.6.0",
|
"@vitejs/plugin-react": "^4.6.0",
|
||||||
"@vitest/coverage-v8": "^3.2.4",
|
"@vitest/coverage-v8": "^3.2.4",
|
||||||
"eslint": "^9.27.0",
|
"eslint": "^9.30.0",
|
||||||
"eslint-config-next": "^15.3.2",
|
"eslint-config-next": "^15.3.4",
|
||||||
"eslint-plugin-prettier": "^5.4.0",
|
"eslint-plugin-prettier": "^5.5.1",
|
||||||
"jsdom": "^26.1.0",
|
"jsdom": "^26.1.0",
|
||||||
"markdownlint-cli2": "^0.18.1",
|
"markdownlint-cli2": "^0.18.1",
|
||||||
"postcss": "^8.5.3",
|
"postcss": "^8.5.6",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.6.2",
|
||||||
"prettier-plugin-jinja-template": "^2.1.0",
|
"prettier-plugin-jinja-template": "^2.1.0",
|
||||||
"prisma": "^6.10.1",
|
"prisma": "^6.10.1",
|
||||||
"tailwindcss": "^4.1.11",
|
"tailwindcss": "^4.1.11",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"tsx": "^4.20.3",
|
"tsx": "^4.20.3",
|
||||||
"tw-animate-css": "^1.3.4",
|
"tw-animate-css": "^1.3.4",
|
||||||
"typescript": "^5.0.0",
|
"typescript": "^5.8.3",
|
||||||
"vite-tsconfig-paths": "^5.1.4",
|
"vite-tsconfig-paths": "^5.1.4",
|
||||||
"vitest": "^3.2.4"
|
"vitest": "^3.2.4"
|
||||||
},
|
},
|
||||||
|
|||||||
1384
pnpm-lock.yaml
generated
1384
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user