Skip to content

tactspace/freight-brain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FreightBrain 🧠

FreightBrain automates shipment tracking and document processing using AI agents.

Overview

FreightBrain consists of two main components:

  1. Backend: FastAPI backend, Browser-use agent, OCR, self-learning agent
  2. Frontend: Next.js, Tailwind CSS, Typescript
  3. Datastores: Weaviate, MongoDB

MVP

  • 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

System Architecture

Blank diagram - Page 1 (1)

Data Sources

FreightBrain utilizes multiple data sources:

  1. Uploaded BOL Documents: PDF files containing shipment details
  2. Carrier Websites: Including Maersk, MSC, COSCO, Evergreen, Hapag-Lloyd, ONE, and more
  3. Agent Activity Logs and Agent Knowledge store: Event logs data from previous tracking attempts

OCR Processing

The system employs a sophisticated approach to document processing:

  1. OCR:

    • Textual PDFs parsed using PDFMiner
    • OCR using OpenAI Vision API for messy visual documents
  2. Document Parsing:

    • Identifies key fields in shipping documents
    • Extracts structured data into standard format

Shipment Tracking Agent

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

Learning Agent

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

Self-Learning Workflow

FreightBrain implements a sophisticated self-learning loop:

  1. Agent Execution: The Shipment Tracking Agent attempts to retrieve shipment information, this agent runs a cron job every 10 mins.
  2. Log Generation: Logs of all agent actions are stored in MongoDB
  3. Learning: The Learning Agent collects these logs to identify mistakes
  4. Prompt Updates: The Learning Agent updates the Shipment Tracking Agent's instructions
  5. Improved Performance: Subsequent tracking attempts (every 10 mins) benefit from previous learnings

Getting Started

  1. Clone the repository
  2. Set up environment variables (API keys, MongoDB connection)
  3. Install dependencies for backend and frontend
  4. This project uses uv as the default package manager. Setup your environment and run the backend server with cd backend && uv run main.py
  5. Run the frontend with cd frontend && npm run dev
  6. Access the web interface at http://localhost:3000

Tech used to qualify

  • Weaviate
  • Aikido (1 medium, 1 low issues so far)
  • OPENAI API

Aikido Score

image

About

🧠

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors