A modern full-stack TypeScript platform built with Turborepo monorepo architecture, featuring authentication, user management, and AI-powered chat functionality.
- 🔐 Multi-Provider Authentication - GitHub OAuth + Email/Password with NextAuth v5
- 💬 AI Chat System - Real-time chat with persistent history using IndexedDB
- 👥 User Management - Role-based access control with invite code system
- 🎨 Modern UI - Ant Design Pro Components with Tailwind CSS
- 🚀 High Performance - Next.js 15 with Turbopack and optimized builds
- 🔄 Real-time Features - Redis integration for caching and sessions
- 📊 Database - PostgreSQL with Prisma ORM and connection pooling
- 🎭 Animations - GSAP integration with various animation examples
apps/api-server- NestJS backend API (Port 8080)apps/admin-web- Next.js frontend application (Port 8081)
@repo/prisma- Database schema and client@repo/database- Database utilities and repositories@repo/env- Environment management with validation@repo/config- Shared configurations (ESLint, Prettier, TypeScript)@repo/ui- Reusable React components@repo/chat-ui- Chat interface components@repo/types- Shared TypeScript definitions@repo/utils- Common utility functions
- Node.js >= 18
- pnpm (recommended package manager)
- PostgreSQL database
- Redis (for sessions and caching)
# Clone the repository
git clone <repository-url>
cd kitz-platform
# Install dependencies
pnpm install
# Set up environment variables
cp packages/env/.env.example packages/env/.env.local
# Generate Prisma client
cd packages/prisma
pnpm prisma-generate
# Run database migrations
pnpm prisma-migrate
# Seed the database (optional)
pnpm prisma-seed# Start all applications in development mode
pnpm dev
# Or start individually
cd apps/api-server && pnpm dev # API server on port 8080
cd apps/admin-web && pnpm dev # Web app on port 8081pnpm dev # Start all apps in development mode
pnpm build # Build all apps and packages
pnpm test # Run tests across all packages
pnpm test:e2e # Run end-to-end tests
pnpm lint # Lint all packages and apps
pnpm format # Format all TypeScript/JavaScript filescd packages/prisma
pnpm prisma-migrate # Run database migrations
pnpm prisma-generate # Generate Prisma client
pnpm prisma-seed # Seed database with sample dataCreate environment files in packages/env/:
AUTH_SECRET- NextAuth secret keyPOSTGRES_URL_PRISMA_ACCELERATE- Database connection URLPOSTGRES_URL_NON_POOLING- Direct database URLREDIS_HOST- Redis server hostNEXT_PUBLIC_API_URL- API base URLNEXT_PUBLIC_DIFY_BASE_URL- Dify AI service URLAUTH_GITHUB_ID- GitHub OAuth client IDAUTH_GITHUB_SECRET- GitHub OAuth client secret
# Run all tests
pnpm test
# Run specific app tests
cd apps/api && pnpm test
cd apps/web && pnpm test
# Run in watch mode
pnpm test --watch
# Run E2E tests
pnpm test:e2e- Dual authentication: GitHub OAuth and email/password credentials
- JWT token management with automatic refresh
- Protected routes with role-based access control
- Session management with Redis
- AI-powered chat bot with floating interface
- Persistent message history using IndexedDB
- Message pagination for performance
- Real-time typing indicators and loading states
- Integration with Dify AI platform
- User management with role-based permissions
- Invite code system for controlled registration
- GSAP animation examples and demos
- System administration panels
- PostgreSQL with Prisma ORM
- Connection pooling with Prisma Accelerate
- Type-safe database operations
- Automated migrations and seeding
- Frontend: Next.js 15, React 19, TypeScript, Tailwind CSS, Ant Design Pro
- Backend: NestJS, Node.js, TypeScript, JWT Authentication
- Database: PostgreSQL, Prisma ORM, Redis
- Tools: Turborepo, pnpm, ESLint, Prettier, Jest, Playwright
- AI/ML: Dify integration for chat functionality
- Animation: GSAP for smooth animations and transitions
- Package Manager: Always use
pnpmfor dependency management - Build Order: Packages must be built before applications
- Environment: Environment files are managed centrally in
/packages/env - Testing: Run
pnpm buildbefore testing to avoid dependency issues - Database: Use Prisma migrations for schema changes
- Authentication: JWT tokens expire in 1 hour with automatic refresh
- VSCode dev container setup
- Supabase integration evaluation
- Refine framework integration
- SWR implementation for data fetching
- API response format standardization
- Session token behavior optimization
- Enhanced error handling and logging
-
解决pnpm test报错问题:先执行build后在test就不报错了
-
跑通api controller测试用例,支持分页查询
-
将通用查询方法都提取到base-service和base-controller中:算了,类型定义太麻烦
-
接入supabase和refine
-
登录鉴权放在api好还是web好?:可能放在web更简便,api需要额外协同第三方登录的token鉴权,但放web需要解决与api的token互通和将session token转变为request header token。最终放在了api中。
-
为什么next-auth默认会将token存储在cookie中:next-auth源码会在登录成功后将token放入cookie中
-
我每次刷新页面输出的token.exp都会变化,且是30天后的时间戳,与我预期不符:这是NextAuth内部管理session生成的,其实本项目完全不依赖NextAuth鉴权
-
检查server comp和client comp的交界点,我经常会受制于client comp不能包含server comp,最佳实践是什么 用户提出的核心问题很好:在 Next.js 中 server 和 client 的边界应该定在哪里?
让我分析几种方案:
方案1:将权限检查提升到最上层 (推荐)
在 dashboard/layout.tsx 中根据路径进行权限检查
方案2:重新设计边界
将 Client 边界推到叶子组件,保持布局层为 Server
方案3:使用路由中间件
在 middleware.ts 中处理路由级权限
方案4:混合权限策略
Server 层做核心检查,Client 层做 UI 控制
我觉得方案1最合适,因为:
-
保持了现有架构的一致性
-
集中化权限管理
-
简化了系统复杂度,减少了不必要的权限逻辑分散
This project is licensed under the MIT License.