How nick-choudhary/emailvalidator works
Project type and purpose
• This is a Node.js helper library that can also run as a standalone microservice.
• Its core function is to check email validity via syntax checks, DNS (MX/A) lookups, and a live SMTP handshake, with Redis used as a cache layer.
File structure
• Top-level files:
• index.js – exposes the public API (checkEmailAddress, getExternalIp, startWebServer)
• package.json – dependencies (express, redis, dns, net, etc.)
• controllers/ directory:
• externalAddressController.js – obtains or validates the external IP
• validatorController.js – runs syntax checks, DNS queries, SMTP connection attempts, and interacts with Redis
• webServerController.js – sets up an Express HTTP server to expose the email-check API over GET requests
README for additional insights
• Describes two usage patterns:
a) As a module: synchronous method calls
b) As a microservice: HTTP GET on /:email
• Lists external dependencies: Redis (cache), DNS servers, SMTP servers, optional external IP lookup service
a. Main components
• Client (library user or HTTP client)
• API layer
– Module API (function calls)
– HTTP server (webServerController via Express)
• Controllers & Services
– ExternalAddressController
– ValidatorController
• Infrastructure
– Redis cache
– DNS resolvers (public Internet)
– SMTP server endpoints (public Internet)
b. Relationships & data flow
1. Client invokes checkEmailAddress() or sends GET /email@domain.com.
2. If external IP not provided, ExternalAddressController fetches it.
3. ValidatorController:
– Syntax validation
– Redis lookup by email (cache hit → return)
– DNS MX record lookup → if none, A record lookup
– TCP connect to mail exchanger on port 25 to verify live server
– Write result to Redis with TTL
4. Return result object back to client or HTTP response
c. Architectural patterns & design principles
• Modular controllers for separation of concerns
• Cache-aside pattern with Redis to avoid repeated network calls
• Single-process, event-driven Node.js microservice
d. Key technologies/frameworks
• Node.js (runtime)
• Express.js (web server)
• redis (node client)
• dns (built-in)
• net (built-in TCP sockets)
Detail
• Cache logic (check/insert).
• Fallback paths (if MX fails → A record).
• Configuration inputs (redisHost, redisPort, externalIpAddress).