A GitHub profile views counter service that can be deployed on Vercel, using MongoDB for data storage.
- IP-based view counting (same IP within 24 hours not counted repeatedly)
- Real GitHub user verification (calls GitHub API)
- Beautiful SVG badge style
- Vercel Serverless deployment
- MongoDB data persistence
- 7-day cache mechanism to reduce API calls
Add the following to your GitHub profile README:
Example:
- Create a free MongoDB Atlas account
- Create a new cluster
- Create a database user
- Get the connection string
- Fork this project to your GitHub
- Visit Vercel
- Import your GitHub repository
- Configure environment variables:
MONGODB_URI: MongoDB connection stringMONGODB_DB_NAME: Database name (optional, defaults to profile_views_counter)IP_ACCESS_WINDOW_HOURS: IP access time window (optional, defaults to 24 hours)
- Click Deploy
# Install dependencies
npm install
# Copy environment variables file
cp .env.example .env
# Edit .env file, fill in your MongoDB connection information
# Start development server
npm run devVisit http://localhost:3000/{username}/count.svg to test
Returns profile views count SVG image
Parameters:
username: GitHub username (path parameter)
Response:
- Content-Type:
image/svg+xml - Returns SVG format profile views badge
- Response headers include:
X-Profile-Views-Count: Current view countX-Profile-Views-Is-New: Whether this visit is newX-Profile-Views-IP: IP tracking status
API interface version
Parameters:
username: GitHub username (query parameter)
- Same IP address visiting the same user within 24 hours counts only once
- Supports proxy environments like Vercel, Cloudflare to get real IP
- IP access records automatically cleaned up
- Calls GitHub API to verify if username exists
- 7-day cache mechanism to reduce API call frequency
- Prevents view counting for invalid usernames
- Runtime: Node.js 18+
- Framework: Vercel Serverless Functions
- Database: MongoDB
- Styling: SVG
- API: GitHub REST API
MIT