An AI Chatbot application inspired by ChatGPT, built using the MERN stack and OpenAI API.
This customized chatbot allows users to have conversational interactions with an AI, and all user messages are stored in a database for future retrieval or deletion. The application emphasizes both functionality and security.
- AI-powered chatbot using OpenAI API
- Message storage in MongoDB for future retrieval
- Message deletion feature
- Fully secure with:
- JWT (JSON Web Tokens) for authentication
- HTTP-Only Cookies
- Signed Cookies
- Password encryption for user accounts
- Middleware chains for request validation and security
This application prioritizes security, employing a range of techniques to protect user data and ensure the integrity of the communication, including:
- JWT Authentication: Secure token-based user authentication to protect API endpoints.
- HTTP-Only Cookies: Used to store authentication tokens securely, inaccessible via JavaScript.
- Signed Cookies: Cookies are signed to prevent tampering.
- Password Encryption: Passwords are hashed and salted before being stored.
- Middleware Chains: Predefined middleware chains are used for handling authentication, validation, and other operations.
- Frontend: React (as part of the MERN stack)
- Backend: Node.js with Express
- Database: MongoDB
- Authentication: JWT (JSON Web Tokens), HTTP-Only Cookies, Signed Cookies
- AI: OpenAI API for natural language processing and chatbot interaction
To get the application running locally, follow these steps:
git clone https://github.com/your-repo/mern-chatbot.gitIn both the client and server directories, run the following command:
npm installCreate a .env file in the server directory and include the following:
- JWT_SECRET
- OPENAI_API_KEY
- MONGO_URI
To start both the frontend and backend servers, run:
npm run devThe React frontend will start on http://localhost:3000 and the backend on http://localhost:5000.
Contributions are welcome! If you want to contribute, feel free to fork the repository and submit a pull request.