Spaces:
Paused
title: VGTC Compliance API
emoji: π
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: true
VGTC
AI Trade Compliance Platform
Automate import compliance. From document to audit trail in seconds.
Upload a document or connect your ERP β Get HS codes, sanctions screening, and a compliance report with full audit trail.
The Problem
Import compliance takes 2-4 hours per document. Manual HS code lookups, sanctions checks, duty calculations. One misclassification = millions in penalties.
The Solution
VGTC automates it end-to-end.
| Metric | Manual | VGTC |
|---|---|---|
| Time per document | 2-4 hours | 30 seconds |
| Cost per check | $50-100 | $0.50 |
| Setup time | 6-18 months | 10 minutes |
| HS classification accuracy | ~70% | 75%+ (LLM-backed) |
| Sanctions coverage | Partial | OFAC SDN + EU Consolidated (local, free) |
Live Deployment
| Component | URL | Stack |
|---|---|---|
| Frontend | https://vgtc.voraprotocol.com |
Next.js β Cloudflare Pages |
| Backend API | https://vgtc.onrender.com |
FastAPI β Docker β Render |
| API Docs | https://vgtc.onrender.com/docs |
Swagger UI |
Workflow
1. Upload document / Connect ERP β PDF, SAP S/4HANA, Odoo
2. AI extracts data β Products, quantities, values, origins
3. HS code classification β pyhscodes (6,940+ WCO) + DeepSeek LLM
4. Sanctions screening β OFAC SDN + EU Consolidated (local, public domain)
5. Compliance report β Full audit trail with SHA-256 hash chain
6. Human review β Dashboard with approve/reject workflow
Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Cloudflare Pages β
β vgtc.voraprotocol.com (frontend) β
ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β HTTPS
ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β Render.com (Docker) β
β vgtc.onrender.com (backend) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β FastAPI Server (server.py) β
β βββ POST /api/v1/compliance/check β PDF upload pipeline β
β βββ POST /api/v1/integration/sap/trigger β SAP OData β
β βββ POST /api/v1/integration/odoo/trigger β Odoo JSON-RPC β
β βββ GET /api/v1/dashboard/queue β Review queue β
β βββ POST /api/v1/dashboard/action β Approve/reject β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Core Engines β
β βββ HS Classifier (1,405 lines) β pyhscodes + LLM hybrid β
β βββ Sanctions Engine (1,237 lines) β 8-layer phonetic match β
β βββ PDF Parser (807 lines) β pypdf extraction β
β βββ Dashboard Service (1,720 lines) β PostgreSQL-backed queue β
β βββ ERP Connector (726 lines) β SAP + Odoo integration β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Database: PostgreSQL (Render) β
β βββ compliance_review_items β Review items β
β βββ compliance_audit_chain β SHA-256 hash chain β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Core Engines
HS Code Classifier (hs_classifier.py β 1,405 lines)
Hybrid classification engine with 3-tier caching:
| Tier | Source | Latency | Cost |
|---|---|---|---|
| 1 | In-memory LRU cache (2,048 entries) | ~0ms | Free |
| 2 | PostgreSQL ILIKE fuzzy match | ~5ms | Free |
| 3 | pyhscodes (6,940+ WCO codes) | ~10ms | Free (LGPL-2.1) |
| 4 | LLM (DeepSeek V4 Flash via OpenCode) | ~30-70s | Free tier |
Enterprise features:
classify_batch()β async batch classification withasyncio.Semaphore(5)concurrency control- Cross-validation between pyhscodes and LLM (LLM wins when confidence gap > 15%)
- Automatic dot/dash normalization in LLM responses
- Markdown code block stripping for raw LLM output
- Human review flagging for ambiguous terms
Supported LLM providers: DeepSeek, Qwen, OpenAI, Anthropic, Google Gemini
Sanctions Engine (sanctions.py β 1,237 lines)
8-layer phonetic matching engine β no external API dependency:
| Layer | Method | Purpose |
|---|---|---|
| 1 | Exact match | Perfect match |
| 2 | Normalized exact | Case/punctuation insensitive |
| 3 | Token sort | Word order variation |
| 4 | Partial match | Substring containment |
| 5 | Phonetic (Soundex) | Homophone matching |
| 6 | Phonetic (Metaphone) | Sound-alike matching |
| 7 | Levenshtein distance | Fuzzy spelling |
| 8 | Jaro-Winkler | Similarity scoring |
Data sources: OFAC SDN CSV + EU Consolidated XML (public domain, auto-downloaded)
ERP Integration (erp_connector.py β 726 lines)
| ERP | Adapter | Lines | Protocol |
|---|---|---|---|
| SAP S/4HANA | sap_adapter.py |
891 | OData v2 |
| Odoo | odoo_adapter.py |
832 | JSON-RPC |
Pipeline flow: ERP β line items β async batch HS classification β sanctions screening β PostgreSQL persistence (ComplianceReviewItem + AuditChain)
Mock mode: Automatic when ERP credentials are missing β returns realistic sample data.
Dashboard Service (dashboard.py β 1,720 lines)
PostgreSQL-backed review queue with:
- Tenant isolation (X-Tenant-ID header)
- Optimistic locking for concurrent updates
- SHA-256 hash chain audit trail
- In-memory fallback when database is unavailable
Quick Start
# Clone
git clone https://github.com/mysterious75/VGTC.git
cd VGTC
# Install
pip install -e .
# Run demo (uses DeepSeek LLM β requires API key in .env)
python demo.py
# Run with your PDF
python demo.py --file your_invoice.pdf
Configuration (.env)
# LLM β DeepSeek V4 Flash via OpenCode (free tier)
MODEL_PROVIDER=opencode
MODEL_API_KEY=sk-...
MODEL_NAME=deepseek-v4-flash
MODEL_BASE_URL=https://opencode.ai/zen/go/v1
# Database (Render PostgreSQL)
DATABASE_URL=postgresql+asyncpg://...
# Security
SECURITY_API_KEY=vgk_...
SECURITY_SECRET_KEY=...
Tech Stack
| Layer | Technology |
|---|---|
| Language | Python 3.11+ |
| API Framework | FastAPI |
| HS Classification | pyhscodes (LGPL-2.1) + DeepSeek LLM |
| Phonetics | jellyfish (BSD-3) |
| PDF Parsing | pypdf (BSD-3) |
| Sanctions Data | OFAC SDN CSV + EU Consolidated XML |
| Database | PostgreSQL (SQLAlchemy async) |
| Frontend | Next.js 14 (Cloudflare Pages) |
| Backend Hosting | Docker β Render.com |
| DNS | Cloudflare |
| CI/CD | GitHub Actions |
| ERP Adapters | SAP S/4HANA (OData) + Odoo (JSON-RPC) |
Project Structure
VGTC/
βββ demo.py # One-command demo
βββ src/hermes/
β βββ tools/
β β βββ hs_classifier.py # HS code classification (1,405 lines)
β β βββ sanctions.py # Sanctions screening (1,237 lines)
β β βββ pdf_parser.py # PDF extraction (807 lines)
β β βββ dashboard.py # Review queue (1,720 lines)
β β βββ erp_connector.py # SAP/Odoo bridge (726 lines)
β β βββ sanctions_scheduler.py # 24h auto-refresh (197 lines)
β β βββ __init__.py # CompliancePipeline orchestrator
β βββ api/
β β βββ server.py # FastAPI server (1,114 lines)
β β βββ routers/ # API route modules
β βββ database/
β β βββ models.py # SQLAlchemy models (177 lines)
β β βββ connection.py # DB connection manager
β βββ config/
β β βββ settings.py # Pydantic settings
β βββ compliance/
β β βββ eu_ai_act.py # EU AI Act compliance
β β βββ gdpr.py # GDPR compliance
β βββ core/
β βββ auth.py # Authentication
β βββ exceptions.py # Exception hierarchy
βββ mcp-servers/
β βββ erp-gateway/
β β βββ sap_adapter.py # SAP S/4HANA adapter (891 lines)
β β βββ odoo_adapter.py # Odoo adapter (832 lines)
β β βββ models.py # Shared Pydantic models
β β βββ server.py # MCP server
β βββ government-portal/ # German gov integration
β βββ trade-solutions/ # Customs & logistics
βββ tests/ # 175 tests
β βββ test_hs_classifier.py # 37 tests
β βββ test_sanctions.py # 26 tests
β βββ test_pdf_parser.py # 33 tests
β βββ test_dashboard.py # 31 tests
β βββ test_sanctions_scheduler.py # 14 tests
β βββ test_erp_integrations.py # 34 tests
βββ frontend-nextjs/ # Next.js 14 frontend
βββ Dockerfile.vgtc # Multi-stage Docker build
βββ .github/workflows/
β βββ keep-alive.yml # Render keep-alive (every 25 min)
βββ docs/
βββ DEPLOYMENT_CLOUDFLARE_PAGES.md
βββ DEPLOYMENT_BACKEND_DOCKER.md
API Endpoints
| Method | Path | Description | Auth |
|---|---|---|---|
POST |
/api/v1/compliance/check |
Full pipeline (PDF β classify β screen) | Bearer + Tenant |
POST |
/api/v1/integration/sap/trigger |
SAP order β compliance check | Bearer + Tenant |
POST |
/api/v1/integration/odoo/trigger |
Odoo invoice β compliance check | Bearer + Tenant |
GET |
/api/v1/dashboard/queue |
Review queue (paginated) | Bearer + Tenant |
POST |
/api/v1/dashboard/action/{item_id} |
Approve/reject/request_info | Bearer + Tenant |
GET |
/docs |
Swagger UI | None |
GET |
/health |
Health check | None |
Data Sources
| Source | Coverage | License | Cost |
|---|---|---|---|
| OFAC SDN | US Specially Designated Nationals | Public Domain | Free |
| EU Consolidated | EU Sanctions List | Open Data | Free |
| pyhscodes | 6,940+ WCO HS Codes | LGPL-2.1 | Free |
| UK HMT OFSI | UK Sanctions | Open Government | Free |
| UNSC | UN Security Council | UN Open Data | Free |
Note: OpenSanctions (CC BY-NC) is NOT used β commercial use requires paid license ($3,000+/year). All sanctions data is sourced directly from government databases (public domain).
Development
# Run tests
python -m pytest tests/ -x -q
# Run specific engine tests
python -m pytest tests/test_hs_classifier.py -x -q
python -m pytest tests/test_sanctions.py -x -q
python -m pytest tests/test_erp_integrations.py -x -q
# Start dev server
uvicorn hermes.api.server:server --reload --port 8000
Deployment
Backend (Render):
docker build -f Dockerfile.vgtc -t vgtc .
docker run -p 8000:8000 vgtc
- Auto-deployed from
mainbranch - Keep-alive via GitHub Actions (every 25 min)
- Auto-SSL, 512 MB RAM, shared CPU
Frontend (Cloudflare Pages):
- Static HTML from
frontend-nextjs/out/ - Custom domain:
vgtc.voraprotocol.com - Global CDN, DDoS protection
Roadmap
- HS code classification (pyhscodes + LLM)
- Sanctions screening (OFAC + EU local engine)
- PDF parsing (pypdf, AGPL-free)
- FastAPI server with auth
- Compliance dashboard (PostgreSQL-backed)
- SAP S/4HANA integration
- Odoo integration
- Async batch classification (Semaphore-5)
- Semantic caching (memory + DB)
- SHA-256 audit trail
- Docker deployment
- Cloudflare Pages frontend
- Render.com backend
- 175 tests passing
- PDF report generation
- EU TARIC live duty rates
- Multi-language support
- Webhook notifications
- SSO / SAML integration
License
Source Available License
Code is visible for review. Commercial use requires written permission.
Built by Ved Kumar β’ vedkumar755@gmail.com