Skip to content
CodeWithAdrianJamesPublic

About

SHAKE: Structured Handling and Automated Knowledge Extraction

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

121 Commits

Folders and files

Repository files navigation

Shake Banner

Shake — From Paper to Data

SHAKE: Structured Handling and Automated Knowledge Extraction

Team Shake | Oltek Solutions Corp. Logistics Automation Hackathon 2026

A privacy-first, fully offline pipeline that converts ocean freight contract PDFs into structured, machine-readable data — JSON, Excel, and CSV — reducing manual encoding work.


Problem

Ocean freight contracts from carriers (MSC, CMA CGM, COSCO, etc.) arrive as unstructured PDFs and must be manually re-encoded into Oltek's internal Excel tracking system. This is slow, error-prone, and labour-intensive — especially across multiple contract formats and carriers.

Solution

Upload a PDF → Shake extracts all freight rates and arbitraries and outputs clean, structured files ready for immediate use.

Unlike naive text scrapers, Shake parses the Document Object Model (JSON AST) generated by OpenDataLoader, enabling it to perfectly stitch together tables split across multiple pages and intelligently carry context (like Scope, Origins, and Commodities) down the document.

Shake Pipeline Overview


Key Features

  • Offline-first — no data leaves the machine; NDA-safe by design.
  • JSON-Native AST Extraction — Bypasses messy text parsing by navigating the PDF's structural JSON tree, guaranteeing perfect column alignment.
  • Intelligent Context State Machine — A finite state machine reads the document in order, caching dangling labels, dates, and commodities, and retroactively "stamps" them onto the correct freight tables.
  • Cross-Page Table Stitching — Instantly detects when a table spills onto the next page and seamlessly joins the rows without duplicating headers.
  • Multi-section support — Extracts Rates, Origin Arbitraries, and Destination Arbitraries as isolated, correctly tagged output tables.
  • Batch mode — Process a single file or an entire directory in one command.
  • Unified output schema — One canonical format covers multiple Oltek carrier contract templates.
  • Web API — Lightweight Flask API (shake/frontend/web/) for programmatic access.

Tech Stack

Layer Technology
PDF Conversion & DOM opendataloader_pdf (Java/Hybrid modes generating rich JSON ASTs)
PDF Classification PyMuPDF (fitz)
Extraction Engine Python — JSON AST traversal & Regex State Machine (shake/core/extraction.py)
Data Mapping Python — Dictionary standardisation (shake/core/mapping.py)
Output / Export pandas, openpyxl (Flattened CSVs & Multi-sheet Excel)
Web API Flask (shake/frontend/web/)
Config config.py — single source for all paths, modes, and options

Getting Started

1. Clone the repository

git clone https://github.com/GReturn/Shake.git
cd Shake

2. Set up a virtual environment

python -m venv .venv
# Windows
.venv\Scripts\activate
# Mac/Linux
source .venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

Note: opendataloader_pdf requires Java to be installed and on your system PATH.

4. Run the Web Application (Recommended)

Shake now comes with a React-based web interface for easier use.

  1. Start the backend API:
# In the root project directory:
python -m shake.frontend.web.app
  1. Start the frontend UI:
cd frontend
npm install   # Only needed once
npm run dev
  1. Open your browser to http://localhost:5173 (or the port specified by Vite in your terminal).

5. Run the CLI Pipeline (Alternative)

# Process a single file
python -m shake.frontend.cli input/data/digital/ATL0347N25.pdf

# Process an entire directory (outputs to ./output/ by default)
python -m shake.frontend.cli input/ -o results/

CLI flags:

Flag Short Description
--output DIR -o Output directory (default: ./output)
--quiet -q Suppress the per-file row-count summary table

Project Structure

Shake/
├── shake/                          # Core Package
│   ├── core/                       # Pure Domain Logic (No UI)
│   │   ├── __init__.py
│   │   ├── models.py               # Data classes & enums
│   │   ├── errors.py               # Custom exceptions
│   │   ├── ingestion.py            # PDF → OpenDataLoader JSON AST
│   │   ├── extraction.py           # JSON AST → State Machine Payload
│   │   ├── mapping.py              # Payload → Mapped payload
│   │   └── exporter.py             # Mapped payload → Canonical Pandas Exports 
│   │
│   ├── frontend/                   # Presentation Layers
│   │   ├── cli/                    # Terminal UI (ANSI colors, argparse)
│   │   │   ├── __main__.py
│   │   │   ├── main.py
│   │   │   └── display.py
│   │   └── web/                    # Flask Web API
│   │       └── app.py
│   │
│   └── utils/                      # Shared Helpers
│       ├── logger.py
│       └── patterns.py             # Single source of truth for regex
│
├── input/                          # Sample contract PDFs
│   └── data/digital/
├── config.py                       # Central config (OCR method, output paths, ports)
├── requirements.txt
└── README.md

Team

Name Role
Rafael Technical coordination
Kesha Technical documentation
Jive Lead pipeline development
Gil Frontend development and pitching
Adrian Frontend development

Why This Fits the Hackathon

Oltek's primary bottleneck is the manual transcription of carrier rate data from PDFs into Excel. Shake addresses that problem directly by converting freight contracts into structured outputs offline and deterministically, in a format that aligns with Oltek's existing templates while standardizing data across multiple carrier formats.


Oltek Solutions Corp. — From Paper to Data Hackathon 2026

About

SHAKE: Structured Handling and Automated Knowledge Extraction

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages