Skip to content

naresh-kamarthy/linkmind-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

LinkMind AI

LinkMind AI

AI URL Shortener & Realtime Analytics Platform

Enterprise-grade link intelligence platform powered by Gemini AI, realtime Socket.IO telemetry, and a production-hardened MERN stack.

TypeScript React Node.js Express MongoDB Socket.IO Gemini AI Redis Tailwind CSS License

Build PRs Welcome Platform


๐Ÿ“‹ Table of Contents


๐Ÿง  Overview

LinkMind AI is a production-grade, full-stack SaaS platform that redefines URL shortening with AI-powered analytics, realtime visitor telemetry, and enterprise-level security.

Built on the MERN stack with TypeScript end-to-end, it combines sub-5ms Redis-cached redirections, Socket.IO live dashboards, Gemini AI traffic intelligence, and a comprehensive admin moderation system โ€” all wrapped in a polished glassmorphism UI.

What makes LinkMind AI different?

  • ๐Ÿ”— Not just a URL shortener โ€” it's a complete link intelligence platform
  • ๐Ÿ“Š Realtime analytics โ€” live click streams, visitor counters, and timeline charts powered by Socket.IO
  • ๐Ÿค– AI-driven insights โ€” Gemini generates actionable marketing recommendations from your traffic data
  • ๐Ÿ›ก๏ธ Enterprise security โ€” CSRF protection, HttpOnly JWT cookies, RBAC, rate limiting, and Helmet headers
  • โšก Redis-powered performance โ€” BullMQ queue-based click processing with <4ms cache-hit redirections
  • ๐ŸŒ GeoIP tracking โ€” real geographic visitor data via MaxMind integration

โœจ Features

Core Link Management

Feature Description
URL Shortening Generate compact, trackable short links with auto-generated codes
Custom Aliases Create branded vanity URLs (/r/my-brand) with unique constraint validation
QR Code Generation Automatic vector QR code generation for every shortened link
Campaign Grouping Organize links into named campaigns for segmented analytics
Password Protection Secure sensitive links behind password-gated unlock pages
Expiration System Set auto-expiry dates with cron-based archival processing
Burn-After-Click One-time-use links that self-destruct after first access
Favorites & Archive Star important links and archive inactive ones
Bulk Export Download click history as timestamped CSV or nested JSON

๐Ÿ“Š Analytics & Monitoring

Feature Description
Realtime Click Tracking Live click events streamed to dashboards via Socket.IO
Visitor Demographics Device type, OS, browser, country, city breakdown
Traffic Timeline Interactive Recharts visualizations with hourly distribution
Referrer Analysis Track inbound traffic sources and referral channels
Unique vs Total Clicks Deduplicated visitor metrics with IP-based uniqueness
Active Visitor Counter Live global connected-user count broadcast in realtime
GeoIP Resolution Real city/country/timezone mapping via MaxMind geoip-lite

๐Ÿ” Authentication & Security

Feature Description
JWT HttpOnly Cookies Secure, non-JavaScript-accessible token storage
Refresh Token Flow Automatic silent token refresh with 7-day sliding sessions
CSRF Protection Double-submit cookie pattern (XSRF-TOKEN header validation)
Helmet Headers Comprehensive HTTP security headers
CORS Policy Configurable cross-origin protection
Rate Limiting Granular DDoS protection across auth, API, redirect, and AI endpoints
RBAC Role-based access control (user / admin) with middleware guards
Developer API Keys SHA-256 hashed API keys with expiration and lastUsedAt tracking

๐Ÿ›ก๏ธ Admin Dashboard

Feature Description
User Management View, suspend, and manage all registered users
Global Analytics Platform-wide click metrics and user activity overview
Audit Logs Comprehensive administrative action logging with auto-rotation
Suspicious Link Monitoring Review and moderate flagged or problematic links
Protected Routes Admin-only pages gated by RBAC middleware

๐Ÿค– AI Intelligence

Feature Description
Gemini-Powered Insights Deep traffic analysis with actionable marketing recommendations
Engagement Analysis AI evaluates click patterns, device ecosystems, and referral quality
Peak Time Detection Identifies optimal posting windows from hourly activity profiles
Growth Tactics Concrete, data-driven suggestions for campaign optimization
Smart Fallbacks Heuristic analytics engine when Gemini API is unavailable

๐Ÿ› ๏ธ Tech Stack

Frontend

Technology Purpose
React 19 Component-based UI framework
TypeScript End-to-end type safety
Redux Toolkit Global state management with slices
Tailwind CSS v4 Utility-first responsive styling
Framer Motion Smooth page transitions and micro-animations
Recharts Interactive data visualization charts
Lucide React Modern icon system
Axios HTTP client with interceptor support
Socket.IO Client Realtime WebSocket communication
React Router v7 Client-side routing with protected routes
Zod Runtime schema validation

