A modular, multi-agent system designed for small B2B import clearance operations. The system automates document processing, compliance verification, and shipment coordination through specialized AI agents.
- Overview
- System Architecture
- Agents
- Project Structure
- Tech Stack
- Installation
- Usage
- Development
- API Reference
- Future Enhancements
Importance is a custom clearance automation system that helps small B2B import businesses streamline their customs clearance processes. The system uses specialized AI agents to:
- Process intake - Extract and validate information from invoices and shipping documents
- Generate documentation - Create required government forms (CBP7501, etc.) with accurate data
- Supervise and verify - Review all processed shipments and trigger final actions
- Small to medium-sized import businesses
- Customs brokers with moderate volume
- Companies handling repetitive import documentation
┌─────────────────────────────────────────────────────────────────────┐
│ Import Clearance System │
└─────────────────────────────────────────────────────────────────────┘
│
┌───────────────────────────┼───────────────────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Agent 1: │ │ Agent 2: │ │ Agent 3: │
│ Intake │ │ Expert │ │ Supervisor │
│ │ │ │ │ │
│ - Invoice │ │ - Generate CBP │ │ - Verify data │
│ parsing │ │ 7501 forms │ │ - Check │
│ - Document │ │ - Create Python │ │ compliance │
│ validation │ │ scripts │ │ - Process ship. │
│ - Data │ │ │ │ - Human │
│ extraction │ │ │ │ trigger │
└──────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
└───────────────────────────┼───────────────────────────┘
▼
┌──────────────────┐
│ Shared Memory │
│ & Context │
└──────────────────┘
Purpose: Process incoming import documents and extract relevant data.
Capabilities:
- Invoice parsing (PDF, image, text)
- Document validation and verification
- Data extraction and normalization
- Initial quality checks
Input Types:
- Commercial invoices
- Packing lists
- Bills of lading
- Phosphates and chemical documentation
Output:
- Structured JSON data
- Validation reports
- Data quality scores
Tools:
- OCR for image-based documents
- PDF parsing libraries
- Data validation rules
Purpose: Generate accurate government and compliance documentation.
Capabilities:
- Generate CBP Form 7501 (Customs Entry Summary)
- Create other required import documents
- Python script generation for document population
- Format compliance verification
Output Forms:
- CBP 7501 (Entry Summary)
- CBP 3461 (Bill of Lading)
- ISF (Import Security Filing) data
- ACE (Automated Commercial Environment) submissions
Technical Implementation:
- Python scripts that populate PDF templates
- PDF manipulation using PyPDF2, reportlab
- JSON-to-document mapping
Purpose: Verify processed shipments and trigger final actions.
Capabilities:
- Cross-reference Agent 1 and Agent 2 outputs
- Compliance verification
- Decision-making on shipment release
- Human notification and approval workflow
Verification Checks:
- Data consistency across documents
- Compliance with regulations
- Error detection and resolution
- Final approval workflow
importance/
├── src/
│ ├── agents/
│ │ ├── intake.py # Agent 1: Intake processor
│ │ ├── expert.py # Agent 2: Documentation expert
│ │ └── supervisor.py # Agent 3: Supervisor
│ ├── documents/
│ │ ├── parser.py # Document parsing utilities
│ │ ├── formatter.py # Document formatting
│ │ └── templates/ # Form templates
│ │ ├── cbp7501.json
│ │ └── cbp7501.pdf
│ ├── core/
│ │ ├── agent.py # Base agent class
│ │ ├── memory.py # Shared memory system
│ │ └── context.py # Context management
│ └── utils/
│ ├── logging.py
│ └── validators.py
├── tests/
│ ├── test_agents.py
│ ├── test_documents.py
│ └── test_integration.py
├── examples/
│ ├── sample_invoice.pdf
│ └── workflow_example.py
├── requirements.txt
├── README.md
└── LICENSE
- Python 3.10+ - Main implementation language
- PyPDF2 - PDF manipulation
- PyMuPDF (fitz) - Advanced PDF processing
- pdfplumber - PDF text extraction
- OpenCV - Image processing for OCR
- pytesseract - OCR capabilities
- requests - API communication
- pydantic - Data validation
- logging - System logging
- LangChain - Agent orchestration
- Redis - Shared memory/cache
- FastAPI - Web interface
- React - Frontend dashboard
- Python 3.10 or higher
- pip package manager
- Adobe Acrobat (optional, for advanced PDF features)
- Clone the repository:
git clone https://github.com/yourusername/importance.git
cd importance- Create a virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows- Install dependencies:
pip install -r requirements.txt- Configure environment variables:
cp .env.example .env
# Edit .env with your configuration- Run the system:
python -m src.agents.intake- Agent 1 - Intake:
from src.agents.intake import IntakeAgent
agent = IntakeAgent()
result = agent.process_document("invoice.pdf")
print(result.data) # Extracted data
print(result.validation) # Validation report- Agent 2 - Expert:
from src.agents.expert import ExpertAgent
agent = ExpertAgent()
cbp_form = agent.generate_cbp7501(intake_data)
print(cbp_form.json()) # Generated form data- Agent 3 - Supervisor:
from src.agents.supervisor import SupervisorAgent
agent = SupervisorAgent()
verification = agent.verify_shipment(expert_output)
print(verification.status) # "approved" or "requires_review"from src.agents.intake import IntakeAgent
from src.agents.expert import ExpertAgent
from src.agents.supervisor import SupervisorAgent
# Process invoice
intake = IntakeAgent()
invoice_data = intake.process_document("commercial_invoice.pdf")
# Generate CBP form
expert = ExpertAgent()
cbp_form = expert.generate_cbp7501(invoice_data)
# Supervisor verification
supervisor = SupervisorAgent()
result = supervisor.verify_shipment(cbp_form)
if result.status == "approved":
print("Shipment cleared for import")
else:
print(f"Requires review: {result.remarks}")pytest tests/# Linting
flake8 src/
# Type checking
mypy src/- Create agent file in
src/agents/ - Inherit from
src/core/agent.py - Implement
process()method - Add to agent registry
process_document(file_path)- Process document and extract datavalidate_data(data)- Validate extracted datanormalize_data(data)- Normalize data to standard format
generate_cbp7501(data)- Generate CBP Form 7501create_python_script(template, data)- Create population scriptvalidate_form(form)- Verify form completeness
verify_shipment(expert_output)- Verify processed shipmenttrigger_human_review(data)- Request human reviewprocess_shipment(data)- Final shipment processing
-
Additional Agents:
- Agent 4: Compliance researcher (regulation lookup)
- Agent 5: Communication liaison (customs broker interaction)
-
Web Interface:
- Upload portal
- Document tracking
- Status dashboard
-
Integrations:
- ACE (Automated Commercial Environment)
- USDA APHIS systems
- FDA entry systems
-
Machine Learning:
- Invoice template learning
- Error pattern detection
- Process optimization
-
Cloud Deployment:
- AWS/GCP deployment packages
- Serverless functions for agents
- Managed queues for workload distribution
MIT License - See LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request