A secure, serverless API implementation following Zero Trust Architecture principles for handling confidential files and automated invoice processing. This project demonstrates how to build a secure file handling system with AI-powered invoice processing using AWS Lambda, API Gateway, and Gemini AI, implementing strict security controls and zero-trust principles.
This API provides a secure way to handle confidential files and process invoices with the following key features:
- Secure File Management: Upload, download, and list confidential files with end-to-end encryption
- AI-Powered Invoice Processing: Automated invoice processing using Google's Gemini AI for intelligent data extraction
- Multi-Factor Authentication: Mandatory MFA for all users to ensure secure access
- Zero Trust Security: Every request is verified and authenticated, regardless of its source
- Serverless Architecture: Built on AWS Lambda for scalability and cost-effectiveness
- Email Notifications: Secure email notifications using Resend API for important events
This project implements the following Zero Trust principles:
- Never Trust, Always Verify: Every request is authenticated and authorized, regardless of its origin
- Least Privilege Access: Strict access controls and minimal permissions for all operations
- Micro-segmentation: Isolated functions and resources with strict boundaries
- Encryption Everywhere: Data encryption at rest and in transit
- Defense in Depth: Multiple layers of security controls
The system is built using:
- Serverless Framework for handling deployments and monitoring
- AWS Lambda for serverless compute
- API Gateway for secure API endpoints
- Resend API for sending emails
- Serverless CI/CD pipeline
- End-to-end encryption for file handling
- JWT-based authentication
- Secure file storage with encryption at rest
- MFA enabled mandatory for all users
- Node.js 20.x or later
- AWS CLI configured with appropriate credentials
- Serverless Framework installed globally
- Google Gemini API key for invoice processing
npm install- Set up your AWS credentials
- Configure environment variables in
.envfile - Configure your params on serverless dashboard:
resendApiKey: API key for Resend email servicejwtSecret: Secret key for JWT token generationemailFrom: Email address for sending notificationss3UploadBucketName: Base name for the S3 bucket (will be appended with stage)geminiApiKey: API key for Google's Gemini AI servicegeminiApiURL: URL for Gemini AI API endpoint
- Update the
serverless.ymlwith your specific requirements
Deploy the service using:
serverless deploy --stage dev # or prod, staging, etc.The deployment will create:
- DynamoDB tables for Users and MFA codes
- S3 bucket for file uploads with encryption
- Lambda functions with appropriate IAM roles
- API Gateway endpoints with JWT authorization
The API provides the following secure endpoints:
POST /signup- Register a new userPOST /signin- Authenticate user and initiate MFAPOST /verify-mfa- Verify MFA codePOST /files/get-upload-url- Get presigned URL for file upload (requires authentication)GET /files/list- Get List of files uploaded by the user (requires authentication)GET /files/get-download-url/{fileName}- Get a presigned URL for download the file (requires authentication)
The system automatically processes invoices when they are uploaded to the S3 bucket, using Gemini AI for intelligent data extraction and storage.
- Always use HTTPS for all API calls
- Implement proper authentication for all requests
- Use environment variables for sensitive configuration
- Regularly rotate encryption keys
- Monitor and audit all access attempts
The system uses Serverless Dashboard for comprehensive monitoring and logging:
-
Serverless Dashboard
- Real-time function monitoring
- Performance metrics and insights
- Error tracking and debugging
- Deployment history and rollback capabilities
- Custom metrics and alerts
- Team collaboration features
-
AWS Integration
- CloudWatch Logs for detailed operation logs
- CloudWatch Metrics for performance monitoring
- AWS X-Ray for request tracing
- Custom audit logs for security events
To access the monitoring dashboard:
- Log in to your Serverless Dashboard account
- Navigate to the
zero-trust-confidential-files-apiservice - Use the monitoring section to:
- View real-time function invocations
- Monitor error rates and latencies
- Set up custom alerts
- Track resource usage
- View deployment history
Please read our contributing guidelines before submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.