Backend

Technology Purpose
Node.js JavaScript runtime
Express.js REST API framework
TypeScript Server-side type safety
MongoDB + Mongoose Document database with compound indexes
JWT (jsonwebtoken) Stateless authentication tokens
Socket.IO Realtime bidirectional event communication
Redis (ioredis) High-performance caching layer
BullMQ Background job queue for click telemetry
Helmet HTTP security headers
Cookie Parser Secure cookie management
Express Rate Limit DDoS and abuse protection
bcryptjs Password hashing with salt rounds
node-cron Background scheduled maintenance tasks
qrcode QR code generation library
geoip-lite MaxMind GeoIP database integration
esbuild Ultra-fast production bundler

AI & Intelligence

Technology Purpose
Google Gemini API gemini-3.5-flash model for traffic intelligence
@google/genai Official Google GenAI SDK

Deployment

Platform Use
Vercel Frontend hosting + serverless functions
Railway / Render Backend + WebSocket hosting
MongoDB Atlas Managed cloud database
Upstash / Redis Cloud Managed Redis instances

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        CLIENT BROWSER                           โ”‚
โ”‚              React 19 + Redux Toolkit + Socket.IO               โ”‚
โ”‚                    Tailwind CSS + Recharts                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚                  โ”‚
                   REST API            WebSocket
                   (Axios)          (Socket.IO Client)
                        โ”‚                  โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     EXPRESS SERVER (Node.js)                     โ”‚
โ”‚                                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚   Helmet     โ”‚  โ”‚   CORS       โ”‚  โ”‚   Cookie Parser        โ”‚  โ”‚
โ”‚  โ”‚   Security   โ”‚  โ”‚   Policy     โ”‚  โ”‚   + CSRF Shield        โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚              RATE LIMITERS (Per-Route Granularity)          โ”‚ โ”‚
โ”‚  โ”‚   Global: 200/15m โ”‚ Auth: 15/15m โ”‚ AI: 10/15m โ”‚ 300/15m   โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”           โ”‚
โ”‚  โ”‚  Auth    โ”‚ โ”‚  Links   โ”‚ โ”‚ Campaign โ”‚ โ”‚  Admin   โ”‚           โ”‚
โ”‚  โ”‚  Routes  โ”‚ โ”‚  Routes  โ”‚ โ”‚  Routes  โ”‚ โ”‚  Routes  โ”‚           โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜           โ”‚
โ”‚       โ”‚            โ”‚            โ”‚            โ”‚                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚  โ”‚            CONTROLLER LAYER                      โ”‚            โ”‚
โ”‚  โ”‚   Auth โ”‚ Links โ”‚ Campaigns โ”‚ Analytics โ”‚ Admin   โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ”‚                         โ”‚                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚  โ”‚              SERVICE LAYER                       โ”‚            โ”‚
โ”‚  โ”‚   AI Service โ”‚ Redis โ”‚ Queue (BullMQ) โ”‚ Cron    โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ”‚               โ”‚               โ”‚
          โ–ผ               โ–ผ               โ–ผ
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚   MongoDB   โ”‚ โ”‚    Redis    โ”‚ โ”‚  Gemini AI  โ”‚
   โ”‚   Atlas     โ”‚ โ”‚   Cache     โ”‚ โ”‚   Engine    โ”‚
   โ”‚             โ”‚ โ”‚  + BullMQ   โ”‚ โ”‚             โ”‚
   โ”‚  โ€ข Users    โ”‚ โ”‚  โ€ข Link     โ”‚ โ”‚  โ€ข Traffic  โ”‚
   โ”‚  โ€ข Links    โ”‚ โ”‚    Cache    โ”‚ โ”‚    Analysis โ”‚
   โ”‚  โ€ข Analyticsโ”‚ โ”‚  โ€ข AI Cache โ”‚ โ”‚  โ€ข Growth   โ”‚
   โ”‚  โ€ข Campaignsโ”‚ โ”‚  โ€ข Pub/Sub  โ”‚ โ”‚    Tactics  โ”‚
   โ”‚  โ€ข ApiKeys  โ”‚ โ”‚  โ€ข Socket   โ”‚ โ”‚  โ€ข Peak     โ”‚
   โ”‚  โ€ข AuditLog โ”‚ โ”‚    Adapter  โ”‚ โ”‚    Times    โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Realtime Analytics Flow

