Skip to content

zerogravityengineering/TeamGenesisCoreTapSureMVP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TapSure — Agentic Insurance MVP

Team Genesis Core — A production-grade, event-driven multi-agent insurance platform built to revolutionize how merchants and consumers interact with instant coverage.

Upload a receipt. Get intelligent coverage recommendations in milliseconds. Confirm protection. Repeat.

Designed and architected by Zebbediah Winston Beck — CEO/Founder/Chief Software Architect at Zero Gravity Engineering (Pty) Ltd

Technology Stack

  • Backend: FastAPI + composable agent modules (OpenAI-compatible LLM optional, graceful heuristic fallbacks)
  • Frontend: Mobile-first vanilla HTML/CSS/JS + Tesseract.js OCR
  • Architecture: Event-driven orchestrator pattern with pluggable agents (ReceiptAnalyzer, CoverageRecommender, ConversationalAgent)

Quick start

  1. Backend
  • Create a virtual env
    • Windows (PowerShell) python -m venv .venv .venv\Scripts\Activate.ps1
  • Install deps pip install -r backend/requirements.txt
  • Configure env copy backend/.env.example backend/.env

    set OPENAI_API_KEY if you want AI OCR/LLM; otherwise fallback heuristics run

  • Run API uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
  1. Frontend
  • Open frontend/index.html in a browser, or serve statically (e.g., python -m http.server 5173 -d frontend)
  • By default it calls http://localhost:8000

Key endpoints

  • POST /api/receipt/analyze (multipart file: receipt)
  • POST /api/coverage/recommend (JSON receipt payload)
  • POST /api/flow/confirm (JSON selection)
  • POST /api/chat (JSON {message})

POS-ready automation roadmap (color-coded todo)

Legend:

  • P0 = required to be a reliable POS automation product
  • P1 = strongly recommended for adoption + ops
  • P2 = good polish / later

Product wedge (stop being “generic insurance”)

  • P0 Pick 1–2 POS use-cases (e.g., receipt-based protection / reimbursement) and remove everything else from the happy path.
  • P0 Define the decision output contract: approve / deny / needs-more-info, with explicit reasons and required evidence.
  • P1 Add a “human handoff” lane (merchant support / insurer ops) instead of pretending 100% can be automated.

POS ingestion (how merchants actually feed you data)

  • P0 Add a POS webhook/API ingestion route (digital receipt payload) alongside image upload.
  • P0 Support idempotency keys + retries (POS systems will resend events).
  • P0 Normalize receipt line items (SKU/UPC, category, quantity, price, tax, merchant id, timestamp).
  • P1 Build “adapters” per POS/provider (keep core logic provider-agnostic).

Pricing + coverage engine (cost-effective + explainable)

  • P0 Make coverage recommendation deterministic-first with transparent formulas + rule traces (LLM only for parsing ambiguous text).
  • P0 Add hard constraints: max item value, excluded categories, jurisdiction flags, waiting periods.
  • P1 Add configurable rule tables per insurer/merchant program (multi-tenant config, not code changes).
  • P2 Add a calibration harness with golden receipts + expected outputs (regression safety).

Automation workflow (end-to-end, not a demo)

  • P0 Introduce a first-class Case model: intake → extracted data → decision → policy/confirmation → audit.
  • P0 Persist cases (SQLite/Postgres) and make the flow resumable.
  • P1 Add outbound webhooks for: decision ready, policy issued, exception required.

Security, privacy, and trust (table stakes for insurers)

  • P0 Replace promo-code gating with real auth (merchant API keys / OAuth) + tenant isolation.
  • P0 Rate limiting + upload limits + content-type validation + malware scanning strategy.
  • P0 PII handling: redaction support, retention policy, deletion endpoint, minimal logging of sensitive fields.
  • P1 Add an audit log: who/what/when for every decision and data mutation.

Reliability & ops (so it doesn’t die at checkout)

  • P0 Add async processing for OCR/LLM (queue) so POS calls stay fast (<500ms) and results arrive via webhook/poll.
  • P1 Add structured logging + request IDs + metrics (latency, error rate, cost per case).
  • P1 Add cost controls: LLM call budget per case, caching, and “LLM-off mode” parity tests.

