An intelligent AI chatbot application that learns from conversations and can generate personality profiles based on chat history.
- 💬 Free-form Chatting: Chat naturally with an AI assistant powered by OpenAI
- 🧠 Conversation Memory: All conversations are stored and used as context for future interactions
- 👤 Personality Profiling: After a few messages, ask "Who am I?" or "Tell me about myself" to get a personalized personality profile derived from your chat history
- 🔐 Authentication: Secure user authentication with JWT tokens
- 🎨 Modern UI: Clean, responsive interface built with React + Vite, Tailwind CSS, and shadcn/ui components
- Frontend: React + Vite, JavaScript, Tailwind CSS
- Backend: Express.js REST API (separate server)
- Database: PostgreSQL with Prisma ORM (local server)
- AI: OpenAI GPT-4o-mini
- Authentication: JWT with bcrypt
- Testing: Vitest
- Node.js 18+ and npm/yarn
- PostgreSQL database server (local installation)
- OpenAI API key
This project is split into Frontend and Backend:
- Frontend: React + Vite application in the root directory
- Backend: Express.js API server in
/backenddirectory
See SETUP.md for detailed setup instructions.
cd backend
npm installCreate backend/.env:
DATABASE_URL="postgresql://roopansh@localhost:5432/chatbot?schema=public"
OPENAI_API_KEY="your-openai-api-key"
JWT_SECRET="your-secret-key"
PORT=5000
FRONTEND_URL="http://localhost:3000"npm run db:generate
npm run db:push
npm run devBackend runs on http://localhost:5000
# From project root
npm installCreate .env:
VITE_API_URL="http://localhost:5000"npm run devFrontend runs on http://localhost:3000
See SETUP.md for detailed instructions.
For testing purposes, you can:
- Create an account through the sign-up page on the app
- Use the demo user script (for local development):
Or:
npm run create-demo-user
This will create a demo user with:node scripts/create-demo-user.js
- Email:
demo@example.com - Password:
demo123
- Email:
Note: Demo credentials are not hardcoded in the codebase. For production, demo credentials should be provided separately in the submission documentation.
- Sign Up/Login: Create an account or log in with existing credentials
- Start Chatting: Begin a conversation with the AI assistant
- Build Context: Have a few conversations to build up context
- Ask About Yourself: Try asking:
- "Who am I?"
- "Tell me about myself"
- "What do you know about me?"
- "Describe me"
- "What am I like?"
The AI will analyze your conversation history and generate a personality profile!
# Run tests once
npm test
# Run tests in watch mode
npm run test:watchnpm run build
npm start- Push your code to GitHub
- Import your repository in Vercel
- Add environment variables in Vercel dashboard
- Deploy!
- Create a new project on Railway
- Connect your GitHub repository
- Add PostgreSQL service
- Add environment variables
- Deploy!
Make sure to set these in your hosting platform:
DATABASE_URL: Your PostgreSQL connection stringOPENAI_API_KEY: Your OpenAI API keyJWT_SECRET: A strong, random secret key
├── app/
│ ├── api/ # API routes
│ │ ├── auth/ # Authentication endpoints
│ │ ├── chat/ # Chat endpoint
│ │ └── messages/ # Messages retrieval
│ ├── chat/ # Chat page
│ ├── layout.tsx # Root layout
│ └── page.tsx # Login/signup page
├── components/
│ └── ui/ # Reusable UI components
├── lib/ # Utility functions
│ ├── auth.ts # Authentication helpers
│ ├── openai.ts # OpenAI integration
│ ├── personality.ts # Personality profiling
│ └── prisma.ts # Prisma client
├── prisma/
│ └── schema.prisma # Database schema
└── test/ # Test files
All messages are stored in the database with user association, allowing the AI to maintain context across sessions.
When a user asks about themselves, the system:
- Retrieves the last 50 messages from the conversation history
- Sends them to OpenAI with a specialized prompt
- Generates a personality profile based on interests, communication style, preferences, and traits
The AI uses the last 20 messages as context for generating responses, ensuring continuity in conversations.
This project is created for the Middleware assignment.
For questions or issues, please contact the development team.