Skip to content

xthxr/piik.me

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

PIIK.ME

The open-source link infrastructure for modern businesses.

Real-time analytics, custom domains, and zero latency redirects.

License:  GNU Node.js Firebase Socket.IO Vercel

A professional-grade, open-source platform for creating trackable short links, personalized bio pages, and real-time analytics with instant QR code generation β€” a better alternative to bitly. com

Features β€’ Quick Start β€’ Tech Stack β€’ API Reference β€’ Contributing


πŸ“‹ Overview

PIIK.ME is a comprehensive link management and analytics platform that empowers marketers, developers, and businesses to create, track, and analyze their URLs with unprecedented insight. Built with modern web technologies and real-time capabilities, it offers everything from URL shortening to personalized bio link pages.

Why PIIK.ME?

  • πŸš€ Real-Time Analytics - Watch clicks happen live with WebSocket-powered updates
  • πŸ“± QR Code Generation - Instantly generate and download customizable QR codes
  • 🎯 Campaign Tracking - Built-in UTM parameter support for marketing attribution
  • πŸ‘€ Bio Links - Create stunning personalized bio pages with social links (like Linktree)
  • βœ… Verified Badges - Premium verification system for early adopters
  • πŸ”’ Secure & Private - Firebase Authentication with security rules
  • πŸ’Ύ Persistent Storage - All data safely stored in Google Cloud Firestore
  • ⚑ Low Latency - Sub-second analytics updates for immediate insights
  • 🌐 Open Source - Free to use, modify, and deploy for any purpose

✨ Features

Core Capabilities

Feature Description
URL Shortening Generate short, memorable links with custom codes
Custom Short Codes Choose your own vanity URLs with real-time availability checking
Real-Time Analytics Dashboard Live tracking of impressions, clicks, and shares
QR Code Generation One-click QR code creation with download functionality
UTM Parameter Management Add and track campaign parameters (source, medium, campaign, term, content)
Device & Browser Analytics Detailed breakdown of mobile vs desktop and browser usage
Referrer Tracking Identify traffic sources and referring websites
Click-Through Rate (CTR) Automatic calculation and display of conversion metrics
Share Tracking Monitor social sharing and link distribution
Click History Chronological log of all link interactions with timestamps

πŸ‘€ Bio Links (New!)

Create personalized bio pages accessible at piik.me/username:

  • Custom Profile Pages - Display name, bio, and profile picture
  • Multiple Link Support - Add unlimited social links with icons
  • Drag & Drop Ordering - Easily reorder links with drag-and-drop functionality
  • Live Preview - See changes in real-time while editing
  • Auto-Save - Changes save automatically without manual intervention
  • Background Styles - Multiple animated background options including:
    • Animated radial gradients
    • Mesh gradient effects
    • Glassmorphism overlays
  • Verified Badges - Blue checkmark verification for early adopters
  • "Under Review" Status - Unverified profiles display review status
  • Link Previews - Automatic favicon and URL previews for each link
  • Magnetic Hover Effects - Interactive hover animations on links

🎨 Visual Enhancements

  • Holographic UI Design - Modern glassmorphism aesthetic
  • 3D Parallax Tilt Effects - Interactive card animations
  • Animated Mesh Gradients - Dynamic background animations
  • Magnetic Interactions - Engaging hover states
  • Responsive Design - Mobile-first UI with modern CSS animations
  • Loading Animations - Rotating logo on black background

Technical Features

  • Google Authentication - Secure OAuth login via Firebase Auth
  • User Dashboard - Centralized view of all created links with quick stats
  • WebSocket Updates - Real-time analytics via Socket.IO (no page refresh needed)
  • Firebase Firestore - NoSQL database for scalable data persistence
  • RESTful API - Comprehensive API for programmatic access
  • Custom Short Code Validation - Real-time checking with improved UX (300ms debounce)
  • Firestore Server Timestamps - Proper sorting and display of creation dates
  • Session Management - Firebase Auth token-based sessions

πŸ› οΈ Technology Stack

piik.me is built with modern, production-ready technologies:

Backend

Technology Purpose
Node.js JavaScript runtime environment
Express.js Web application framework
Socket.IO Real-time bidirectional event-based communication
Firebase Admin SDK Server-side Firebase operations
nanoid Secure, URL-friendly unique ID generator
Axios HTTP client for API requests
QRCode Server-side QR code generation

Frontend

Technology Purpose
HTML5 Semantic markup
CSS3 Modern styling with glassmorphism, animations, and transitions
Vanilla JavaScript Lightweight, no-framework frontend
Firebase SDK Client-side authentication
QRCode.js Client-side QR code generation
Three.js 3D graphics and animations
Globe.gl Interactive 3D globe visualizations
D3 Scale Data visualization utilities

