No description
While running the backfill against production we found that many
cards had user-corrected values trapped in fieldData with stale
OCR originals in the top-level column (e.g. LaGay: top-level
email "lagayferters@yahoo.com" vs fieldData "lagayfenters@yahoo.com").
The previous "only promote when top-level is empty" rule skipped
these — so the list view, search, and CSV export still showed the
stale OCR data even though the detail view showed the correction.
New rule:
- When fieldData[canonical] is non-empty, promote it to the
top-level column (regardless of whether the top-level column
already has a value). Reasoning: pre-fix, the UI saved
non-core edits only to fieldData, so any non-empty
fieldData[canonical] is the user's most recent value (or
matches the OCR original — harmless either way). Verified
against the prod DB that fieldData never contains
firstName/lastName/name, so there is no risk of reverting
user-edited names.
Also:
- Adds `import "dotenv/config"` so `npx tsx` picks up .env.
- Logs fill-empty vs overwrite counts and a sample of conflicts
(top-level → fieldData) so the dry-run is easy to audit.
Applied against prod: 23 form fields flipped, ~3127 values
promoted across 901 cards, 282 names recomputed. Re-run dry-run
reports 0 remaining changes.
Co-authored-by: Cursor <cursoragent@cursor.com>
|
||
|---|---|---|
| .convoys | ||
| .cursor | ||
| .github | ||
| docs | ||
| prisma | ||
| public | ||
| scripts | ||
| src | ||
| tests/smoke | ||
| .agent-context-manifest.yml | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| AGENTS.md | ||
| components.json | ||
| docker-compose.yml | ||
| Dockerfile | ||
| eslint.config.mjs | ||
| next.config.ts | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.mjs | ||
| prisma.config.ts | ||
| README.md | ||
| start.sh | ||
| tsconfig.json | ||
| vercel.json | ||
Echo OCR
OCR-powered response card scanner and management tool for Echo Life Church.
Scans front/back of paper response cards (PDF or images), extracts structured data using a local Ollama vision model, stores results in PostgreSQL, and serves them through a modern filterable table UI.
Stack
- Next.js 15 (App Router) + Tailwind CSS v4 + shadcn/ui
- TanStack Table for data tables with filtering, sorting, pagination
- Prisma + PostgreSQL for data storage
- Ollama (local LLM) for OCR via vision models (LLaVA 7B recommended)
- MinIO (S3-compatible) for PDF/image storage
- Docker for deployment via Coolify
Local Development
Prerequisites
- Node.js 18+
- Docker + Docker Compose (for PostgreSQL + MinIO)
- Ollama running locally with a vision model (
ollama pull llava:7b) - GraphicsMagick (
brew install graphicsmagick) for PDF-to-image conversion
Setup
# Install dependencies
npm install
# Start local PostgreSQL + MinIO
docker compose up -d postgres minio
# Create MinIO bucket (visit http://localhost:9001, login minioadmin/minioadmin)
# Push database schema
npm run db:push
# Start dev server
npm run dev
Open http://localhost:3000.
Environment Variables
Copy .env.example to .env and configure:
cp .env.example .env
Deployment (Coolify)
See the deployment section in the project plan for step-by-step Coolify setup instructions including PostgreSQL, MinIO bucket creation, Ollama configuration, and Traefik routing.
API Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/cards |
List cards (filters, pagination, search) |
| POST | /api/cards |
Create a card |
| GET | /api/cards/[id] |
Get card with presigned image URLs |
| PUT | /api/cards/[id] |
Update card fields |
| DELETE | /api/cards/[id] |
Delete card and images |
| POST | /api/cards/[id]/export |
Mark card as exported |
| POST | /api/upload |
Upload PDF/images for OCR |
| GET | /api/jobs |
List processing jobs |
| GET | /api/stats |
Card count statistics |
| GET/PUT | /api/settings |
App settings |
| POST | /api/watch |
Start/stop folder monitoring |
| GET | /api/images/[...path] |
Proxy images from MinIO |