A complete monorepo chat system with admin panel, built with React, Express, TypeScript, and powered by Skald AI.
- Authentication: Secure login/logout with httpOnly cookies
- Chat Interface: ChatGPT-like streaming chat with conversation history
- Admin Panel: User management with create, delete, and password reset
- Responsive Design: Works seamlessly on desktop and mobile
- Containerized: Full Docker support for easy deployment
- React 18 + TypeScript
- Vite
- TailwindCSS + shadcn/ui
- React Router
- Server-Sent Events (SSE) for streaming
- Express + TypeScript
- MikroORM (PostgreSQL)
- express-session with PostgreSQL store
- Skald AI SDK
- bcrypt for password hashing
- pnpm workspaces (monorepo)
- PostgreSQL 16
- Docker + docker-compose
- nginx (production frontend)
/
├── packages/
│ ├── backend/ # Express API
│ ├── frontend/ # React app
│ └── shared/ # Shared TypeScript types
├── docker-compose.yml
├── pnpm-workspace.yaml
└── .env
- Node.js 18+
- pnpm 8+
- Docker & Docker Compose (for PostgreSQL)
- Clone and install dependencies
cd chat-rh
cp .env.example .env
pnpm install- Configure environment variables
Edit .env and add your Skald API key:
SKALD_API_KEY=sk_proj_your_actual_key_here- Start PostgreSQL
docker-compose up postgres -d- Build shared package
cd packages/shared
pnpm build
cd ../..- Run database migrations
cd packages/backend
pnpm migration:up- Create an admin user
cd packages/backend
pnpm create-adminFollow the prompts to create your admin account.
- Start development servers
In the root directory:
pnpm devThis will start:
- Backend on http://localhost:3001
- Frontend on http://localhost:5173
Your system is now running! Open http://localhost:5173 in your browser.
Note: Docker deployment currently has issues with bcrypt native module compilation in Alpine Linux. For production, we recommend deploying the backend and frontend separately or using a Debian-based image. Development mode (above) works perfectly.
- Build all packages
pnpm build- Start PostgreSQL
docker-compose up postgres -d- Run migrations
cd packages/backend
pnpm migration:up- Start the backend
cd packages/backend
pnpm start- Serve the frontend
Use any static file server:
cd packages/frontend
npx serve distThe application will be available at the configured ports.
- Login: Use credentials provided by admin
- First Login: You'll be prompted to change password
- Chat: Start conversations with AI assistant
- History: All conversations are persisted in the database
- Login: Use admin credentials
- Access Admin Panel: Click "Admin Panel" button
- User Management:
- Create new users (auto-generates temporary password)
- Delete users
- Reset user passwords
- Chat: Admins can also use the chat interface
POST /api/auth/login- LoginPOST /api/auth/logout- LogoutGET /api/auth/me- Get current userPOST /api/auth/change-password- Change password
GET /api/admin/users- List all usersPOST /api/admin/users- Create userDELETE /api/admin/users/:id- Delete userPOST /api/admin/users/:id/reset-password- Reset password
GET /api/chats- Get user's chatsGET /api/chats/:id- Get chat with messagesDELETE /api/chats/:id- Delete chatPOST /api/stream- Stream chat messages (SSE)
pnpm dev # Start all packages in dev mode
pnpm build # Build all packages
pnpm clean # Clean all dist folders
pnpm type-check # Type check all packagespnpm dev # Start dev server
pnpm build # Build for production
pnpm create-admin # Create admin user
pnpm migration:create # Create new migration
pnpm migration:up # Run migrationspnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production buildDATABASE_URL- PostgreSQL connection stringDB_HOST,DB_PORT,DB_NAME,DB_USER,DB_PASSWORD- Database configPORT- Backend port (default: 3001)NODE_ENV- Environment (development/production)SESSION_SECRET- Session encryption keySKALD_API_KEY- Skald AI API key
VITE_API_URL- Backend API URL
- Uses PostgreSQL-backed sessions for reliability
- httpOnly cookies for security
- 7-day session lifetime
- Conversation history stored in database
- Context included in system prompt for continuity
- New chat_id generated on page refresh (per requirements)
- Server-Sent Events (SSE) for real-time responses
- Chunked token delivery for smooth UX
- Automatic reconnection handling
- Password hashing with bcrypt
- Role-based access control (user/admin)
- Forced password change on first login
- CORS configured for credentials
# Check if PostgreSQL is running
docker ps
# View logs
docker logs chatrh-postgres# View backend logs
docker logs chatrh-backend
# Restart backend
docker-compose restart backend# Clear browser cache
# Check browser console for errors
# Verify API proxy in vite.config.tsMIT