Database & Authentication

Service Purpose
Firebase Firestore NoSQL cloud database
Firebase Authentication OAuth 2.0 provider (Google Sign-In)

Development Tools

Tool Purpose
dotenv Environment variable management
cors Cross-origin resource sharing
nodemon Development server with auto-reload

Deployment

Platform Purpose
Vercel Serverless deployment with automatic HTTPS

Architecture Highlights

  • RESTful API - Clean, resource-oriented endpoints
  • WebSocket Communication - Sub-second analytics updates
  • JWT Token Authentication - Secure session management
  • Event-Driven Architecture - Scalable real-time processing
  • NoSQL Database - Flexible schema for rapid iteration
  • Client-Server Architecture - Separated concerns with Firebase backend

πŸ“¦ Dependencies

{
  "dependencies": {
    "axios": "^1.13.2",
    "cors": "^2.8.5",
    "d3-scale": "^4.0.2",
    "d3-scale-chromatic": "^3.1.0",
    "dotenv": "^16.3.1",
    "express":  "^4.18.2",
    "firebase": "^12.4.0",
    "firebase-admin": "^13.5.0",
    "globe.gl": "^2.45.0",
    "nanoid": "^3.3.7",
    "qrcode": "^1.5.4",
    "socket.io":  "^4.6.1",
    "three":  "^0.181.2"
  },
  "devDependencies":  {
    "nodemon": "^3.0.1"
  }
}

πŸš€ Quick Start

Prerequisites

  • Node.js v14 or higher (Download)
  • npm (comes with Node.js)
  • Google Account (for Firebase setup)
  • Firebase Project (Create one free)

Installation

  1. Clone the repository

    git clone https://github.com/xthxr/piik.me.git
    cd piik.me
  2. Install dependencies

    npm install
  3. Set up Firebase

    • Create a Firebase project
    • Enable Google Authentication
    • Create a Firestore database
    • Generate service account credentials
    • Configure Firestore security rules
  4. Configure environment variables

    Create a .env file in the root directory (see .env.example):

    PORT=3000
    BASE_URL=http://localhost:3000
    
    # Firebase Admin SDK (from service account JSON)
    FIREBASE_PROJECT_ID=your_project_id
    FIREBASE_CLIENT_EMAIL=your_client_email@your_project. iam.gserviceaccount.com
    FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
  5. Update Firebase web configuration

    Edit public/js/firebase-config.js with your Firebase web app credentials.

  6. Start the application

    npm start

    For development with auto-reload:

    npm run dev
  7. Access the dashboard

    Open your browser and navigate to: http://localhost:3000


πŸ“ Project Structure

The project follows a clean, modular architecture optimized for maintainability and contributor-friendliness:

zaplink/
β”œβ”€β”€ config/               # Configuration files
β”‚   └── firebase.config.js    # Firebase Admin SDK initialization
β”œβ”€β”€ docs/                 # Documentation
β”‚   β”œβ”€β”€ ARCHITECTURE.md       # System architecture
β”‚   β”œβ”€β”€ CODE_OF_CONDUCT.md    # Community guidelines
β”‚   β”œβ”€β”€ FIREBASE_SETUP.md     # Firebase setup guide
β”‚   β”œβ”€β”€ PROJECT_STRUCTURE.md  # Detailed structure docs
β”‚   └── SECURITY.md           # Security policies
β”œβ”€β”€ public/               # Frontend assets (served statically)
β”‚   β”œβ”€β”€ assets/              # Icons and images
β”‚   β”œβ”€β”€ css/                 # Stylesheets
β”‚   β”œβ”€β”€ js/                  # Client-side JavaScript modules
β”‚   β”‚   β”œβ”€β”€ app.js           # Main application logic
β”‚   β”‚   β”œβ”€β”€ auth.js          # Authentication module
β”‚   β”‚   β”œβ”€β”€ bio-link.js      # Bio link functionality
β”‚   β”‚   β”œβ”€β”€ qr-generator.js  # QR code generation
β”‚   β”‚   └── firebase-config.js # Firebase client config
β”‚   β”œβ”€β”€ index.html           # Main dashboard
β”‚   β”œβ”€β”€ bio.html             # Bio link page
β”‚   └── landing.html         # Landing page
β”œβ”€β”€ scripts/              # Utility scripts
β”‚   └── set-verified-badges.js # Badge management
β”œβ”€β”€ src/                  # Server-side source code
β”‚   β”œβ”€β”€ middleware/          # Express middleware
β”‚   β”‚   └── auth.middleware.js # Token verification
β”‚   β”œβ”€β”€ routes/              # API routes (modular)
β”‚   β”œβ”€β”€ services/            # Business logic
β”‚   β”‚   └── memory.service.js # In-memory storage
β”‚   └── utils/               # Helper functions
β”‚       └── url.utils.js     # URL utilities
β”œβ”€β”€ .env.example          # Environment template
β”œβ”€β”€ CONTRIBUTING.md       # Contribution guide
β”œβ”€β”€ LICENSE               # MIT License
β”œβ”€β”€ package.json          # Dependencies
β”œβ”€β”€ README.md             # This file
β”œβ”€β”€ server.js             # Express server entry point
└── vercel.json           # Deployment config

