Overview
Invoice OCR is built with modern web technologies focused on type safety, performance, and developer experience.Core Technologies
Framework
Next.js 15.5.2
React framework with App Router, server components, and API routes
- App Router for modern routing and layouts
- Server-side API routes for secure OpenRouter integration
- Automatic code splitting and optimization
- Built-in TypeScript support
- Image and font optimization
- App Router (
app/directory) - Route handlers for API endpoints
- Server and client components
next/fontfor Geist font optimization
Language
TypeScript 5
Strict mode enabled for maximum type safety
- Strict mode enabled in
tsconfig.json - Path alias
@/*for clean imports - Type checking for React 19 JSX
- ESNext target for modern JavaScript features
- Catch errors at compile time
- Enhanced IDE autocomplete
- Self-documenting code
- Refactoring confidence
UI & Styling
React 19.1.0
Modern React features:- Functional components with hooks
- Server and client components
- Async server components
- React 19 compiler optimizations
Tailwind CSS v4
Utility-first CSS framework:@tailwindcss/postcssplugin- Custom design system via CSS variables
- Responsive design utilities
- Dark mode support
shadcn/ui
Component library built on:- Radix UI primitives (
@radix-ui/react-*) - Tailwind CSS for styling
class-variance-authorityfor variants
- Button
- Label
- Separator
- Custom styled primitives in
components/ui/
UI Utilities
OCR & AI
OpenRouter API
Provider: https://openrouter.ai Features used:- Vision models for OCR (image → text)
- Structured JSON output (
response_format: json_object) - PDF processing via
file-parserplugin - Multiple model support
- Primary:
openai/gpt-4o-mini(configurable viaOPENROUTER_MODEL) - Fallback:
google/gemini-2.0-flash
pdf-text(default) - Text extractionmistral-ocr- OCR-based extractionnative- Model’s native PDF support
Testing
Vitest 4.0.15
Modern test framework:- Fast, Vite-powered test runner
- Jest-compatible API
- Native TypeScript support
- Watch mode for TDD
vitest.config.ts):
Coverage: @vitest/coverage-v8
Coverage reports:- Text output in terminal
- JSON for CI/CD integration
- HTML for detailed browsing
lib/__tests__/invoice_v4.test.ts- Reconciliation enginelib/__tests__/standards.test.ts- Standards compliance
Development Tools
Linting & Formatting
eslint.config.mjsextendsnext/core-web-vitals- TypeScript-aware rules
- Automatic fixes for many issues
Type Definitions
Package Manager
npm (Node Package Manager) Key scripts:Architecture Patterns
Component Organization
Logic Separation
API Design
Performance Optimizations
Next.js Built-ins
- Automatic code splitting
- Image optimization (
next/image) - Font optimization (
next/font) - Static and dynamic rendering
Build Optimizations
- Tree shaking for unused code
- Minification in production
- CSS extraction and optimization
- Compression and caching headers
Dependencies Summary
Production Dependencies
Development Dependencies
External Services
OpenRouter
API endpoint:https://openrouter.ai/api/v1/chat/completions
Authentication: Bearer token via OPENROUTER_API_KEY
Headers:
HTTP-Referer- Site URL for analyticsX-Title- App name for identification
Version Requirements
- Node.js: 20.x or higher recommended
- npm: 9.x or higher
- TypeScript: 5.x
- React: 19.1.0
- Next.js: 15.5.2
Check
package.json for the exact versions of all dependencies.Next Steps
Project Structure
Explore the repository layout and organization
Local Development
Set up your development environment
