Skip to content

keshav-sudo/kurser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Kurser - GitHub Repository Manager πŸš€

Ek modern system jo GitHub repositories ko track, analyze aur manage karta hai. Automatic webhooks, code analysis aur distributed processing ke sath.

Kya Kar Sakta Hai? ✨

  • GitHub se login karo aur apni repositories dekho
  • Automatic webhook setup
  • Repository clone aur analysis
  • Real-time updates jab bhi code change ho
  • Queue-based processing (no overload)
  • Azure Blob me files store
  • Scalable architecture (jitne chahiye utne workers)

Kaise Kaam Karta Hai? πŸ—οΈ

User β†’ Frontend β†’ API β†’ MongoDB (data save)
                    ↓
                  Redis Queue
                    ↓
                  Worker β†’ Git Clone β†’ Azure Storage
                    ↓
                  Analysis Complete!

Technology Stack πŸ’»

Backend:

  • Node.js + TypeScript
  • Express (API)
  • MongoDB (Database)
  • BullMQ + Redis (Queue)
  • GitHub OAuth

Worker:

  • Background job processing
  • Git operations
  • Azure Blob Storage

Frontend:

  • React + Vite
  • Clean UI

Local Setup (Testing) πŸš€

1. Clone karo

git clone <your-repo-url>
cd kurser

2. Docker se start karo

docker-compose up -d

3. Environment variables set karo

main/.env file:

MONGODB_URI=your_mongodb_atlas_url
GITHUB_CLIENT_ID=your_github_app_id
GITHUB_CLIENT_SECRET=your_github_app_secret
JWT_SECRET=random_secret_key
REDIS_HOST=redis
REDIS_PORT=6379

worker/.env file:

REDIS_HOST=redis
REDIS_PORT=6379
MONGODB_URI=same_as_main
WORKER_CONCURRENCY=5

4. Access karo

Production Deployment 🌐

Sabse easy: Railway.app (free tier available) Best for Azure: App Service + Blob Storage

Complete guide: DEPLOYMENT.md

Quick Deploy to Railway:

  1. Railway.app pe account banao
  2. GitHub repo connect karo
  3. 4 services add karo: Redis, Main, Worker, Frontend
  4. Environment variables set karo
  5. Deploy! ✨

URLs automatically mil jayengi:

  • Example: kurser-api.railway.app

Azure Storage Setup (Optional but Recommended)

Agar aap large repositories clone kar rahe ho, to Azure Blob Storage use karo:

# Storage account banao
az storage account create --name kurserdata --resource-group kurser-rg

# Connection string lo
az storage account show-connection-string --name kurserdata

Worker .env me add karo:

AZURE_STORAGE_CONNECTION_STRING=your_connection_string

Important URLs

Website kahan milegi:

  • Railway: Dashboard me automatic URL milti hai
  • Azure: https://your-app-name.azurewebsites.net
  • Vercel: Deploy karne pe URL milti hai

GitHub Webhook URL:

  • Format: https://your-api-url.com/webhook
  • Yeh URL GitHub repository settings me dalna hoga

Project Structure πŸ“

kurser/
β”œβ”€β”€ main/                   # Main API service
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/        # Configuration files
β”‚   β”‚   β”œβ”€β”€ controller/    # Route controllers
β”‚   β”‚   β”œβ”€β”€ middleware/    # Express middleware
β”‚   β”‚   β”œβ”€β”€ models/        # MongoDB models
β”‚   β”‚   β”œβ”€β”€ routes/        # API routes
β”‚   β”‚   └── index.ts       # Entry point
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”‚
β”œβ”€β”€ worker/                # Worker service
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/        # Queue & env config
β”‚   β”‚   β”œβ”€β”€ processors/    # Job processors
β”‚   β”‚   β”œβ”€β”€ workers/       # Worker definitions
β”‚   β”‚   β”œβ”€β”€ services/      # Git & Azure services
β”‚   β”‚   └── index.ts       # Entry point
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”‚
β”œβ”€β”€ frontend/              # React frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # React components
β”‚   β”‚   β”œβ”€β”€ pages/         # Page components
β”‚   β”‚   β”œβ”€β”€ services/      # API services
β”‚   β”‚   └── App.tsx        # Main app
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”‚
β”œβ”€β”€ docker-compose.yml     # Docker Compose config
β”œβ”€β”€ DEPLOYMENT.md          # Deployment guide
β”œβ”€β”€ WORKER_SETUP.md        # Worker setup guide
└── README.md              # This file

Features in Detail πŸ”

1. Webhook Processing

When GitHub sends a webhook:

  1. Main API receives and validates webhook
  2. Saves event to MongoDB
  3. Adds job to Redis queue
  4. Worker picks up and processes
  5. Updates event status

2. Repository Cloning

When repository is added:

  1. Job added to clone queue
  2. Worker clones repository to local storage
  3. Can checkout specific branches
  4. Triggers analysis job

3. Code Analysis

Worker analyzes:

  • Total file count
  • File type distribution
  • Lines of code
  • Project type detection
  • Latest commit information

Scaling Guidelines πŸ“

Repositories Workers Concurrency Redis Memory
0-100 1 5 256MB
100-500 2-3 5 512MB
500-2000 5-10 5-10 1-2GB
2000+ 10-20+ 10 4GB+

Azure Queue Integration ☁️

For enterprise scale (2000+ repos):

# Add to worker/.env
AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;...

Benefits:

  • 20,000 messages/sec throughput
  • 7-day message retention
  • 99.9% SLA
  • Geo-redundancy

Troubleshooting πŸ”§

Workers Not Processing

# Check Redis
docker-compose ps redis
docker exec -it kurser-redis redis-cli ping

# Check queue has jobs
docker exec -it kurser-redis redis-cli KEYS bull:*

# Restart worker
docker-compose restart worker

GitHub Webhooks Not Working

  1. Verify PUBLIC_URL is set
  2. Check GitHub webhook settings
  3. Ensure URL is publicly accessible
  4. Check webhook delivery in GitHub

High Memory Usage

# Reduce concurrency
WORKER_CONCURRENCY=3 docker-compose up -d

# Or add more workers
docker-compose up -d --scale worker=5

Contributing 🀝

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing)
  5. Open Pull Request

Performance Tips ⚑

  1. Use Redis persistence for job recovery
  2. Scale workers horizontally instead of increasing concurrency too high
  3. Monitor queue depth and scale proactively
  4. Clean up old cloned repos regularly
  5. Use Azure Queues for very high throughput

Security πŸ”’

  • JWT tokens for authentication
  • GitHub OAuth for secure login
  • Environment variables for secrets
  • CORS configured for frontend
  • Rate limiting (recommended to add)

License πŸ“„

ISC

Support πŸ’¬

  • Documentation: See /docs folder
  • Issues: GitHub Issues
  • Discussions: GitHub Discussions

Roadmap πŸ—ΊοΈ

  • Bull Board dashboard integration
  • Prometheus metrics
  • Advanced code analysis (complexity, dependencies)
  • Slack/Discord notifications
  • Multi-tenant support
  • GraphQL API
  • Real-time updates via WebSocket

Acknowledgments πŸ™

  • BullMQ for reliable queue processing
  • simple-git for Git operations
  • GitHub API for repository data
  • Railway/Nixpacks for easy deployment

Made with ❀️ for scalable GitHub repository management

kurser

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors