- MongoDB Atlas account: A cloud-based MongoDB account for creating the database and managing data.
- Log in to MongoDB Atlas and create a new database named
insurance_pdf_rag
. - Inside this database, create a collection called
default
.
Note: Create a .env file within the backend directory.
MONGODB_URI="mongodb+srv://<REPLACE_USERNAME>:<REPLACE_PASSWORD>@<REPLACE_CLUSTER_NAME>.mongodb.net/<REPLACE_DATABASE_NAME>"
PDF_PATH="/data/pdfs"
PDF_IMAGES="/data/pdf-images"
ARTIFACT_STORE="/data/artifacts"
OPENAI_ACCESS_KEY=<REPLACE_OPENAI_ACCESS_KEY>
TITLE="PDF Search in Insurance with MongoDB Vector Search and Superduper"
ORIGINS=http://localhost:3000
- Create
/artifacts
and/pdf-images
folders withinbackend/data/
Note: Notice that this is the same folders where the
/pdfs
are. You will end up having 3 folders insidebackend/data/
.
- In the
frontend
folder, create a.env.local
file. - Add the URL for the API using the following format:
NEXT_PUBLIC_ASK_THE_PDF_API_URL="http://localhost:8000/querythepdf"
- Navigate to the
backend
folder. - Install dependencies using Poetry by running:
poetry install
- Start the backend server with the following command:
poetry run uvicorn main:app --host 0.0.0.0 --port 8000
The backend will now be accessible at http://localhost:8000, ready to handle API requests for image vector search.
- Navigate to the
frontend
folder. - Install dependencies by running:
npm install
- Start the frontend development server with:
npm run dev
The frontend will now be accessible at http://localhost:3000 by default, providing a user interface to interact with the image vector search demo.
To run the application using Docker, follow these setup steps:
NOTE: If you don’t have make installed, you can install it using
sudo apt install make
orbrew install make
To build the Docker images and start the services, run the following command:
make build
NOTE: Depending on the version of Docker Compose you have installed, you might need to modify the Makefile to use docker-compose (with a hyphen) instead of docker compose (without a hyphen), as the command format can vary between versions.
To stop all running services, use the command:
make stop
To remove all images and containers associated with the application, execute:
make clean
In this guide, we'll deploy a t2.micro instance running Ubuntu Server 24.04 LTS with approximately 20 GB of storage.
- Launch a t2.micro EC2 instance with Ubuntu Server 24.04 LTS from the AWS Console.
NOTE: Ensure that you open port 3000 for the frontend and port 8000 for the backend in your security group settings. Additionally, allow outbound traffic to port 27017, which is the default port for MongoDB.
Once the instance is up and running, SSH into the machine using the following command:
ssh ubuntu@<your-ec2-ip-address>
Before installing any packages, it's good practice to update the package index:
sudo apt update
Install Docker on your EC2 instance by running the following command:
sudo apt install docker.io -y
Verify the installation by checking the Docker version:
docker --version
Download Docker Compose:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Make Docker Compose executable:
sudo chmod +x /usr/local/bin/docker-compose
Check the Docker Compose version:
docker-compose --version
Start the Docker service:
sudo systemctl start docker
Enable Docker to start on boot:
sudo systemctl enable docker