Checkout the Demo of Project at Demo-Link
A full-featured chat assistant built from scratch using the MERN stack, OpenAI API, Material UI, and TypeScript. The application provides a seamless and engaging user experience with features like SignUp, LogIn, View Previous Chats, Chatting Assistance, and the ability to delete conversations.
- Reusable and Modular Components: The frontend is designed using reusable and modular components, ensuring scalability and maintainability.
- React Concepts:
useState(): For managing state within components.context API: For persisting and exchanging data between various components, includingauthContextfor user authentication.useEffect(): To trigger functions based on component lifecycle events.useRef(): To reference input elements directly within the DOM.useLayoutEffect(): To run functions before page rendering occurs.
- API Integration: Utilized
axiosfor making API calls to the backend. - Routing: Implemented routing using
react-router-domfor managing all links and URLs within the application. - Material UI: Used to create a pleasant and user-friendly interface.
- Additional Libraries:
react-icons,react-toast, andreact-type-animation: For an engaging and interactive user interface.
- Authentication:
- JSON Web Tokens (JWT) for secure SignIn and storing http-only cookies for up to 7 days to keep users logged in.
- Cookie operations handled using
cookie-parserlibrary.
- Protected Routes:
- User routes: Signup, login, authentication, logout.
- Chat routes: New chat, retrieve all chats, delete chats.
- Routes secured using
corsandjsonwebtokenlibraries.
- OpenAI Integration:
- Integrated with OpenAI API using
openailibrary for providing chat completion and answering coding queries.
- Integrated with OpenAI API using
- Input Validation:
- Custom and in-built validators using
express-validatorto ensure the integrity of user inputs and chat data.
- Custom and in-built validators using
- Database:
- User schema designed using
mongooseto store user information and conversations in MongoDB.
- User schema designed using
- Express Middlewares:
- Middleware Functionality: Used express middlewares for request processing, authentication checks, error handling, and request validation.
- Error Handling:
- Robust error handling with specified expected response codes, implemented using
try-catchblocks and promises (resolve and reject) for handling asynchronous operations.
- Robust error handling with specified expected response codes, implemented using
- Frontend: React.js, TypeScript, Material UI, axios, react-router-dom
- Backend: Node.js, Express.js, MongoDB, JWT, OpenAI API
- Libraries:
- Frontend:
react-icons,react-toast,react-type-animation - Backend:
cookie-parser,cors,jsonwebtoken,express-validator,mongoose
- Frontend:
- Clone the repository:
git clone https://github.com/deepankkartikey/Coding-Assistant cd your-repo-name - Install dependencies for both frontend and backend:
cd frontend npm install cd ../backend npm install
- Create a
.envfile in thebackenddirectory and add the following environment variables:PORT=<PORT Number to run Backend> FRONTEND_PORT=<PORT on Which Frontend React-app is running> MONGO_URI=<Your MongoDB URI> JWT_SECRET=<Your JWT Secret> OPENAI_API_KEY=<Your OpenAI API Key> COOKIE_SECRET=<Your Cookie Secret> MODEL_NAME=<GPT model you want to use> like gpt-3.5-turbo, gpt-4o-mini, gpt-4o etc.
- Start the development server:
cd backend npm run dev cd ../frontend npm run dev
Checkout the Demo of Project here. Demo-Link
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for providing the chat completion API.
- Material UI for the beautiful UI components.
- The amazing open-source community for the libraries and tools used in this project.