The Name Verification Application is a specialized tool designed to demonstrate intelligent name matching with strict architectural separation. The system consists of two independent components: a Target Name Generator and a Name Verifier, operating under the constraint that the verifier must treat the generator as a black box.
- Target Name Generation: Generate unique human names from natural language prompts using LLM integration
- Name Verification: Verify candidate names against the latest generated target with fuzzy matching
- Black Box Architecture: Strict isolation between generator and verifier components
- Comprehensive Test Suite: 30 test cases covering various name matching scenarios
- Mock Mode: Fallback to mock data when LLM API keys are unavailable
- Production-Ready: Full test coverage and robust error handling
- Black Box Constraint: The verifier cannot access generator internals, chat history, or call back into the generator
- Deterministic Verification: Matching algorithm produces stable, consistent results
- Isolated State: Only the latest generated name string is shared between components
┌─────────────────┐
│ Client UI │
│ (React/TS) │
└─────────────────┘
│
│
│
▼
┌───────────────┐ ┌────────────────┐
│ API server │ generates │ │
│ (Express/TS) │──────────────►│ Name Generator │
│ │ │ (LLM/Mock) │
└───────────────┘ └────────────────┘
│
│ exposes only
│ targetName:string
▼
┌─────────────────┐
│ Name Verifier │
│ (Fuzzy Matcher) │
└─────────────────┘
- Framework: React 19 with TypeScript
- Styling: Tailwind CSS 4
- Build Tool: Vite
- HTTP Client: Native Fetch API with typed wrappers
- Runtime: Node.js (>=18.0.0)
- Framework: Express.js with TypeScript
- LLM Integration: NVIDIA NIM API (with mock fallback)
- Testing: Jest with comprehensive test suite
- Code Quality: TypeScript, ESLint, Prettier
- Node.js >= 18.0.0
- npm >= 9.0.0
- (Optional) NVIDIA NIM API key for live name generation
# Clone the repository
git clone <repository-url>
cd name_verification_app
# Install root dependencies
npm install
# Install client and server dependencies
npm run install:allCreate a .env file in the server directory:
# server/.env
LLM_PROVIDER=nvidia_nim
LLM_MODEL=meta/llama-3.3-70b-instruct
LLM_TEMPERATURE=0.2
LLM_TOP_P=0.9
LLM_MAX_TOKENS=256
# Optional: Add your NVIDIA NIM API key for live generation
# NIM_API_KEY=your_nim_api_key_here
NIM_BASE_URL=https://integrate.api.nvidia.com/v1
PORT=3001
NODE_ENV=developmentStart both client and server concurrently:
npm run devThis will launch:
- Client: http://localhost:3000
- Server: http://localhost:3001
- API Proxy: Client automatically proxies
/apirequests to the server
# Build both client and server
npm run build
# Start production server
npm start# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watchThe application includes 63 comprehensive tests covering:
- Name matching algorithms (30 test cases)
- Edge cases and error handling
- Performance benchmarks
- Configuration validation
- Navigate to the "Target Name Generator" panel
- Enter a prompt (e.g., "Generate a random Arabic sounding name with Al and ibn")
- Click "Generate"
- The system will produce a target name and store it as the latest
- Navigate to the "Name Verifier" panel
- Enter a candidate name to check
- Click "Verify"
- View results including match status, confidence score, and explanation
Prompt: "Generate a Spanish name with two last names"
Generated Target: "Maria Garcia Lopez"
Candidate: "Mario Garcia Lopez"
Result: No Match (51% confidence)
Reason: Gendered name difference
Candidate: "Maria Garcia-Lopez"
Result: Match (92% confidence)
Reason: Names match with minor variations
POST /api/generate
Request:
{
"prompt": "Generate a random Arabic sounding name"
}Response:
{
"targetName": "Ahmed Al Fayed"
}POST /api/verify
Request:
{
"candidateName": "Ahmad Alfayed"
}Response:
{
"match": true,
"confidence": 0.85,
"reason": "Names match with minor variations (spelling, nickname, or transliteration)",
"targetName": "Ahmed Al Fayed"
}The verifier implements a sophisticated multi-layered matching strategy:
- Convert to lowercase
- Remove diacritics and punctuation
- Standardize spacing and hyphens
- Special handling for Arabic names (Al, ibn, Abdul)
- Greedy token alignment algorithm
- Nickname equivalence mapping (Bob ↔ Robert, Liz ↔ Elizabeth)
- Transliteration variations (Mohammed ↔ Muhammad)
- Phonetic suffix handling (v ↔ ff, ov ↔ off)
- Levenshtein distance for typos
- String similarity thresholds
- Cultural-specific rule sets
- Order swap detection and penalization
- Weighted average of token matches
- Penalties for structural differences
- Adaptive thresholds based on name complexity
The application passes 30 specified test cases including:
- Transposition typos: "Tyler Bliha" ↔ "Tlyer Bilha"
- Cultural variations: "Mohammed Al Fayed" ↔ "Muhammad Alfayed"
- Nickname equivalence: "Bob Ellensworth" ↔ "Robert Ellensworth"
- Punctuation differences: "Sarah O'Connor" ↔ "Sara Oconnor"
- Different first names: "John Smith" ↔ "James Smith"
- Order swaps: "Ali Hassan" ↔ "Hassan Ali"
- Gendered differences: "Maria Gonzalez" ↔ "Mario Gonzalez"
- Different surname roots: "Ahmed Al Rashid" ↔ "Ahmed Al Rashidi"
| Variable | Default | Description |
|---|---|---|
| LLM_PROVIDER | nvidia_nim | LLM provider (nvidia_nim, openai_compatible, other) |
| LLM_MODEL | meta/llama-3.3-70b-instruct | Model identifier |
| LLM_TEMPERATURE | 0.2 | Generation creativity (0-2) |
| LLM_TOP_P | 0.9 | Nucleus sampling parameter |
| LLM_MAX_TOKENS | 256 | Maximum tokens per generation |
| NIM_API_KEY | - | NVIDIA NIM API key (optional) |
| NIM_BASE_URL | https://integrate.api.nvidia.com/v1 | API endpoint |
| PORT | 3001 | Server port |
| NODE_ENV | development | Runtime environment |
When no API key is provided, the system automatically uses a mock name generator that:
- Returns consistent names based on prompt hash
- Includes all test case names in rotation
- Provides deterministic behavior for testing
name_verification_app/
├── client/ # React frontend
│ ├── src/
│ │ ├── api/ # HTTP client and types
│ │ ├── components/ # React components
│ │ └── App.tsx # Main application
│ └── vite.config.ts # Build configuration
├── server/ # Express backend
│ ├── src/
│ │ ├── config/ # Configuration management
│ │ ├── generator/ # Name generation logic
│ │ ├── verifier/ # Name matching algorithm
│ │ ├── storage/ # Latest target persistence
│ │ ├── routes/ # API endpoints
│ │ └── index.ts # Server entry point
│ └── test/ # Comprehensive test suite
├── package.json # Root build and run scripts
└── README.md # This documentation
- TypeScript strict mode enabled
- ESLint with React/TypeScript rules
- Prettier for code formatting
- Consistent import ordering
- Structured error responses from API
- Graceful degradation when services unavailable
- Comprehensive logging in development mode
- User-friendly error messages in UI
- English-centric nickname mappings
- Limited support for non-Latin scripts
- Basic phonetic matching (no Soundex/Metaphone)
- In-memory state persistence (restart clears state)
Server fails to start:
- Check Node.js version (>=18 required)
- Verify all dependencies are installed (
npm run install:all) - Ensure PORT 3001 is available
Name generation fails:
- Check
NIM_API_KEYinserver/.env - Verify network connectivity to NVIDIA NIM
- Review server logs for API errors
Tests failing:
- Ensure all dependencies are installed
- Check test environment configuration
- Verify no other process is using test ports
Client cannot connect to server:
- Verify both client and server are running
- Check proxy configuration in
vite.config.ts - Ensure CORS is properly configured
Enable detailed logging by setting in server/.env:
DEBUG=true
NODE_ENV=development- API keys stored server-side only
- No sensitive data in client code
- Input validation on all endpoints
- CORS configured for development only
- Environment-based configuration
- Test cases designed to cover realistic name matching scenarios
- Architecture inspired by clean separation principles
- Fuzzy matching algorithm optimized for name-specific patterns
- Built as a demonstration of robust system design with TypeScript
This application serves as both a practical tool for name verification and a demonstration of well-architected, test-driven TypeScript application development with clear separation of concerns and comprehensive error handling.