User clicks /r/:shortCode
        โ”‚
        โ–ผ
  Rate Limiter Check (300/15min)
        โ”‚
        โ–ผ
  Redis Cache Lookup (<4ms)  โ”€โ”€โ”€โ”€ Cache Miss โ”€โ”€โ”€โ–ถ  MongoDB Query
        โ”‚                                               โ”‚
        โ–ผ                                               โ–ผ
  Extract Visitor Metadata                        Cache Result in Redis
  (IP, User-Agent, GeoIP, Referrer)                     โ”‚
        โ”‚                                               โ”‚
        โ–ผ                                               โ”‚
  BullMQ Queue โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  (Async Click Telemetry)
        โ”‚
        โ–ผ
  MongoDB Analytics Insert
        โ”‚
        โ–ผ
  Socket.IO Broadcast
  โ†’ "click_registered" event
  โ†’ Link room + Campaign room
  โ†’ Active visitor count update
        โ”‚
        โ–ผ
  Dashboard Charts Update (Realtime)

Authentication Lifecycle

Register/Login โ”€โ”€โ–ถ Generate JWT Pair โ”€โ”€โ–ถ Set HttpOnly Cookies
                   (access: 15m)         (Secure, SameSite)
                   (refresh: 7d)
        โ”‚
        โ–ผ
  Protected Request โ”€โ”€โ–ถ Verify Access Token
        โ”‚                      โ”‚
        โ”‚              Token Expired?
        โ”‚                 โ”‚         โ”‚
        โ”‚               Yes         No
        โ”‚                โ”‚          โ”‚
        โ”‚                โ–ผ          โ–ผ
        โ”‚         Verify Refresh   Proceed
        โ”‚            Token          โ”‚
        โ”‚              โ”‚            โ”‚
        โ”‚         Rotate Pair       โ”‚
        โ”‚         Set New Cookies   โ”‚
        โ”‚              โ”‚            โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ธ Screenshots

Add screenshots of the running application here.

View Preview
Dashboard Dashboard
Link Analytics Analytics
Campaign Manager Campaigns
Admin Panel Admin
Mobile View Mobile

๐Ÿš€ Getting Started

Prerequisites

  • Node.js v18+ and npm v9+
  • MongoDB (Atlas cloud or local instance)
  • Redis (optional โ€” enables caching, BullMQ queues, and Socket.IO scaling)
  • Gemini API Key (optional โ€” enables AI traffic insights)

Installation

# 1. Clone the repository
git clone https://github.com/yourusername/linkmind-ai.git
cd linkmind-ai

# 2. Install dependencies
npm install

# 3. Configure environment variables
cp .env.example .env
# Edit .env with your credentials (see Environment Variables section)

# 4. Seed the admin user (optional)
npm run seed:admin

# 5. Start the development server
npm run dev

The application will launch at http://localhost:3000 with Vite's hot-reload development middleware enabled.

Production Build

# Compile frontend (Vite) and backend (esbuild โ†’ CJS)
npm run build

# Launch the production server
npm run start

๐Ÿ”‘ Environment Variables

Create a .env file in the project root with the following variables:

Required

Variable Description Example
MONGODB_URI MongoDB connection string mongodb+srv://user:pass@cluster.mongodb.net/linkmind
JWT_SECRET Secret key for signing JWT tokens your-super-secure-jwt-secret-key-2026

Optional (Recommended for Production)

Variable Description Example
NODE_ENV Environment mode production
APP_URL Public application URL https://linkmind.ai
GEMINI_API_KEY Google Gemini API key for AI insights API KEY
REDIS_URI Redis connection URL (enables caching, BullMQ, Socket.IO adapter) redis://user:pass@host:6379
# โ”€โ”€โ”€ Server โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
NODE_ENV=production
APP_URL=https://linkmind.ai

# โ”€โ”€โ”€ Database โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/linkmind

# โ”€โ”€โ”€ Authentication โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
JWT_SECRET=your-super-secure-jwt-secret-key-2026

# โ”€โ”€โ”€ AI Engine โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
GEMINI_API_KEY=AIzaSy...

# โ”€โ”€โ”€ Redis (Optional) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
REDIS_URI=redis://default:password@redis-host:6379

# โ”€โ”€โ”€ Frontend โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
VITE_API_URL=https://api.linkmind.ai

Note: If MONGODB_URI is not set, the app automatically falls back to an in-memory MongoDB instance via mongodb-memory-server for development. If REDIS_URI is not set, the app gracefully falls back to direct database queries and memory-based batch processing.


๐Ÿ”’ Security

LinkMind AI implements multi-layer security designed for production SaaS environments:

Authentication Security

  • HttpOnly Cookies โ€” JWT tokens stored in HTTP-only cookies, preventing XSS token theft
  • Secure Flag โ€” Cookies marked Secure in production (HTTPS-only transmission)
  • SameSite Policy โ€” None in production for cross-origin support, Lax in development
  • Token Rotation โ€” Automatic access token refresh using long-lived refresh tokens
  • Password Hashing โ€” bcrypt with 10 salt rounds for all stored passwords