Integration deliverables (what partners expect)

  • P0 Publish an integration spec: webhook schemas, auth, retries, idempotency, status codes.
  • P1 Provide a reference POS “button” flow: offer → accept → pay → policy issuance.
  • P2 Add SDK snippets (JS/Python) + Postman collection for partners.

Notes

  • OpenAI is optional. You can run 100% free using:
    • OCR: Tesseract (open-source)
    • LLM: Ollama local models (OpenAI-compatible API)
  • This is an MVP for rapid iteration and can be swapped to LangGraph/Temporal later.

Serverless frontend-only mode (no Python, no Ollama)

  • Just run a static server; OCR and parsing happen entirely in the browser using Tesseract.js.
    npx serve frontend -l 5173
    
  • When the API isn’t reachable, the UI auto-switches to local OCR + local recommendation.
  • To re-enable the real backend later, start the API and refresh the page.

Free setup (no paid APIs)

  1. Install Tesseract OCR (Windows):
  2. Install Ollama and pull a model:
    • https://ollama.com/download
    • Run in a terminal: ollama pull llama3.1:8b
    • (Optional) For vision models use: ollama pull llama3.2-vision:11b
  3. Configure backend/.env: LLM_BASE_URL=http://localhost:11434/v1 LLM_API_KEY=ollama LLM_MODEL=llama3.1:8b

    TESSERACT_CMD=C:\Program Files\Tesseract-OCR\tesseract.exe

  4. Start the backend and front-end as above.

🟢🟡🔴 Run Everything (scripts, copy/paste)

Legend: 🟢 recommended · 🟡 optional/helpful · 🔴 strict/fail-fast

🟢 1) Install everything (first time)

./install-all.sh

🟢 2) Run backend + frontend-v2 (recommended)

./dev-all.sh
  • Backend: http://localhost:8000
  • Frontend-v2: http://localhost:5174
  • Logs: .logs/backend.log and .logs/frontend-v2.log

🟡 Run with max logging + POS QR enforced (demo mode)

This turns on HTTP logs + frontend API logs and enforces QR-gating.

./dev-all-verbose.sh

🟢 Run just one piece

Backend only:

./dev-backend.sh

Frontend-v2 only:

./dev-frontend-v2.sh

Legacy static frontend only:

./dev-frontend-static.sh

🟡 Kill stuck dev servers/ports

./kill-latent.sh

🔴 Run tests (strict, fail-fast)

./test-all-strict.sh

🟢 POS QR demo (anti-abuse flow)

  1. Generate a demo receipt image with a signed TSQR1 token QR:
./gen-demo-pos-qr.sh
ls -la backend/fixtures/demo_pos_qr_receipt.png
  1. Run the backend with tenant secrets configured:
POS_TENANT_SECRETS='{"demo":"dev-secret"}' \
POS_QR_ENFORCEMENT=on \
./dev-backend.sh
  1. Upload backend/fixtures/demo_pos_qr_receipt.png in the UI.

Optional QR diagnostics (prints decoded texts):

./debug-qr.sh backend/fixtures/demo_pos_qr_receipt.png

🟡 Useful env toggles

Backend:

  • TAPSURE_DEBUG_HTTP=1 (detailed HTTP request/response logs)
  • POS_QR_ENFORCEMENT=on|off|auto (default: on)
  • POS_REQUIRE_QR=1 (force QR required)
  • POS_TENANT_SECRETS='{"demo":"dev-secret"}' (required to verify tokens)
  • POS_QR_MAX_AGE_SECONDS=900, POS_QR_MAX_FUTURE_SKEW_SECONDS=60, POS_QR_MAX_BYTES=3000000

Frontend-v2 (read at dev-server startup):

  • VITE_API_URL=http://localhost:8000
  • VITE_DEBUG_LOGGING=1 (logs every API call in the browser console)
  • VITE_POS_REQUIRE_QR=1 (adds X-POS-Require-QR: 1 header for uploads)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published