My project is a PDFChat application built using ReactJS Vite Framework, MongoDB for data storage, JWT for user authentication and authorization, and Node.js with Express.js for the backend. It also utilizes various libraries and tools for efficient development, including dotenv for environment variable management, Langchain and its vector store for language processing, Multer for file uploads, and Axios for making requests to the backend. The project is styled with Tailwind CSS and Shadcn Framework for a sleek user interface.
On the back-end, I used Node.js with Express.js for handling requests and MongoDB to store user information and manage user logins. To keep things secure, I used JSON Web Tokens for user authentication, making sure that only authorized users could access certain parts of the project.
For handling PDF files, I used a tool called Multer to store the files and their locations in the database. Then, I processed the uploaded PDFs, breaking them into smaller parts and storing them in a HNSW Vector Store provided by Langchain. This journey expanded my skills and gave me a better understanding of the possibilities offered by advanced technology like Langchain and RAG.
Before running the project, you need to set up environment and configuration variables:
Clone the Repository: Start by cloning this repository to local machine.
Frontend Setup:
npm install to install frontend dependencies.npm run dev to start the frontend.Backend Setup:
npm install to install backend dependencies..env file in the backend directory and set the following variables:
PORT: Port number on server will run.(By default 8080)username: MongoDB Atlas connection username.password: MongoDB Atlas connection password.JWT_SECRET: secret for JWT token generation.OPENAI_API_KEY: OpenAI API key.Database Setup:
Start the Backend:
npm start to start the backend server.Access the Application:
http://localhost:5173 in browser to access the application.http://localhost:8080 or http://localhost:PORT in your terminal to access the backend part application.The project structure is organized into two main directories:
frontend: Contains all the ReactJS code for the frontend with typescript.backend: Contains the Node.js server using Express.js for the backend logic.I have used JWT (JSON web Tokens) for user authentication and authorization. When users register or log in, they receive a token that must be sent with subsequent requests to access authorized routes.
User information is stored in MongoDB, a flexible NoSQL database. User data is securely stored and retrieved as needed for user interactions.
I have used Multer, a middleware for handling file uploads, allowing users to upload files like images or documents. This feature enhances the user experience by supporting multimedia content.
The frontend is designed with a user-friendly interface using Tailwind CSS and the Shadcn Framework. It offers a responsive and visually appealing experience for users.
The backend provides various API endpoints to manage user data, authentication, and file uploads. These endpoints are documented in the code, and you can find more details in the backend's codebase.