The industry's first offline-first KYC solution. High-speed OCR, biometric matching, and background syncβpackaged into a lightweight installable Progressive Web App.
HC-402 is a secure, modern digital Know Your Customer (KYC) and identity verification platform. It enables seamless identity verification through:
- π Document OCR - Intelligent extraction of data from government IDs
- π€ Face Recognition - Biometric face matching between document and selfie
- π Liveness Detection - Anti-spoofing verification with video analysis
- π Compliance Reports - Automated PDF generation for audit trails
- π± Progressive Web App - Works offline, installable on any device
- π End-to-End Encryption - Secure session management with JWT
- π Beautiful UI - Modern, mobile-first responsive design
- β Authentication System - Secure login with NextAuth.js
- β Responsive Layout - Mobile-first design with Tailwind CSS
- β Multi-Step Wizard - Guided onboarding (Document β Selfie β Review)
- β File Upload Component - Drag-and-drop ID document upload
- β Camera Capture - Real-time selfie capture with video preview
- β Dashboard - Admin verification hub with audit logs
- β Results Display - Real-time verification scores and status
- β PWA Ready - Service workers, offline support, installable app
- β Dark Mode Compatible - Beautiful UI with Tailwind styling
- β RESTful API - Complete KYC endpoints with proper error handling
- β File Management - Secure file upload and storage system
- β Database Layer - SQLite with SQLAlchemy ORM
- β
Document Upload -
/kyc/upload-id- ID document storage - β
Selfie Upload -
/kyc/upload-selfie- Selfie image storage - β
Verification Engine -
/kyc/verify- Run KYC verification - β
Result Retrieval -
/kyc/result- Get verification results - β
Report Generation -
/kyc/generate-report- PDF report creation - β
Health Checks -
/healthendpoint for monitoring
- β Document OCR - Extract text from ID documents
- β Face Detection - Locate faces in images
- β Face Matching - Compare faces with confidence scoring
- β Liveness Detection - Verify real person vs. spoofed image
- β Document Validation - Quality checks on ID documents
- β Image Processing - Preprocessing and normalization
- β Session-Based Security - Unique KYC ID per verification
- β JWT Authentication - NextAuth.js with JWT tokens
- β CORS Enabled - Secure cross-origin requests
- β File Validation - Size limits (5MB) and type checks
- β Database Encryption - SQLite with secure storage
- β AES-256 Data Protection - End-to-end encryption
| Layer | Technology | Version |
|---|---|---|
| Frontend | Next.js | 16.1.6 |
| Frontend UI | React | 19.2.3 |
| Frontend Styling | Tailwind CSS | 3.x |
| Frontend Auth | NextAuth.js | 4.24.13 |
| Frontend PWA | next-pwa | 5.6.0 |
| Backend API | FastAPI | Latest |
| Backend Server | Uvicorn | Latest |
| Backend ORM | SQLAlchemy | Latest |
| Database | SQLite | 3.x |
| ML Libraries | OpenCV, NumPy, PIL | Latest |
| Containerization | Docker | 20.10+ |
| DevOps | Docker Compose | 2.x |
hc402-kyc-platform/
βββ frontend/ # Next.js React PWA
β βββ app/ # App Router pages
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Home page
β β βββ login/ # Login page
β β βββ onboarding/ # Verification wizard
β β βββ dashboard/ # Admin dashboard
β β βββ api/ # Route handlers (NextAuth, KYC proxy)
β βββ components/ # Reusable React components
β β βββ Header.tsx # Navigation header
β β βββ OnboardingWizard.tsx # Multi-step wizard
β β βββ FileUpload.tsx # Document upload
β β βββ Camera.tsx # Selfie capture
β β βββ Results.tsx # Verification results
β β βββ Footer.tsx # Footer component
β β βββ ui/ # shadcn/ui components
β βββ lib/ # Utilities
β β βββ auth.ts # NextAuth configuration
β β βββ utils.ts # Helper functions
β βββ public/ # Static assets
β β βββ sw.js # Service worker
β βββ package.json # Dependencies
β βββ tsconfig.json # TypeScript config
β βββ next.config.ts # Next.js config
β
βββ backend/ # FastAPI Python backend
β βββ main.py # FastAPI app entry point
β βββ config.py # Configuration settings
β βββ database.py # SQLAlchemy setup
β βββ routers/ # API route handlers
β β βββ health.py # Health check endpoint
β β βββ kyc.py # KYC verification routes
β βββ models/ # Data models
β β βββ kyc_model.py # KYC database model
β β βββ response.py # Response schemas
β βββ services/ # Business logic
β β βββ file_service.py # File operations
β β βββ report_service.py # PDF report generation
β βββ ml_service/ # ML services
β β βββ api/
β β β βββ ml_service.py # ML API endpoints
β β βββ ocr/
β β β βββ document_ocr.py # OCR processing
β β β βββ text_extractor.py # Text extraction
β β βββ face/
β β β βββ face_detector.py # Face detection
β β β βββ face_matcher.py # Face matching
β β β βββ liveness.py # Liveness detection
β β βββ fraud/
β β β βββ document_validator.py # Document validation
β β βββ utils/
β β βββ image_processor.py # Image utilities
β βββ uploads/ # User uploaded files
β βββ requirements.txt # Python dependencies
β βββ logging_config.py # Logging configuration
β
βββ deployment/ # Deployment configuration
β βββ docker/ # Docker files
β β βββ Dockerfile.backend # Backend container
β β βββ Dockerfile.frontend # Frontend container
β βββ scripts/ # Deployment scripts
β
βββ docs/ # Documentation
βββ assets/ # Images and icons
βββ docker-compose.yml # Docker Compose orchestration
βββ .env.example # Environment variables template
βββ README.md # This file
Ensure you have installed:
- Node.js 18.0+ (Download)
- Python 3.10+ (Download)
- Docker & Docker Compose (Optional, for containerized setup)
- Git (Download)
- npm or yarn (comes with Node.js)
git clone https://github.com/yourusername/hc402-kyc-platform.git
cd hc402-kyc-platform# Copy the example environment file
cp .env.example .env
# Edit .env with your configuration
nano .env # or use your preferred editorEnvironment Variables (.env):
# Application Configuration
ENVIRONMENT=development
DEBUG=true
# Backend Settings
API_HOST=0.0.0.0
API_PORT=8000
SECRET_KEY=your-super-secret-key-change-this
PYTHON_BACKEND_URL=http://localhost:8000
# Database
DATABASE_URL=./kyc.db
# File Uploads
UPLOAD_DIR=./uploads
MAX_FILE_SIZE=5242880
# Frontend
FRONTEND_URL=http://localhost:3000
NEXTAUTH_SECRET=your-nextauth-secret-key
NEXTAUTH_URL=http://localhost:3000cd backend
# Create Python virtual environment
python3 -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# From backend directory with activated venv
uvicorn main:app --reload --host 0.0.0.0 --port 8000Backend will be available at: http://localhost:8000
Check health: http://localhost:8000/health
# In new terminal, navigate to frontend
cd frontend
# Install Node dependencies
npm install
# or
yarn install# From frontend directory
npm run dev
# or
yarn devFrontend will be available at: http://localhost:3000
git clone https://github.com/yourusername/hc402-kyc-platform.git
cd hc402-kyc-platformcp .env.example .env
# Edit .env as needed
nano .env# Build and start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose downServices:
- Backend:
http://localhost:8000 - Frontend:
http://localhost:3000
GET /health # Backend health check
GET / # API info endpoint
POST /kyc/upload-id # Upload ID document
POST /kyc/upload-selfie # Upload selfie image
POST /kyc/verify # Start verification process
GET /kyc/result # Get verification results
POST /kyc/generate-report # Generate PDF report
GET /kyc/status # KYC service status
Upload ID Document:
curl -X POST http://localhost:8000/kyc/upload-id \
-F "file=@id_photo.jpg" \
-F "kyc_id=user123"Start Verification:
curl -X POST http://localhost:8000/kyc/verify \
-H "Content-Type: application/json" \
-d '{"kyc_id": "user123"}'Get Results:
curl http://localhost:8000/kyc/result?kyc_id=user123The platform uses NextAuth.js with JWT for secure authentication.
Email: test@example.com
Password: demo (in development mode)
Edit frontend/lib/auth.ts to modify authentication logic:
async authorize(credentials) {
// Replace with your authentication logic
if (credentials?.email === "test@example.com" &&
credentials?.password === "demo") {
return {
id: "user123",
name: "Test User",
email: "test@example.com"
};
}
return null;
}KYC Sessions Table:
CREATE TABLE kyc_sessions (
kyc_id VARCHAR PRIMARY KEY,
ocr_confidence FLOAT,
face_match_score FLOAT,
status VARCHAR,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)# Access SQLite database
sqlite3 backend/kyc.db
# View all records
SELECT * FROM kyc_sessions;
# Clear all records (for testing)
DELETE FROM kyc_sessions;cd frontend
# Run tests
npm test
# Run with coverage
npm test -- --coverage
# Run in watch mode
npm test -- --watchcd backend
# Run pytest
pytest
# With coverage
pytest --cov=.
# Specific test file
pytest tests/test_kyc.pyThe KYC verification follows this workflow:
1. User Login
β
2. Document Upload (ID Card)
β (API: /kyc/upload-id)
Document validation & OCR extraction
β
3. Selfie Capture
β (API: /kyc/upload-selfie)
Face detection & quality check
β
4. Final Submission
β (API: /kyc/verify)
Face matching + Liveness check
Optional: Video-based liveness verification
β
5. Results & Report
β (API: /kyc/result)
Display verification score (0-100%)
Status: VERIFIED / REJECTED
Generate PDF report
| Page | Route | Purpose |
|---|---|---|
| Home | / |
Landing page with features overview |
| Login | /login |
Authentication page |
| Onboarding | /onboarding |
KYC verification wizard |
| Dashboard | /dashboard |
Admin/verification hub |
- Header - Navigation with auth status
- OnboardingWizard - Multi-step form with progress
- FileUpload - Drag-and-drop document upload
- Camera - Real-time video capture
- Results - Verification results display
- Footer - Security badges and links
# 1. Install Homebrew (macOS)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 2. Install Node.js
brew install node
# 3. Install Python
brew install python3
# 4. Install Docker
brew install docker
# 5. Clone project
git clone https://github.com/yourusername/hc402-kyc-platform.git
cd hc402-kyc-platform
# 6. Follow Quick Start steps above# 1. Install Chocolatey (run as Admin)
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# 2. Install prerequisites
choco install nodejs python docker-desktop git -y
# 3. Clone project
git clone https://github.com/yourusername/hc402-kyc-platform.git
cd hc402-kyc-platform
# 4. Follow Quick Start steps with Windows-specific commandsFrontend won't start:
cd frontend
rm -rf node_modules package-lock.json
npm install
npm run devBackend won't connect:
# Check if port 8000 is in use
lsof -i :8000 # macOS/Linux
netstat -ano | findstr :8000 # Windows
# Kill process (if needed)
kill -9 <PID> # macOS/Linux
taskkill /PID <PID> /F # WindowsDatabase issues:
# Delete and recreate SQLite
rm backend/kyc.db
python backend/main.py # Recreates schemaCORS errors:
- Ensure
PYTHON_BACKEND_URLis correctly set in.env - Backend must have CORS middleware enabled
- Check both frontend and backend are running
File upload fails:
- Check
uploads/directory exists and is writable - Verify MAX_FILE_SIZE is not too restrictive
- Ensure file format is JPEG or PNG
# Backend
export DEBUG=True
uvicorn main:app --reload --log-level debug
# Frontend
export DEBUG=true
npm run dev- Set
ENVIRONMENT=productionin.env - Change
SECRET_KEYto a strong random value - Change
NEXTAUTH_SECRETto a strong random value - Enable HTTPS (use Let's Encrypt)
- Setup database backups
- Configure CDN for static assets
- Setup monitoring and alerts
- Configure CI/CD pipeline
# Build production images
docker-compose -f docker-compose.yml build
# Start services
docker-compose up -d
# View logs
docker-compose logs backend frontend
# Scale services (if needed)
docker-compose up -d --scale backend=3- Image optimization with Next.js
Imagecomponent - Code splitting with dynamic imports
- Service worker caching for offline support
- Lighthouse score optimization
- Database query optimization with indexes
- Async processing with background tasks
- GPU acceleration for ML models
- Response compression with gzip
- Always use HTTPS in production
- Keep dependencies updated - Run
npm audit fixregularly - Validate all inputs - Both frontend and backend
- Rotate secrets regularly - Change SECRET_KEY monthly
- Use CORS properly - Specify allowed origins
- Enable CSRF protection - Configured by default
- Sanitize file uploads - Check file types and sizes
- Monitor logs - Check for suspicious activity
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email: support@hc402.dev | Open an issue: GitHub Issues
Last Updated: February 2026 | Version: 1.0.0