Request Security

  • CSRF Protection โ€” Double-submit cookie pattern validates XSRF-TOKEN headers on all mutations (POST/PUT/DELETE)
  • Helmet Headers โ€” Comprehensive HTTP security headers (X-Frame-Options, X-Content-Type-Options, etc.)
  • CORS โ€” Configurable cross-origin resource sharing policy
  • Input Validation โ€” Zod schemas for request payload validation

Rate Limiting

Endpoint Group Limit Window
Global API 200 requests 15 minutes
Auth (Login/Register) 15 requests 15 minutes
Gemini AI Analytics 10 requests 15 minutes
Link Redirects 300 requests 15 minutes

Access Control

  • RBAC Middleware โ€” Role-based route protection (user, admin)
  • Admin Route Guard โ€” Server-side authorize("admin") middleware + client-side redirect
  • API Key Auth โ€” SHA-256 hashed developer keys with expiration support
  • Account Suspension โ€” Suspended users are blocked at the middleware level

๐Ÿค– AI Features

LinkMind AI integrates Google Gemini (gemini-3.5-flash) to transform raw click data into actionable intelligence:

How It Works

  1. Data Collection โ€” The analytics engine aggregates click metrics including device profiles, geographic data, referral channels, and hourly activity patterns
  2. AI Analysis โ€” Gemini processes the anonymized dataset through a specialized marketing analysis prompt
  3. Insight Generation โ€” The AI produces a structured report with four key sections:
    • Traffic Summary โ€” Current performance assessment and trajectory analysis
    • Audience Demographics โ€” Geographic and device ecosystem breakdown
    • Peak Time Detection โ€” Optimal posting windows based on hourly click distribution
    • Growth Tactics โ€” Three concrete, data-driven marketing recommendations

Intelligent Caching

  • AI responses are cached in Redis for 30 minutes using a compound hash of analytics properties
  • Cache keys incorporate click totals, unique visitors, and data dimensions to auto-invalidate when metrics change meaningfully

Graceful Fallbacks

  • If the Gemini API key is not configured, a heuristic analytics engine generates insights using statistical analysis of available data
  • Heuristic results are cached for 5 minutes and provide the same structured format

โšก Realtime Engine

Socket.IO Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Browser 1  โ”‚     โ”‚  Browser 2  โ”‚     โ”‚  Browser N  โ”‚
โ”‚  Dashboard  โ”‚     โ”‚  LinkDetail โ”‚     โ”‚  Campaign   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚                   โ”‚                   โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚ WebSocket
                           โ–ผ
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚     Socket.IO Server   โ”‚
              โ”‚                        โ”‚
              โ”‚  Rooms:                โ”‚
              โ”‚  โ€ข link:{linkId}       โ”‚
              โ”‚  โ€ข campaign:{campId}   โ”‚
              โ”‚                        โ”‚
              โ”‚  Events:               โ”‚
              โ”‚  โ€ข click_registered    โ”‚
              โ”‚  โ€ข active_visitors     โ”‚
              โ”‚  โ€ข join_link           โ”‚
              โ”‚  โ€ข join_campaign       โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚  Redis Pub/Sub Adapter โ”‚
              โ”‚  (Horizontal Scaling)  โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Events

Event Direction Description
click_registered Server โ†’ Client New click telemetry data broadcast
active_visitors Server โ†’ Client Updated global connected user count
join_link Client โ†’ Server Subscribe to a specific link's room
join_campaign Client โ†’ Server Subscribe to a campaign's room

Horizontal Scaling

  • The @socket.io/redis-adapter enables multi-instance deployment where Socket.IO events sync across distributed server containers via Redis Pub/Sub

๐Ÿ”ฎ Future Roadmap

  • GeoIP Dashboard Maps โ€” Interactive world map visualization of visitor locations
  • AI Anomaly Detection โ€” Automated alerts for suspicious traffic spikes or bot activity
  • CDN Edge Caching โ€” Cloudflare Workers for sub-millisecond global redirections
  • Team Workspaces โ€” Multi-user organizations with shared link management
  • Webhook Integrations โ€” Real-time click notifications to Slack, Discord, and custom endpoints
  • A/B Link Testing โ€” Split traffic between destination URLs with statistical analysis
  • Custom Domains โ€” Branded short domains with automatic SSL provisioning
  • Link Scheduling โ€” Publish links at specific future dates/times
  • Advanced API Rate Tiers โ€” Usage-based API plans with quota management

๐Ÿ‘จโ€๐Ÿ’ป Author

Naresh Kamarthy

MERN Stack Developer โ€ข AI Systems Engineer โ€ข React.js Developer

GitHub LinkedIn Portfolio


๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.


Built with โค๏ธ and โ˜• by Naresh Kamarthy

If you found this project useful, consider giving it a โญ on GitHub!

About

AI-powered URL shortener and realtime analytics platform with Socket.IO, MongoDB, JWT auth, and admin moderation systems.

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages