No description
  • Go 81.2%
  • HTML 18.2%
  • JavaScript 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-06 23:44:53 +08:00
.opencode/agents working MVP commit 2026-08-05 18:25:08 +08:00
cmd Add synchronous managed uploader agents 2026-08-06 23:06:22 +08:00
docs Harden uploader failure recovery 2026-08-06 23:44:53 +08:00
internal Harden uploader failure recovery 2026-08-06 23:44:53 +08:00
migrations Add synchronous managed uploader agents 2026-08-06 23:06:22 +08:00
queries working MVP commit 2026-08-05 18:25:08 +08:00
src working MVP commit 2026-08-05 18:25:08 +08:00
static Add printable distributor statements 2026-08-05 20:45:59 +08:00
templates Harden uploader failure recovery 2026-08-06 23:44:53 +08:00
tests working MVP commit 2026-08-05 18:25:08 +08:00
.env.example working MVP commit 2026-08-05 18:25:08 +08:00
.gitignore working MVP commit 2026-08-05 18:25:08 +08:00
AGENTS.md working MVP commit 2026-08-05 18:25:08 +08:00
CHANGELOG.md Harden uploader failure recovery 2026-08-06 23:44:53 +08:00
docker-compose.yml working MVP commit 2026-08-05 18:25:08 +08:00
go.mod working MVP commit 2026-08-05 18:25:08 +08:00
go.sum working MVP commit 2026-08-05 18:25:08 +08:00
opencode.json working MVP commit 2026-08-05 18:25:08 +08:00
README.md Add synchronous managed uploader agents 2026-08-06 23:06:22 +08:00
sqlc.yaml working MVP commit 2026-08-05 18:25:08 +08:00

PMVIC Uploader

Internal web application for PMVIC vehicle lookup, emission-result validation, synchronous LTMS upload, and transaction tracking.

Getting started

  1. Start PostgreSQL:
docker compose up -d postgres
  1. Apply migrations with Goose:
go run github.com/pressly/goose/v3/cmd/goose@latest -dir migrations postgres "$DATABASE_URL" up

For a local PostgreSQL install using peer/socket authentication, this project was verified with:

createdb eney
goose -dir migrations postgres "postgres:///eney?host=/var/run/postgresql" up
DATABASE_URL="postgres:///eney?host=/var/run/postgresql" go run ./cmd/web
  1. Run the web app:
go run ./cmd/web
  1. Open http://localhost:8080.

Development users:

Mock lookup values:

  • GAS123 or any normal value returns a gasoline SUV.
  • DIESEL returns a diesel utility vehicle.
  • MOTO, MOTORCYCLE, TRICYCLE, or MOP returns a motorcycle.
  • NOTFOUND returns no vehicle.
  • TEMPFAIL returns a temporary lookup failure.
  • REJECT returns a vehicle but the mock upload is rejected.
  • UNKNOWN returns a vehicle but the mock upload outcome is unknown.

LTMS modes

The app defaults to deterministic mock mode for development:

LTMS_MODE=mock go run ./cmd/web

Direct LTO mode is intended only when the web server runs from an LTO-authorized IP and production upload settings are configured:

LTMS_MODE=direct \
PMVIC_CENTER="Configured Center" \
ITP_CODE="configured-itp-code" \
INSPECTOR_USERNAME="configured-inspector" \
go run ./cmd/web

Optional direct-mode settings:

  • LTMS_SEARCH_URL, defaulting to the documented get_vehicleinfo endpoint.
  • LTMS_UPLOAD_URL, defaulting to the documented store_testresults endpoint.
  • LTMS_SEARCH_TIMEOUT, default 60s.
  • LTMS_UPLOAD_TIMEOUT, default 600s.

TLS certificate verification remains enabled. Failed or uncertain uploads are not retried automatically.

Uploader Agent

Remote uploader agents wrap the LTMS lookup and upload API from an LTO-authorized site. The web app calls agents synchronously over the private Netbird/WireGuard network and requires a per-agent bearer token.

Run an agent on an authorized site:

UPLOADER_AGENT_TOKEN="change-this-token" \
HTTP_ADDR=":8090" \
go run ./cmd/uploader

Register the agent as an admin or manager in /admin/uploaders with its Netbird HTTP URL, token, priority, and daily allocation. Lower priority numbers are used first. Successful uploads count against allocation; unresolved UNKNOWN uploads hold allocation until reconciled. Vehicle lookup remains direct from the main app by default, but agents expose /agent/v1/lookup and have a lookup-enabled switch for future fallback use.

Development Commands

sqlc generate
gofmt -w cmd internal
go test ./...
go build ./...

Project documentation

  • AGENTS.md: Instructions for AI coding agents
  • docs/PROJECT.md: Goals, users, scope, and constraints
  • docs/ARCHITECTURE.md: Components and data flow
  • docs/DECISIONS.md: Architectural decision records
  • docs/CURRENT_STATE.md: Continuation notes for future sessions
  • docs/TESTING.md: Test commands and strategy
  • docs/BACKLOG.md: Deferred and upcoming work

OpenCode subagents

  • @review: Read-only review of current changes
  • @project-docs: Updates project documentation after implementation