No description
  • Python 81.7%
  • HTML 12.6%
  • CSS 3.9%
  • Dockerfile 1.1%
  • Shell 0.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-10 14:43:49 +08:00
app various enhancement to the GUI 2026-08-10 14:43:49 +08:00
docs various enhancement to the GUI 2026-08-10 14:43:49 +08:00
tests various enhancement to the GUI 2026-08-10 14:43:49 +08:00
.dockerignore Added privacy endpoint 2026-08-10 09:17:53 +08:00
.env.example various enhancement to the GUI 2026-08-10 14:43:49 +08:00
.gitignore first commit 2026-08-07 19:19:16 +08:00
automation-plan.md first commit 2026-08-07 19:19:16 +08:00
Caddyfile fix: fuel noise, evidence gate, migration atomicity, docker fail-closed 2026-08-08 11:35:59 +08:00
CHANGELOG.md fix: fuel noise, evidence gate, migration atomicity, docker fail-closed 2026-08-08 11:35:59 +08:00
docker-compose.yml various enhancement to the GUI 2026-08-10 14:43:49 +08:00
Dockerfile Added privacy endpoint 2026-08-10 09:17:53 +08:00
entrypoint.sh fix: fuel noise, evidence gate, migration atomicity, docker fail-closed 2026-08-08 11:35:59 +08:00
litestream.yml Add migration and docker deployment 2026-08-08 10:53:23 +08:00
pyproject.toml first commit 2026-08-07 19:19:16 +08:00
README.md various enhancement to the GUI 2026-08-10 14:43:49 +08:00
SETUP-MESSENGER.md first commit 2026-08-07 19:19:16 +08:00

Messenger Vehicle Automation

Phase 1 implementation for vehicle document OCR and field extraction.

Current Scope

  • Upload a local OR/CR or vehicle document.
  • Run Azure Document Intelligence prebuilt-read OCR.
  • Extract vehicle fields with rule-based matching (new/old CR and OR), with an optional OpenAI-compatible LLM fallback for weak OCR/rule results.
  • Merge OR + CR attachments from one message into a single vehicle record.
  • Save document metadata, OCR JSON, and extracted vehicle data to SQLite.
  • List recent extracted vehicle records.
  • Correct and approve extracted vehicle records through an API endpoint.
  • Serve a public privacy policy at /privacy-policy from editable markdown in docs/PRIVACY_POLICY.md.

Messenger webhooks and emission web app automation are planned for later phases.

Docker Deployment (single VM)

cp .env.example .env   # fill in credentials (Azure, Meta, domain)
docker compose up -d --build
  • app container: uvicorn on :8000, SQLite + uploads in the app-data volume, migrations applied automatically at startup (fresh DB = zero manual steps)
  • caddy container: reverse proxy with automatic HTTPS (Let's Encrypt)
  • Optional Litestream continuous replication of SQLite to S3-compatible storage when LITESTREAM_BUCKET is set in .env

See docs/DEPLOYMENT.md for backups/restore, updates, troubleshooting, and the full environment reference.

Local Development Setup

  1. Create a virtual environment.
python -m venv .venv
source .venv/bin/activate
  1. Install dependencies.

If venv is unavailable on Ubuntu/Debian, install it first:

sudo apt install python3-venv
pip install -e ".[dev]"
  1. Configure environment variables.
cp .env.example .env

Set:

  • AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT
  • AZURE_DOCUMENT_INTELLIGENCE_KEY
  • APP_DATABASE_PATH
  • APP_STORAGE_DIR

The app automatically loads .env from the project root when it starts.

  1. Run the app.
uvicorn app.main:app --reload
  1. Upload a document.

Open http://127.0.0.1:8000/docs and use POST /documents/upload.

  1. Review or approve extracted data.

Use GET /vehicles/recent to list extracted records, then PATCH /vehicles/{vehicle_id}/review to correct fields and mark a record as approved.

  1. Reprocess saved OCR after extractor changes.

Use POST /documents/{document_id}/reprocess to run extraction again from saved OCR without calling Azure again.

  1. Upload multiple documents for one vehicle.

Use POST /documents/upload-batch with multiple files (e.g. OR + CR together). Each image is processed one-by-one, then the extractions are merged and verified into a single vehicle record. Conflicting values between OR and CR force needs_review.

Verification

Run tests:

pytest

Roadmap

See docs/ROADMAP.md: multi-user + SSO via Authentik (next ~2 months), browser automation of the emission web app, full external API automation, and operational polish.