A modern web application for detecting Personally Identifiable Information (PII) in CSV files using AWS Bedrock's Titan model.
This application uses a clean separation between backend and frontend:
- Backend: Node.js/Express server with AWS Bedrock integration
- Frontend: React/Next.js with shadcn/ui components
- AI Model: Amazon Titan Text Express v1 via AWS Bedrock for PII classification
PII_detection/
├── backend/
│ ├── app/
│ │ ├── __init__.py
│ │ ├── main.py # FastAPI application
│ │ ├── models.py # Pydantic data models
│ │ └── pii_detector.py # Core PII detection logic
│ ├── data/ # Test CSV files
│ ├── requirements.txt # Python dependencies
│ ├── tests/ # Backend tests
│ └── venv/ # Virtual environment
├── frontend/
│ ├── src/
│ │ ├── app/ # Next.js app directory
│ │ ├── components/ # React components
│ │ └── lib/ # Utility functions
│ ├── package.json # Node.js dependencies
│ └── tailwind.config.ts # Tailwind CSS config
└── CLAUDE.md # Development instructions
-
Navigate to backend directory:
cd backend -
Create and activate virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure AWS credentials (choose one method):
Option A: AWS CLI (Recommended)
aws configure
Option B: Environment Variables
export AWS_ACCESS_KEY_ID=your_access_key export AWS_SECRET_ACCESS_KEY=your_secret_key export AWS_REGION=us-east-1
Option C: AWS Profile
export AWS_PROFILE=your-profile-name -
Start the backend server:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
-
Navigate to frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Start both servers:
- Backend:
http://localhost:8000 - Frontend:
http://localhost:3000
- Backend:
-
Access the web application at
http://localhost:3000 -
Upload a CSV file using the drag-and-drop interface
-
View results showing PII classification for each column with:
- PII detection status
- Confidence scores
- Sample values
- AI reasoning
GET /- Health checkGET /health- Detailed health statusPOST /analyze-csv- Upload and analyze CSV filePOST /analyze-column- Analyze individual column
# Upload CSV for analysis
curl -X POST "http://localhost:8001/analyze-csv" \
-H "Content-Type: multipart/form-data" \
-F "file=@your-file.csv"- AWS Account with Bedrock access
- IAM permissions for Bedrock model invocation
- Bedrock model access to
anthropic.claude-instant-v1 - Regional availability: Ensure Bedrock is available in your selected region
This is a defensive security tool designed to help identify PII in datasets. Key security practices:
- Never commit AWS credentials to version control
- Use IAM roles with minimal required permissions
- Process sensitive data in secure environments
- Review detected PII classifications before taking action
cd backend
source venv/bin/activate
uvicorn app.main:app --reloadcd frontend
npm run dev- Backend: Add new endpoints in
app/main.py - Frontend: Create new components in
src/components/ - UI Components: Use shadcn/ui for consistent styling
cd backend
python -m pytest tests/cd frontend
npm test- Deploy as Docker container or serverless function
- Ensure AWS credentials are configured in production environment
- Build:
npm run build - Deploy to Vercel, Netlify, or static hosting
- AWS Authentication Error: Verify AWS credentials and region
- CORS Issues: Ensure backend allows frontend origin
- Port Conflicts: Change ports in configuration if needed
- Model Access: Verify Bedrock model permissions in AWS console
Check FastAPI logs for detailed error information:
uvicorn app.main:app --log-level debugCheck browser console for frontend errors and network issues.