๐ Fix My Policy: A Secure Legal Rephraser App with Angular, AWS Lambda, API Gateway & CloudFront


In this blog, we walk through the step-by-step development and deployment of "Fix My Policy," a smart legal rephraser tool. You'll learn how we:
Built the frontend in Angular
Used Docker + Python for the backend
Integrated OpenRouter AI
Deployed via AWS Lambda & API Gateway
Delivered globally via CloudFront
๐ Live Demo: https://d3lvm4sqaobhu9.cloudfront.net/text
This guide is structured as if you were doing it yourself, step by step.
๐ง Step 1: Frontend Development with Angular
๐ Features:
Paste text or upload
.pdf
,.docx
,.txt
filesDisplays result in "Plain English", "Risks", and "Suggestions"
๐งฑ Components:
TextInputComponent
DocumentUploadComponent
Shared
ResultService
for communication
โ Build Angular App:
ng build --configuration production
This outputs to dist/fix-my-policy/
.
๐ง Step 2: Backend with Python + OpenRouter AI
We wrote the backend in Python that:
Accepts text/file via POST
Uses
pdfplumber
,docx
, andcgi
to extract contentSends prompt to OpenRouter AI (e.g., DeepSeek, Mixtral)
Returns AI-generated JSON explanation
๐ณ Dockerfile:
FROM public.ecr.aws/lambda/python:3.10
COPY requirements.txt ./
RUN pip install -r requirements.txt -t .
COPY app.py .
CMD ["app.lambda_handler"]
๐ฆ Build & Push to ECR:
docker build -t fix-my-policy-lambda .
aws ecr create-repository --repository-name fix-my-policy-lambda
aws ecr get-login-password | docker login --username AWS --password-stdin <your-account-id>.dkr.ecr.us-east-1.amazonaws.com
docker tag fix-my-policy-lambda <your-ecr-uri>:latest
docker push <your-ecr-uri>:latest
๐ Step 3: Deploy as AWS Lambda (Docker)
Create a Lambda function from container image
Use the pushed ECR image
๐ Step 4: Expose via API Gateway
Create a REST API using API Gateway
Integrate it with your Lambda function
Enable CORS (POST + OPTIONS)
Test the endpoint using Postman or Angular frontend
๐๏ธ Step 5: Upload Angular App to AWS for Hosting
We used AWS CloudShell to upload our Angular app to S3.
โ In Your Angular Project:
ng build --configuration production
zip -r fix-my-policy.zip ./dist/fix-my-policy/*
โ In AWS CloudShell:
# Upload fix-my-policy.zip using CloudShell UI
unzip fix-my-policy.zip -d fix-my-policy
aws s3 sync fix-my-policy/dist/fix-my-policy/browser/ s3://fix-my-policy-frontend --delete
๐งฑ Setup S3 Bucket:
aws s3api create-bucket --bucket fix-my-policy-frontend --region us-east-1
aws s3 website s3://fix-my-policy-frontend/ --index-document index.html --error-document index.html
aws s3api put-bucket-policy --bucket fix-my-policy-frontend --policy '...'
๐ Step 6: Serve App Globally with CloudFront
We used a script to create a CloudFront distribution that points to our S3 site.
๐ create-cloudfront.sh:
#!/bin/bash
BUCKET_NAME="fix-my-policy-frontend"
REGION="us-east-1"
ORIGIN_DOMAIN="$BUCKET_NAME.s3-website-$REGION.amazonaws.com"
aws cloudfront create-distribution \
--origin-domain-name "$ORIGIN_DOMAIN" \
--default-root-object index.html \
--query "Distribution.{Id:Id, DomainName:DomainName}" \
--output json
โ Run It:
chmod +x create-cloudfront.sh
./create-cloudfront.sh
Get the DomainName
like:
d3lvm4sqaobhu9.cloudfront.net
Visit:
https://d3lvm4sqaobhu9.cloudfront.net/text
โ Final Deployment Checklist
Angular app built
Backend Lambda Dockerized
Lambda deployed to API Gateway
Frontend uploaded via CloudShell
CloudFront created for global HTTPS
๐งพ Conclusion
"Fix My Policy" is a complete cloud-native, serverless app:
Angular for frontend
Python AI backend with Docker
API Gateway + Lambda for logic
S3 + CloudFront for secure delivery
Deployed entirely from the browser using CloudShell
No local AWS CLI or IAM configuration needed.
โ
Enterprise-ready
โ
Secure
โ
Scalable
โ
Fully Serverless
Let us know if you want the full GitHub repo or auto-deploy script!
Subscribe to my newsletter
Read articles from Abhi Nikam directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
