This is the backend service for Elastiq built using FastAPI. The server runs on port 8000 and utilizes the Cohere API for sentiment analysis.
- Docker
- FastAPI
- Cohere API (for sentiment analysis)
Follow the steps below to build and run the Elastiq backend using Docker.
git clone https://github.com/burrows99/elastiq-backend.git
cd elastiq-backendMake sure you are in the root directory of the project.
docker build -f Dockerfile -t elastiq-backend-docker .To start the container and run the server on port 8000, use the following command:
docker run -d -p 8000:8000 elastiq-backend-dockerOnce the local server is running, you can access it at:
http://localhost:8000Deployed server can be accessed it at:
[https://elastiq-backend.onrender.com/](http://35.226.217.146:8000/classify_review)The Elastiq backend integrates with Cohere to perform sentiment analysis. You can send a POST request to the following endpoint to analyze the sentiment of a text:
POST https://elastiq-backend.onrender.com/classify_reviewRequest Body Example:
{
"review": "This is a very good movie."
}Steps:
- Set the project ID
gcloud config set project natural-oxygen-452115-h7- Enable APIs, if not done already.
gcloud services enable compute.googleapis.com- Add firewall for access to port 8000, if not done already:
gcloud compute firewall-rules create allow-tcp-8000 \
--allow tcp:8000 \
--network default \
--direction INGRESS \
--priority 1000 \
--source-ranges 0.0.0.0/0 \
--target-tags http-server- Create bare metal vm instance:
gcloud compute instances create elastiq-backend-instance \
--zone=us-central1-a \
--machine-type=n1-standard-1 \
--image-family=debian-11 \
--image-project=debian-cloud- Connect to the VM through SSH
gcloud compute ssh elastiq-backend-instance --zone=us-central1-a- Execute the following commands:
sudo apt-get update
sudo apt install git -y
sudo apt-get install -y docker.io- Setup repo
git clone https://github.com/burrows99/elastiq-backend.git
cd elastiq-backend- Build Image
docker build -f Dockerfile -t elastiq-backend-docker .- Run container
docker run -d -p 8000:8000 elastiq-backend-docker- See the external IP from the UI and use http://<EXTERNAL_IP>:8000 to access backend.