A full-stack web application that provides a ChatGPT-style interface for interacting with Large Language Models (LLMs), featuring authentication, organization management, credit-based usage, and real-time notifications.
- Username/Password Authentication: Secure sign-up and sign-in functionality
- Google OAuth Integration: Ready for Google Sign-In implementation
- Automatic Organization Creation: Default organization created on first registration
- User Role Management: Admin and member roles with appropriate permissions
- ChatGPT-style UI: Clean, responsive design matching modern chat interfaces
- Persistent Chat History: All conversations stored and retrievable
- Multiple Chat Sessions: Create and manage multiple conversation threads
- Real-time Messaging: Instant message delivery and responses
- Token Usage Tracking: Monitor API usage and costs
- Usage-based Billing: Credits deducted based on token consumption
- Real-time Credit Display: Live credit counter in the top bar
- Usage Restrictions: Prevent messaging when credits are exhausted
- Transparent Pricing: Clear indication of credit costs per message
- Multi-organization Support: Users can belong to multiple organizations
- Active Organization Switching: Switch between organizations seamlessly
- Member Invitation System: Invite users by email (database record creation)
- Role-based Access Control: Admin and member permissions
- Organization CRUD Operations: Create, rename, and manage organizations
- Socket.IO Integration: WebSocket-based real-time communication
- Global & Targeted Notifications: Broadcast or user-specific messages
- Notification Panel: Expandable notification center with history
- Persistent Storage: All notifications stored in database
- Read/Unread Status: Track notification states
- Responsive Design: Mobile-friendly interface
- Error Handling: Comprehensive error management and user feedback
- Loading States: Proper loading indicators throughout the app
- Data Validation: Input validation on both client and server
- Security: JWT authentication, rate limiting, and input sanitization
- React.js 18 - Modern React with hooks
- Material-UI (MUI) - Professional UI components
- Redux Toolkit - State management
- React Router - Client-side routing
- Socket.IO Client - Real-time communication
- Axios - HTTP client
- React Hot Toast - Notifications
- Node.js - JavaScript runtime
- Express.js - Web framework
- Socket.IO - WebSocket server
- PostgreSQL - Primary database
- JWT - Authentication tokens
- bcryptjs - Password hashing
- OpenAI API - LLM integration
- Vite - Build tool
- Concurrently - Development scripts
- Helmet - Security headers
- CORS - Cross-origin resource sharing
- Rate Limiting - API protection
- Node.js (v16 or higher)
- PostgreSQL (v12 or higher)
- OpenAI API key
- Git
git clone https://github.com/1234-ad/llm-chat-platform.git
cd llm-chat-platform# Install root dependencies
npm install
# Install all dependencies (root, server, client)
npm run install-all# Create PostgreSQL database
createdb llm_chat_platform
# Run migrations
cd server
npm run migratecd server
cp .env.example .envEdit server/.env:
# Database
DATABASE_URL=postgresql://username:password@localhost:5432/llm_chat_platform
# JWT Secret (generate a secure random string)
JWT_SECRET=your-super-secret-jwt-key-here
# OpenAI API
OPENAI_API_KEY=your-openai-api-key
# Google OAuth (optional)
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
# Server Configuration
PORT=5000
NODE_ENV=development
SESSION_SECRET=your-session-secret-key
# Frontend URL
FRONTEND_URL=http://localhost:3000cd clientCreate client/.env (optional):
REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_SOCKET_URL=http://localhost:5000# From root directory - starts both server and client
npm run dev
# Or start individually:
# Server only
npm run server
# Client only
npm run client- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- Health Check: http://localhost:5000/health
POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/google- Google OAuth (placeholder)
GET /api/chat/sessions- Get user's chat sessionsPOST /api/chat/sessions- Create new chat sessionGET /api/chat/sessions/:id/messages- Get session messagesPOST /api/chat/sessions/:id/messages- Send messageDELETE /api/chat/sessions/:id- Delete sessionPATCH /api/chat/sessions/:id- Update session title
GET /api/organizations- Get user's organizationsPOST /api/organizations- Create organizationPATCH /api/organizations/:id- Update organizationGET /api/organizations/:id/members- Get membersPOST /api/organizations/:id/invite- Invite memberDELETE /api/organizations/:id/members/:memberId- Remove memberPOST /api/organizations/:id/activate- Set active organization
GET /api/notifications- Get notificationsPATCH /api/notifications/:id/read- Mark as readPATCH /api/notifications/read-all- Mark all as readDELETE /api/notifications/:id- Delete notification
- users - User accounts and authentication
- organizations - Organization entities
- organization_members - User-organization relationships
- user_active_organization - Current active organization per user
- chat_sessions - Chat conversation sessions
- messages - Individual chat messages
- notifications - System and user notifications
- Users can belong to multiple organizations
- Each user has one active organization at a time
- Chat sessions belong to users and organizations
- Messages belong to chat sessions
- Notifications can be global or user-specific
cd client
npm run build
# Deploy the 'build' folder to your hosting service# Set environment variables on your hosting platform
# Deploy the 'server' directoryEnsure all environment variables are set in your production environment:
DATABASE_URL- Production PostgreSQL connection stringJWT_SECRET- Secure random stringOPENAI_API_KEY- Your OpenAI API keyNODE_ENV=productionFRONTEND_URL- Your frontend domain
- User registration and login
- Chat session creation and messaging
- Credit deduction and display
- Organization creation and switching
- Member invitation (database record)
- Real-time notifications
- Responsive design on mobile
Create test accounts to verify multi-user functionality:
- Register multiple users
- Create organizations
- Invite members
- Test real-time features
llm-chat-platform/
βββ client/ # React frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ services/ # API and Socket services
β β βββ store/ # Redux store and slices
β β βββ App.js # Main app component
β βββ package.json
βββ server/ # Node.js backend
β βββ config/ # Database configuration
β βββ middleware/ # Express middleware
β βββ routes/ # API routes
β βββ scripts/ # Database migrations
β βββ socket/ # Socket.IO handlers
β βββ index.js # Server entry point
βββ package.json # Root package.json
- Backend: Add routes in
server/routes/ - Frontend: Create components in
client/src/components/ - State Management: Add Redux slices in
client/src/store/slices/ - Database: Update migration script in
server/scripts/migrate.js
- Use ES6+ features
- Follow React hooks patterns
- Implement proper error handling
- Add loading states for async operations
- Use Material-UI components consistently
# Check PostgreSQL is running
pg_ctl status
# Verify database exists
psql -l | grep llm_chat_platform
# Check connection string in .env- Verify API key is correct
- Check API quota and billing
- Ensure proper error handling for rate limits
- Check CORS configuration
- Verify frontend and backend URLs match
- Check browser console for connection errors
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Clear build cache
rm -rf client/build server/distThis project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For support and questions:
- Create an issue in the GitHub repository
- Check the troubleshooting section above
- Review the API documentation
- Google OAuth implementation
- File upload and sharing
- Voice message support
- Advanced user roles and permissions
- Usage analytics and reporting
- Custom LLM model selection
- Conversation export functionality
- Advanced notification settings
- Mobile app development
- API rate limiting per organization
Built with β€οΈ for the LLM Chat Platform Assignment