FreightBrain automates shipment tracking and document processing using AI agents.
FreightBrain consists of two main components:
- Backend: FastAPI backend, Browser-use agent, OCR, self-learning agent
- Frontend: Next.js, Tailwind CSS, Typescript
- Datastores: Weaviate, MongoDB
- Automated Document Processing: Extract shipment details from Bill of Lading (BOL) documents using advanced OCR
- Real-time Shipment Tracking: Autonomously track shipments across multiple carrier websites
- Self-learning Agents: Continuously improve performance through a feedback loop
- Web Interface: User-friendly dashboard for managing shipments and viewing updates
FreightBrain utilizes multiple data sources:
- Uploaded BOL Documents: PDF files containing shipment details
- Carrier Websites: Including Maersk, MSC, COSCO, Evergreen, Hapag-Lloyd, ONE, and more
- Agent Activity Logs and Agent Knowledge store: Event logs data from previous tracking attempts
The system employs a sophisticated approach to document processing:
-
OCR:
- Textual PDFs parsed using PDFMiner
- OCR using OpenAI Vision API for messy visual documents
-
Document Parsing:
- Identifies key fields in shipping documents
- Extracts structured data into standard format
The Shipment Tracking Agent is responsible for:
- Scraping the right carrier websites based on tracking ID
- Handling cookies, captchas, and website navigation
- Extracting real-time shipment status, ETA, ETD, origin, destination
- Automatically retries with different websites if information isn't found
The Learning Agent continuously improves system performance through:
- Event Log: Processes past agent logs to identify mistakes/correct decisions
- Strategy: Determines which websites lead to success
- Prompt Updates: Updates the Shipment Tracking Agent's prompts based on learnings
FreightBrain implements a sophisticated self-learning loop:
- Agent Execution: The Shipment Tracking Agent attempts to retrieve shipment information, this agent runs a cron job every 10 mins.
- Log Generation: Logs of all agent actions are stored in MongoDB
- Learning: The Learning Agent collects these logs to identify mistakes
- Prompt Updates: The Learning Agent updates the Shipment Tracking Agent's instructions
- Improved Performance: Subsequent tracking attempts (every 10 mins) benefit from previous learnings
- Clone the repository
- Set up environment variables (API keys, MongoDB connection)
- Install dependencies for backend and frontend
- This project uses
uvas the default package manager. Setup your environment and run the backend server withcd backend && uv run main.py - Run the frontend with
cd frontend && npm run dev - Access the web interface at http://localhost:3000
- Weaviate
- Aikido (1 medium, 1 low issues so far)
- OPENAI API