PACAT is a Retrieval-Augmented Generation (RAG) platform that allows you to create and manage AI "agents" and chat with them. The application consists of two main components:
- Frontend: React-based web interface (GitHub Repository)
- Backend: Python API service (GitHub Repository)
- Frontend: Deployed on AWS Amplify.
- Backend: Deployed on an EC2 instance running Docker.
- Infrastructure: Managed with Terraform
- Custom AMI: Built with HashiCorp Packer, includes Docker pre-installed.
If you prefer to deploy the RAG platform using Docker for local development or testing, please refer to the Docker Deployment Guide.
After deploying the platform, you can connect it to external AI models (LLMs and embedding models) such as OpenAI, Anthropic Claude, local models via Ollama, or any OpenAI-compatible API. See the External Models Configuration Guide for detailed instructions.
Before deploying the application, ensure you have the following tools installed and configured:
Install Terraform for infrastructure as code management:
- Installation Guide
- Verify installation:
terraform --version
Install Packer for building custom AMIs:
- Installation Guide: https://developer.hashicorp.com/packer/tutorials/docker-get-started/get-started-install-cli
- Verify installation:
packer --version
Install and configure the AWS CLI:
After installing AWS CLI, configure it with your AWS credentials:
aws configureYou'll need to provide:
- AWS Access Key ID
- AWS Secret Access Key
- Default region (e.g.,
us-east-1) - Default output format (e.g.,
json)
Verify AWS authentication:
aws sts get-caller-identity- Navigate to the frontend repository: https://github.com/CLOUDLAB-URV/aina-frontend
- Click the Fork button in the top-right corner
- Select your GitHub account as the destination
- Wait for the fork to complete
AWS Amplify needs a GitHub personal access token to authenticate and access your forked repository.
- Follow the official AWS guide to create a token: Setting up GitHub access for AWS Amplify
- Quick Steps:
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click "Generate new token (classic)"
- Give it a descriptive name (e.g., "AWS Amplify AINA")
- Select the following scopes:
repo(Full control of private repositories)admin:repo_hook(Full control of repository hooks)
- Click "Generate token"
- Important: Copy the token immediately - you won't be able to see it again!
- Open the
terraform.tfvarsfile in this directory - Update the
repository_urlto point to your forked repository:repository_url = "https://github.com/YOUR-GITHUB-USERNAME/aina-frontend.git"
-
Navigate to the terraform directory:
cd terraform -
Initialize Terraform (downloads required providers and modules):
terraform init
-
(Optional) Preview the infrastructure changes:
terraform plan
-
Apply the Terraform configuration to create the infrastructure:
terraform apply
-
Terraform will prompt you for the following variables:
access_token: The GitHub personal access token you created in Step 2admin_password: Password for the admin useragent_creator_password: Password for the agent creator userchatuser_password: Password for the chat user
-
Review the planned changes and type
yesto confirm -
Wait for Terraform to complete (this may take several minutes)
-
Save the outputs: Terraform will display important information like:
- EC2 instance public IP
- Amplify app URL
The frontend needs to be manually deployed for the first time:
-
Navigate to AWS Amplify Console:
- Open the AWS Console: https://console.aws.amazon.com/amplify/
- Make sure you're in the correct region (default:
us-east-1)
-
Find Your App:
- Click on the newly created app named
aina-frontend
- Click on the newly created app named
-
Deploy the Main Branch:
- In the app dashboard, you'll see the
mainbranch listed - Click on the
mainbranch - Click the "Run job" button to start the deployment
- In the app dashboard, you'll see the
-
Monitor the Deployment:
- Watch the build progress through the following stages:
- Provision
- Build
- Deploy
- Verify
- The entire process typically takes several minutes
- Watch the build progress through the following stages:
-
Verify Deployment:
- Once completed, the status should show "Deployed"
- The Amplify app URL will be displayed (format:
https://main.xxxxx.amplifyapp.com)
-
Get the Frontend URL:
- You can find it in the Terraform outputs as
amplify_app_url - Or copy it from the Amplify Console
- You can find it in the Terraform outputs as
-
Open the Web Application:
- Click on "Visit deployed URL" in the Amplify Console
- Or navigate directly to the URL in your browser
-
Login: Use one of the following usernames with the passwords you set during deployment:
- Username:
admin(full administrative access) - Username:
agentcreator(can create and manage agents) - Username:
chatuser(can chat with agents)
- Username:
The backend is automatically deployed on the EC2 instance. You can find the public IP in the Terraform outputs:
terraform output spot_instance_public_ipThe backend API is accessible at: http://<EC2_PUBLIC_IP>:8000
If you configured an SSH key in the terraform.tfvars file, you can SSH into the instance:
ssh -i /path/to/your/key.pem ubuntu@<EC2_PUBLIC_IP>To destroy all resources and avoid ongoing AWS charges:
terraform destroyType yes when prompted to confirm.
Note: This will permanently delete all resources including the EC2 instance, VPC, and Amplify app.
- Verify AWS credentials are correctly configured:
aws sts get-caller-identity - Check you have sufficient AWS permissions
- Ensure your AWS region supports the instance type (default:
c8i.xlarge)
- Verify the GitHub personal access token has the correct permissions
- Check that the repository URL in
terraform.tfvarsis correct - Ensure the repository is accessible (public or token has access)
- Check security groups allow inbound traffic on required ports
- Verify the EC2 instance is running:
aws ec2 describe-instances - Check Amplify deployment status in the AWS Console
SSH into the EC2 instance and check Docker status:
ssh ubuntu@<EC2_PUBLIC_IP>
sudo docker ps
sudo docker logs <container_id>- VPC CIDR:
10.0.0.0/16(configurable) - Public subnet with Internet Gateway
- Security groups for controlled access
- Instance type:
c8i.xlarge(configurable) - Custom Ubuntu 24.04 AMI with Docker pre-installed
- Automatic Docker container startup via user data