A full-stack AI chatbot application with React frontend and Node.js backend, powered by Tiny Llama (local AI model).
- Modern, responsive chat interface
- Real-time message display
- Auto-scroll to latest messages
- Loading states and error handling
- Enter key support for sending messages
- Beautiful gradient design
- RESTful API endpoints
- CORS enabled for frontend communication
- MongoDB integration for user management (optional)
- Environment variable configuration
- Health check endpoint
MPR/
βββ client/ # React frontend
β βββ src/
β β βββ App.jsx # Main chatbot component
β β βββ index.css # Tailwind CSS
β βββ package.json
β βββ tailwind.config.js
βββ server/ # Node.js backend
β βββ routes/
β β βββ chatbot.js
β βββ models/
β β βββ User.js # User model
β βββ index.js # Main server file
β βββ package.json
βββ package.json # Root package.json for running both
- Node.js (v16 or higher)
- npm or yarn
- MongoDB (optional - for user authentication features)
# Install all dependencies (root, server, and client)
npm run install-allIf you want user authentication features, start MongoDB:
# On macOS with Homebrew
brew services start mongodb-community
# Or start manually
mongodbGROQ_API_KEY='Your API KEY'
Note: The chatbot will work perfectly without MongoDB. Only user registration/login features require MongoDB.
# From the root directory
npm run devThis will start:
- Backend server on
http://localhost:3001 - Frontend development server on
http://localhost:5173
npm run server
# or
cd server && npm startnpm run client
# or
cd client && npm run dev- POST
/chat- Request:
{ message: string } - Response:
{ reply: string }
- Request:
- GET
/health- Check server status- Response: Server status and service availability
- POST
/register- Register new user - POST
/login- User login
- Responsive Design: Works on desktop, tablet, and mobile
- Real-time Chat: Instant message display and responses
- Loading States: Visual feedback during API calls
- Error Handling: User-friendly error messages
- Auto-scroll: Automatically scrolls to latest messages
- Keyboard Support: Enter key to send messages
# Build the frontend
npm run build
# Start production server
npm startsrc/App.jsx- Main chatbot component with all UI logicsrc/index.css- Tailwind CSS configurationtailwind.config.js- Tailwind configuration
index.js- Express server setup and route mountingroutes/chatbot.jsmodels/User.js- MongoDB user model
-
Port 3001 already in use
# Find and kill the process lsof -ti:3001 | xargs kill -9
-
MongoDB connection error
- This is normal if MongoDB isn't running
- The chatbot will still work perfectly
- Only user authentication features require MongoDB
-
Frontend not connecting to backend
- Ensure both servers are running
- Check CORS configuration in server/index.js
- Verify the API URL in client/src/App.jsx
- Use
npm run devto start both servers simultaneously - Check browser console for frontend errors
- Check terminal for backend errors
- Use browser dev tools to inspect network requests
- Use
/healthendpoint to check server status
cd client
npm run build
# Deploy the dist/ folder to your hosting servicecd server
npm start
# Deploy to your preferred hosting service (Heroku, Vercel, etc.)ISC License