mkstar is a service that generates shareable square images displaying a GitHub repository's star count. These images are designed for social media sharing to celebrate star count milestones.
- Generate 1:1 square images showing a GitHub repository's star count
- Add optional custom notes to celebrate milestones
- Accept GitHub repository URLs directly or using the simple
username/repositoryformat - Simple and responsive web interface
- Direct image download
- Copy shareable image URL
- Modern, dark theme design with GitHub branding
Try the application at: https://mkstar.netlify.app
- Node.js (v14 or newer)
- npm
- Clone the repository
git clone https://github.com/nkkko/mkstar.git
cd mkstar
- Install dependencies
npm install
- Create a
.envfile in the project root (optional)
PORT=5005
# Add GitHub token for higher rate limits (optional)
# GITHUB_TOKEN=your_github_token
- Start the server in development mode
npm run dev
- For production mode
npm start
- Open your browser and navigate to
http://localhost:5005
- Enter a GitHub repository in one of these formats:
- Simple:
username/repository - Full URL:
https://github.com/username/repository
- Simple:
- Add an optional custom note (e.g., "We reached 1000 stars!")
- Click "Generate Image"
- Preview the generated image
- Download the image or copy the direct URL to share
Generate an image using a direct URL:
https://yourdomain.com/username/repository
Add a custom note:
https://yourdomain.com/username/repository?note=We%20reached%201K%20stars!
Or using the generate endpoint:
https://yourdomain.com/generate?url=https://github.com/username/repository¬e=Thanks%20for%20the%20support!
The easiest way to deploy mkstar is using Docker:
# Build the Docker image
docker build -t mkstar .
# Run the container
docker run -p 5005:5005 mkstarOr with docker-compose:
docker-compose up -dmkstar can be deployed to Vercel with a few simple steps:
-
Fork this repository to your GitHub account
-
Create a vercel.json file in the project root:
{
"version": 2,
"builds": [
{ "src": "src/index.js", "use": "@vercel/node" }
],
"routes": [
{ "src": "/(.*)", "dest": "src/index.js" }
],
"env": {
"NODE_ENV": "production"
}
}-
Sign up for an account on Vercel if you don't have one
-
Install the Vercel CLI:
npm install -g vercel
- Login to Vercel:
vercel login
- Deploy the project:
vercel
- For production deployment:
vercel --prod
-
Fork this repository to your GitHub account
-
Create a netlify.toml file in the project root:
[build]
command = "npm install"
functions = "netlify/functions"
publish = "public"
[functions]
node_bundler = "esbuild"
[[redirects]]
from = "/*"
to = "/.netlify/functions/api/:splat"
status = 200- Create a netlify/functions/api.js file:
const express = require('express');
const serverless = require('serverless-http');
const path = require('path');
const { fetchRepoData } = require('../../src/github');
const { generateStarImage } = require('../../src/imageGenerator');
const app = express();
app.use(express.static(path.join(__dirname, '../../public')));
app.use(express.urlencoded({ extended: true }));
// Home page route
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, '../../public/index.html'));
});
// Generate image from query parameter
app.get('/generate', async (req, res) => {
try {
if (!req.query.url) {
return res.status(400).json({ error: 'GitHub URL is required' });
}
const repoData = await fetchRepoData(req.query.url);
const note = req.query.note || '';
const imageBuffer = await generateStarImage(repoData, note);
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public, max-age=300');
res.send(imageBuffer);
} catch (error) {
res.status(500).json({ error: error.message || 'Failed to generate image' });
}
});
// Generate image with username/repo path parameter
app.get('/:owner/:repo', async (req, res) => {
try {
const { owner, repo } = req.params;
const githubUrl = `https://github.com/${owner}/${repo}`;
const repoData = await fetchRepoData(githubUrl);
const note = req.query.note || '';
const imageBuffer = await generateStarImage(repoData, note);
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public, max-age=300');
res.send(imageBuffer);
} catch (error) {
res.status(500).json({ error: error.message || 'Failed to generate image' });
}
});
module.exports.handler = serverless(app);- Install serverless-http:
npm install --save serverless-http
-
Create a Netlify account: https://app.netlify.com/signup
-
Connect your GitHub repository to Netlify and deploy.
Check the TODO.md file for planned improvements and features.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- GitHub API
- Node.js and Express
- Sharp for image processing