A facial validation service for KYC (Know Your Customer) processes that compares two face images to determine if they belong to the same person.
You can use documents such as a driver's license to verify if it matches the photo.
- KYC-CHECK
- β Upload two images containing faces
- β Real-time image preview
- β Face similarity comparison
- β Percentage-based similarity score
- β Modern user interface with theme switching
- β REST API for integration with other systems
- β Internationalization (Portuguese & English)
- β Monorepo architecture with separate packages
- β Next.js frontend with TypeScript
- β Docker and Kubernetes support
- Basic KYC Implementation Guide using KYC_CHECK - A practical guide on how to implement and use the KYC_CHECK library in your projects.
KYC-CHECK is structured as a monorepo using pnpm workspaces, consisting of two main packages:
- API: Backend service for face detection and comparison
- Web: Next.js frontend application with TypeScript and Tailwind CSS
This architecture allows independent development and deployment of each package while maintaining a unified codebase.
# Clone the repository
git clone https://github.com/juninhopo/kyc-check.git
cd kyc-check
# Install dependencies
pnpm install
# Download face recognition models
pnpm run download-modelsCreate a .env file in the root directory with the following variables:
PORT=3000
API_THRESHOLD=0.50
# Start development environment for both packages
pnpm dev
# Start only the API development server
pnpm --filter api dev
# Start only the Web development server
pnpm --filter web dev
# Build for production
pnpm build
# Start production server
pnpm startAccess the application at http://localhost:3000
This project uses Tailwind CSS for styling. Here are the available commands for working with Tailwind CSS:
# Build Tailwind CSS once
pnpm --filter web build:css
# Watch for changes and rebuild Tailwind CSS automatically
pnpm --filter web watch:css
# Start development server with Tailwind CSS watching
pnpm --filter web devThe project includes several custom Tailwind components:
.btn- Base button style.btn-primary- Primary action button.btn-secondary- Secondary action button.card/.card-dark- Card containers for light/dark modes.lang-button- Language selection buttons.language-active- Active language indicator.theme-toggle- Theme toggle button
You can find and modify these styles in the web package.
POST /api/validate-faces
| Parameter | Types | Description |
|---|---|---|
| image1 | File | First face image |
| image2 | File | Second face image |
type ValidationResponse = {
success: boolean;
data?: {
isMatch: boolean;
similarity: number;
debugInfo?: {
// Debug information about face detection
};
};
error?: string;
};Success Response:
{
"success": true,
"data": {
"isMatch": true,
"similarity": 0.92,
"debugInfo": {
"face1": {
"confidence": 0.99,
"detectionTime": 156
},
"face2": {
"confidence": 0.98,
"detectionTime": 142
},
"comparisonTime": 85
}
}
}Using cURL:
# Production
curl -X POST \
https://kyc-check-production.up.railway.app/api/validate-faces \
-H 'Content-Type: multipart/form-data' \
-F 'image1=@/path/to/first/image.jpg' \
-F 'image2=@/path/to/second/image.jpg'
# Local Development
curl -X POST \
http://localhost:3000/api/validate-faces \
-H 'Content-Type: multipart/form-data' \
-F 'image1=@/path/to/first/image.jpg' \
-F 'image2=@/path/to/second/image.jpg'KYC-CHECK supports both Portuguese (Brazil) and English (US) languages:
Users can switch between languages by clicking on the language buttons (flags) located in the header:
- π§π· Portuguese (Brazil) - Default language
- πΊπΈ English (US)
All interface elements, validation messages, and results will automatically be translated based on the selected language.
When using the API, you can specify the preferred language for error messages:
curl -X POST \
http://localhost:3000/api/validate-faces \
-H 'Content-Type: multipart/form-data' \
-H 'Accept-Language: en-US' \
-F 'image1=@/path/to/first/image.jpg' \
-F 'image2=@/path/to/second/image.jpg'For Portuguese responses, use Accept-Language: pt-BR. If not specified, the API will default to Portuguese.
kyc-check/
βββ packages/
β βββ api/ # Backend service
β β βββ models/ # Face recognition models
β β βββ src/ # API source code
β β βββ api/ # API endpoints
β β βββ services/ # Face detection services
β β βββ types/ # TypeScript definitions
β β βββ utils/ # Utility functions
β βββ web/ # Next.js Frontend
β βββ public/ # Static assets
β βββ src/ # Frontend source code
β βββ app/ # Next.js app directory
β βββ components/ # React components
β βββ contexts/ # React contexts
β βββ services/ # API service calls
βββ k8s/ # Kubernetes configurations
βββ Dockerfile # Docker configuration
βββ pnpm-workspace.yaml # pnpm workspace configuration
βββ package.json # Project root dependencies
Build and run the application using Docker:
# Build the Docker image
docker build -t kyc-check .
# Run the container
docker run -p 3000:3000 kyc-checkDeploy to a Kubernetes cluster using the provided configuration files:
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml- Icon designed by Eric Viana
- This project is based on the original KYC-CHECK by juninhopo
- Special thanks to the developers of face-api.js and its Node.js port by @vladmandic
- Interface redesigned with Next.js and TailwindCSS for improved usability and performance
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request