Skip to content

About

This is an AI-powered chatbot built with the MERN stack and OpenAI API, featuring secure user authentication, message history management, and a responsive user interface.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

47 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

description

This project is a ChatBot application built using the MERN stack (MongoDB, Express.js, React, Node.js) and integrated with the OpenAI API for natural language processing.

Features

  • Natural Language Processing: Utilizes the OpenAI API to understand and respond to user input.
  • User Authentication: Secure user login and registration using JWT tokens and encrypted passwords.
  • Message History: Stores user messages in a database, allowing for message retrieval and deletion.
  • Middleware Chains: Protects routes and handles errors effectively.
  • Responsive UI: A clean and intuitive user interface built with React.

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/MERN-ChatBot.git
    cd MERN-ChatBot
  2. Install dependencies for both the frontend and backend:

    # For the backend
    cd backend
    npm install
    
    # For the frontend
    cd ../frontend
    npm install
  3. Set up the environment variables (see the Environment Variables section below).

  4. Run the application:

    npm run dev
  5. Open your browser:

    • Visit http://localhost:3000 to access the ChatBot application.

Usage

  1. Register or log in to start using the ChatBot.
  2. Interact with the bot by typing messages into the chat interface.
  3. View your chat history or delete messages as needed.

Environment Variables

Create a .env file in the backend directory with the following environment variables:

MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
OPENAI_API_KEY=your_openai_api_key

Technologies Used

  • MongoDB: Database for storing user messages and authentication data.
  • Express.js: Backend framework to handle API requests and middleware.
  • React: Frontend library for building the user interface.
  • Node.js: JavaScript runtime environment for running the server-side code.
  • OpenAI API: Provides natural language processing capabilities.

Project Structure

MERN-ChatBot/
│
├── frontend/            # React frontend code
│   ├── public/          # Static files
│   └── src/             # React components, hooks, and pages
│
├── backend/             # Node.js backend code
│   ├── config/          # Configuration files (e.g., database, JWT)
│   ├── controllers/     # Route controllers
│   ├── models/          # Mongoose models
│   ├── routes/          # Express routes
│   ├── middleware/      # Middleware functions
│   └── utils/           # Utility functions
│
└── README.md            # This file

Security

  • JWT Tokens: Secure authentication with JSON Web Tokens.
  • Password Encryption: User passwords are securely hashed before storing them in the database.
  • HTTP-Only Cookies: Tokens are stored in HTTP-only cookies to prevent XSS attacks.

About

This is an AI-powered chatbot built with the MERN stack and OpenAI API, featuring secure user authentication, message history management, and a responsive user interface.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

⌂ Proxy