An AI-powered Salesforce application that predicts U.S. Customs and Border Protection deployment readiness across ports of entry using OpenAI integration.
https://login.salesforce.com/packaging/installPackage.apexp?p0=04tKa000002vzscIAA
The CBP Readiness Platform enables real-time assessment of deployment readiness for Customs and Border Protection across strategic ports of entry. Users interact with an interactive map to trigger AI-powered assessments that predict readiness scores based on location, infrastructure, and strategic factors.
✅ Interactive Map UI - Lightning Web Component with geolocation markers
✅ AI-Powered Assessments - OpenAI GPT-4o-mini integration via secure callouts
✅ Async Processing - Queueable Apex for non-blocking API calls
✅ Real-Time Updates - Client-side polling for status changes
✅ Secure Integration - Named Credentials for API key management
✅ 100% Test Coverage - HttpCalloutMock for comprehensive testing
✅ Robust Error handling - Error item object captures the errors in the org
CBP_Sector__c (Master)
├── Average_Readiness__c (Rollup Summary)
└── Port_of_Entry__c (Detail - Master-Detail)
├── Geopoint__c (Geolocation)
├── Readiness_Score__c (Number)
├── Assessment_Status__c (Picklist)
├── Last_Assessed_Date__c (DateTime)
└── AI_Response_Summary__c (Long Text)
- LWC:
readinessMap- Interactive map with modal dialogs - Apex Controller:
ReadinessController- Handles UI requests - Queueable:
ReadinessQueueable- Async OpenAI callout - Test Class:
ReadinessQueueableTest- 100% code coverage - error Item -
ErrorLog.cls- captures errors in the UI
- Salesforce CLI installed
- Salesforce Scratch Org or Developer Edition
- OpenAI API Key (Get one here)
# Clone and navigate to project
cd cbpreadiness
# Deploy to your org
sf project deploy start --target-org YOUR_ORG_ALIAS
# Or push to scratch org
sf project deploy startSee SETUP_GUIDE.md for detailed Named Credential setup.
Quick steps:
- Setup → Named Credentials → New
- Create External Credential with your OpenAI API key
- Create Named Credential:
OpenAI_NCpointing tohttps://api.openai.com
External Credentials Not working?
- use nameCredentials with custommetadata
- Create Custom Metadata Record - Steps to add your OpenAI API key to the openAiKey Custom Metadata Type
- Verify Legacy Named Credential - Confirms the OpenAI_Legacy Named Credential is properly configured
# Run the sample data script
sf apex run --file scripts/create-sample-data.apex --target-org YOUR_ORG_ALIASThis creates 4 sectors and 14 ports across the United States.
- App Builder → Create/Edit Lightning Page
- Drag
readinessMapcomponent onto page - Save and activate
- Click any port marker on the map
- Click "Assess Readiness"
- Watch real-time status updates
- View AI-generated score and reasoning
# Run all tests
sf apex run test --test-level RunLocalTests --result-format human --code-coverage
# Expected: 100% coverage on all classes- ✅ Named Credentials for secure API management
- ✅ Queueable Apex for async callouts
- ✅ HttpCalloutMock for testability
- ✅ Wire service for reactive data
- ✅ Master-detail with rollup summary
- ✅ Comprehensive error handling
- ✅ Clean separation of concerns
- ✅ Documented with JavaDoc
- ✅ SOLID principles
- ✅ Modern LWC (ES6+)
- Scheduled Apex - Nightly batch assessments
- Historical Tracking - Readiness_Assessment__c child object
- Platform Events - Real-time UI updates
- Dashboard - Charts and KPIs
- Batch Apex - Bulk processing for 1000+ ports
- Custom Metadata - Configurable prompts and thresholds