How bhargavmupparisetty/trackable-pages works
Project type and purpose
• This is a small full-stack web application (“Trackable Pages”) whose sole purpose is to generate one-time, trackable short links for any legitimate URL, log visitor data (IP, device, geolocation), and then seamlessly redirect the visitor to the original URL.
File structure
• Top-level files:
• package.json / package-lock.json: Node.js dependencies
• server.js: the Express-based HTTP server entry point
• public/index.html: single-page UI for entering a URL
• node_modules: installed libraries (likely including Express, a geolocation library or HTTP-client, etc.)
• No database directory—logging is likely in memory, to disk, or via a third-party API.
README for additional insights
• Tech stack: HTML/Vanilla JS front end, Node.js backend
• Workflow: generate link → share link → log on click → redirect
• Potential external dependency: a geolocation API to map IP → location
A. Client Browser (frontend)
• Loads index.html
• Makes REST call to backend to “create” a trackable link
B. Backend Application (Node.js/Express)
• Link Generation Module
• Generates a unique token/URL for each submitted target URL
• Persists the (token → original-URL) mapping (in memory, file, or DB)
• Redirect & Tracking Module
• Receives incoming GET /track/:token requests
• Extracts client IP and User-Agent
• Calls Geolocation Service (internal library or external API) to resolve location
• Logs the aggregated data (IP, device, timestamp, resolved location)
• Responds with HTTP 302 redirect to the original URL
C. Storage (optional in your current implementation)
• In-memory store, file-based logs, or a future database (Mongo, Redis, etc.)
D. External Services
• Geolocation API (e.g., ip-api.com or a similar service)
• The legitimate target website (final redirect destination)
Architectural patterns and design principles
• Separation of concerns:
• UI layer in /public vs. server logic in server.js
• Link generation vs. redirect/tracking modules
• Stateless HTTP services: each redirect request carries all info in request headers
• Potential extension to microservices: e.g., a dedicated geolocation microservice or a database microservice