How nawinsharma/fingerprint-face-verification works
Project Type and Purpose
• This is a full-stack Next.js web application combining frontend pages and backend API routes.
• It provides biometric capture (fingerprint, face), review, registration, and verification against a PostgreSQL database via Supabase and Prisma ORM.
• It also uses NextAuth.js for user authentication.
File Structure
• Top-level:
• “src/app” holds Next.js App Router pages (page.tsx, layout.tsx) and API routes under src/app/api/*.
• “src/components” contains React UI components (camera feed, previews, forms, layout sections).
• “src/lib” houses database and Supabase clients, plus utility functions.
• “prisma” folder holds schema (schema.prisma) and migration SQL.
• “src/generated/prisma” is the autogenerated Prisma client.
• “scripts” contains Node scripts for generating test data.
• Key configuration: next.config.ts, tsconfig.json, tailwind.config.ts, prisma/schema.prisma, .env for credentials.
• Authentication: NextAuth configured under src/app/api/auth/[...nextauth]/route.ts.
README Insights
• Tech stack: Next.js + Tailwind + Framer Motion (frontend), Next.js API + Supabase (backend), Prisma + PostgreSQL (data), NextAuth for credentials.
• Flow: Capture → Preview → Register → Match/Verify.
• Database table: users with biometric fields and hash buckets.
Main Components & Their Relationships
• Client Browser
• React pages (Next.js App Router) under src/app/*.
• UI components for capture, preview, registration, search.
• Next.js Server
• Server-side rendering of pages.
• API routes:
– /api/auth/* (NextAuth credentials provider)
– /api/auth/signup (user signup)
– /api/search (match & verify endpoint)
– /app/actions/saveUser (edge function or server action to persist user).
• Authentication Layer
• NextAuth.js managing sessions and credential checks.
• Uses lib/supabase or lib/db to verify credentials.
• Data Access Layer
• Prisma Client (in src/lib/db.ts) surfaces typed methods for CRUD on User model.
• Supabase client (in src/lib/supabase.ts) may handle direct REST calls or storage.
• Database
• PostgreSQL hosted by Supabase.
• users table storing personal info, face_image URL, thumb_image URL, face_hash, thumb_hash, buckets.
• Optional External Services
• Supabase Storage (if images are stored in buckets rather than as base64).
• Edge Runtime (Next.js Edge Functions for low-latency).
• Test Data Script
• scripts/generate-test-data.ts invokes Prisma to populate dummy users.
Architectural Patterns & Design Principles
• App Router pattern in Next.js separating Layout, Pages, and API routes.
• Server Actions (in src/app/actions) to encapsulate backend logic close to UI.
• Single codebase for frontend + backend (monorepo style).
• Typed ORM (Prisma) for compile-time safety.
• Clear separation of concerns:
• UI components vs. API business logic.
• Data access (Prisma) vs. external API wrappers (Supabase).