πŸ“– For detailed information about the project structure, see docs/PROJECT_STRUCTURE.md


πŸ—„οΈ Data Architecture

piik.me uses Firebase Firestore for scalable, persistent data storage.

Database Collections

links Collection

{
  originalUrl: string,      // Full destination URL
  shortCode: string,        // Unique identifier (e.g., "abc123")
  shortUrl: string,         // Complete short URL
  userId: string,           // Firebase Auth user ID
  userEmail: string,        // User's email address
  createdAt: timestamp,     // Server timestamp for proper sorting
  utmParams: {
    source:  string,
    medium: string,
    campaign: string,
    term: string,
    content: string
  }
}

analytics Collection

{
  impressions: number,
  clicks: number,
  shares: number,
  clickHistory: [{
    timestamp: timestamp,
    device: string,       // "mobile" or "desktop"
    browser: string,
    referrer: string
  }],
  devices: { mobile: number, desktop: number },
  browsers: { chrome, firefox, safari, edge, other },
  referrers: { "example.com": number, "direct":  number }
}

bioLinks Collection

{
  username: string,         // Unique username/slug
  displayName: string,      // Display name
  bio: string,              // Profile bio
  profilePicture: string,   // Profile image URL
  links: [{
    title: string,
    url: string,
    order: number
  }],
  backgroundStyle: string,  // Background theme
  verified: boolean,        // Verification status
  userId: string,
  createdAt: timestamp
}

πŸ”Œ API Reference

Authentication

Protected endpoints require a Firebase Auth token:

Authorization: Bearer {firebase-auth-token}

Endpoints

Method Endpoint Description
POST /api/shorten Create short link
GET /api/user/links Get user's links
GET /api/analytics/: shortCode Get analytics data
POST /api/track/impression/: shortCode Track impression
POST /api/track/share/:shortCode Track share
GET /: shortCode Redirect (auto-tracks click)
POST /api/github/bug Create GitHub issue

WebSocket Events (Socket.IO)

socket.on('analyticsUpdate', (data) => {
  // { shortCode, impressions, clicks, shares, ...  }
});

🚒 Deployment

Vercel (Recommended)

  1. Install Vercel CLI:

    npm i -g vercel
  2. Deploy:

    vercel
  3. Set environment variables in Vercel dashboard

The repository includes vercel.json for zero-config deployment.

Production Checklist

  • Update Firestore security rules
  • Add production domain to Firebase authorized domains
  • Configure all Firebase credentials as env variables
  • Set BASE_URL to production domain
  • Enable HTTPS/SSL
  • Implement rate limiting
  • Set up error logging (Sentry)
  • Configure CDN for static assets

πŸ”’ Security

Implemented Features

  • βœ… OAuth 2.0 via Google (Firebase Authentication)
  • βœ… Server-side token verification
  • βœ… User-specific data isolation
  • βœ… Firestore security rules
  • βœ… HTTPS enforcement (production)

Recommended Additions

// Rate Limiting
const rateLimit = require('express-rate-limit');
app.use('/api/', rateLimit({ windowMs: 15 * 60 * 1000, max: 100 }));

// Security Headers
const helmet = require('helmet');
app.use(helmet());

🀝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Quick Contribution Steps

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Test thoroughly
  5. Commit: git commit -m "Add amazing feature"
  6. Push: git push origin feature/amazing-feature
  7. Open a Pull Request

Areas for Contribution

  • πŸ› Bug fixes
  • ✨ New features
  • πŸ“ Documentation
  • 🎨 UI/UX enhancements
  • ⚑ Performance optimizations
  • 🌍 Internationalization (i18n)

πŸ“„ License

piik.me is open-source software licensed under the MIT License.

MIT License

Copyright (c) 2024-2025 piik.me

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. 

πŸ™ Acknowledgments

Built with amazing open-source technologies:


⭐ Star this repo if you find it useful!

Made with ❀️ by xthxr