Skip to content

An open-source web-application built with Node.js utilizing GitHub API to find, create, and delete a branch throughout numerous GitHub repositories. Can be setup for organizations or a single user.

License

Notifications You must be signed in to change notification settings

Joe-Tavarez/Git-Captain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

27 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Git-Captain ๐Ÿšข

Git-Captain Logo

Modern, secure Node.js application for managing GitHub repositories at scale

Node.js License Security


๐ŸŒŸ Overview

Git-Captain is a powerful web application that simplifies managing multiple GitHub repositories simultaneously. Originally created to solve the pain of creating same-named branches across numerous repositories for GitFlow and TeamCity workflows, it has evolved into a comprehensive repository management tool.

Perfect for teams working with microservices, multi-repo projects, or any scenario requiring coordinated repository operations.


โœจ Features

  • ๐ŸŒฟ Branch Management: Create, search, and delete branches across multiple repositories
  • ๐Ÿ” Pull Request Discovery: Find open pull requests by base branch
  • ๐Ÿ” Secure GitHub OAuth: Seamless authentication with GitHub
  • ๐Ÿ›ก๏ธ Enterprise Security: Rate limiting, CORS, input validation, security headers
  • ๐Ÿ“Š Real-time Results: Live feedback with detailed operation logs
  • ๐ŸŽฏ Batch Operations: Select multiple repositories for simultaneous operations
  • ๐Ÿ“ฑ Modern UI: Clean, responsive interface with loading states

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+
  • GitHub account with repository access
  • SSL certificates (for HTTPS)

Installation

  1. Clone the repository

    git clone https://github.com/ConfusedDeer/Git-Captain.git
    cd Git-Captain
  2. Install dependencies

    npm install
  3. Configure environment (see Configuration)

  4. Generate SSL certificates (see SSL Setup)

  5. Start the server

    npm start
  6. Access the application

    https://localhost:3000
    

โš™๏ธ Configuration

Environment Variables

Create a .env file in the controllers directory:

# GitHub OAuth Configuration
client_id=your_github_client_id
client_secret=your_github_client_secret
GITHUB_ORG_NAME=your_organization_name

# Server Configuration
PORT=3000
GIT_PORT_ENDPOINT=https://your-domain.com

# SSL Certificate Paths
privateKeyPath=./theKey.key
certificatePath=./theCert.cert

GitHub OAuth Setup

  1. Create OAuth App in GitHub:

    • Go to GitHub Settings โ†’ Developer settings โ†’ OAuth Apps
    • Click "New OAuth App"
    • Application name: Git-Captain
    • Homepage URL: https://your-domain.com
    • Authorization callback URL: https://your-domain.com/authenticated.html
  2. Copy credentials to your .env file

SSL Setup

Generate self-signed certificates (for development):

# Install OpenSSL
# Windows: Download from https://slproweb.com/products/Win32OpenSSL.html
# Linux: sudo apt install openssl

# Generate certificates
openssl req -nodes -new -x509 -keyout controllers/theKey.key -out controllers/theCert.cert

# Set proper permissions (Linux/Mac)
chmod 600 controllers/theKey.key controllers/theCert.cert

For production, use Let's Encrypt or purchase a CA-signed certificate.


๐Ÿ”’ Security Features

Git-Captain implements enterprise-grade security measures:

  • ๐Ÿ›ก๏ธ Security Headers: Helmet.js with CSP, HSTS, and security headers
  • ๐Ÿšฆ Rate Limiting:
    • General: 200 requests/minute
    • Auth operations: 300 requests/5 minutes
    • Sensitive operations: 25 requests/5 minutes
  • ๐ŸŒ CORS Protection: Configurable cross-origin policies
  • โœ… Input Validation: express-validator for all API endpoints
  • ๐Ÿ“ Security Logging: Comprehensive audit trails
  • ๐Ÿ” Session Management: Secure session handling with timeouts

๐Ÿ“š API Endpoints

Endpoint Method Description
/gitCaptain/getToken GET/POST OAuth token exchange
/gitCaptain/searchForRepos POST Search for all your organizations' repositories
/gitCaptain/createBranches POST Create a branch with the same name across all your repositories. Example: creating 'feature/newAwesomeBranch' will create this branch in all repos.
/gitCaptain/searchForBranch POST Searching for a specific branch across ALL your repos. Example: Searching for a branch named 'feature/newAwesomeBranch' will search for this branch and display in which repos that branch exists
/gitCaptain/searchForPR POST Find pull requests
/gitCaptain/deleteBranches DELETE Delete a branch with the same name across all your repositories. Example: deleting 'feature/newAwesomeBranch' will remove this branch from all repos where it exists.
/gitCaptain/checkGitHubStatus GET GitHub API status

๐Ÿ—๏ธ Architecture Overview

Git-Captain v2.0 features a modern, secure architecture built on Node.js and Express:

graph TB
    User[๐Ÿ‘ค User] --> Browser[๐ŸŒ Browser]
    Browser -->|HTTPS| Proxy[๐Ÿ”„ Reverse Proxy]
    Proxy --> App[๐Ÿš€ Git-Captain App<br/>Node.js + Express]
    
    App --> Security[๐Ÿ›ก๏ธ Security Layer<br/>Helmet + CORS + Rate Limiting]
    App --> Auth[๐Ÿ” GitHub OAuth<br/>Authentication]
    App --> API[๐Ÿ™ GitHub API<br/>Repository Operations]
    
    App --> Logs[๐Ÿ“„ Winston Logging]
    App --> Static[๐Ÿ“ Static Assets]

    classDef user fill:#e1f5fe
    classDef app fill:#e8f5e8
    classDef security fill:#fff3e0
    classDef external fill:#fce4ec

    class User,Browser user
    class Proxy,App app
    class Security,Auth security
    class API,Logs,Static external
Loading

Key Components:

  • Security-First Design: Multiple layers of protection including rate limiting, input validation, and security headers
  • OAuth Integration: Seamless GitHub authentication with secure token handling
  • Modern HTTP Client: Axios-based client replacing deprecated request library
  • Comprehensive Logging: Winston-powered structured logging with rotation
  • Production Ready: Designed for scalability with PM2 process management

๐Ÿ“‹ Detailed Documentation:


๐Ÿ› ๏ธ Development

NPM Scripts

npm start          # Start production server
npm run dev        # Start development server (if configured)
npm test           # Run tests
npm run lint       # Code linting
npm audit          # Security audit

Project Structure

Git-Captain/
โ”œโ”€โ”€ controllers/           # Backend logic
โ”‚   โ”œโ”€โ”€ server.js         # Main server file
โ”‚   โ”œโ”€โ”€ config.js         # Configuration management
โ”‚   โ”œโ”€โ”€ middleware.js     # Security middleware
โ”‚   โ”œโ”€โ”€ validation.js     # Input validation schemas
โ”‚   โ”œโ”€โ”€ httpClient.js     # HTTP client (Axios wrapper)
โ”‚   โ”œโ”€โ”€ logger.js         # Winston logging setup
โ”‚   โ””โ”€โ”€ .env             # Environment variables
โ”œโ”€โ”€ public/               # Frontend assets
โ”‚   โ”œโ”€โ”€ js/              # JavaScript files
โ”‚   โ”œโ”€โ”€ css/             # Stylesheets
โ”‚   โ”œโ”€โ”€ images/          # Images and icons
โ”‚   โ””โ”€โ”€ views/           # HTML templates
โ”œโ”€โ”€ docs/                # Documentation
โ”œโ”€โ”€ logs/                # Application logs
โ””โ”€โ”€ scripts/             # Utility scripts

๐Ÿšข Deployment

Development (Local)

npm install
# Configure .env file
npm start

Production Options

Option 1: Reverse Proxy (Recommended)

Use nginx or Apache to handle SSL and forward to port 3000:

server {
    listen 443 ssl;
    server_name yourdomain.com;
    
    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;
    
    location / {
        proxy_pass https://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Option 2: Docker

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]

Option 3: Cloud Platforms

  • AWS: ECS + ALB or Elastic Beanstalk
  • Azure: App Service or Container Instances
  • Google Cloud: Cloud Run or Compute Engine
  • Heroku: Direct deployment with buildpacks

Firewall Configuration

Basic firewall setup for production:

# Linux (UFW)
sudo ufw allow 3000
sudo ufw allow 443

# Windows
netsh advfirewall firewall add rule name="Git-Captain" dir=in action=allow protocol=TCP localport=3000

For detailed enterprise deployment, see docs/DEPLOYMENT.md


๐Ÿ“‹ Recent Updates (v2.0)

๐Ÿ”„ Modernization (July 2025)

  • โœ… Removed deprecated request library โ†’ Modern Axios HTTP client
  • โœ… Added comprehensive security middleware (Helmet, CORS, Rate limiting)
  • โœ… Implemented input validation for all API endpoints
  • โœ… Modern async/await patterns throughout codebase
  • โœ… Environment-based configuration (.env files)
  • โœ… Structured logging system with Winston
  • โœ… Fixed API response formatting for consistent client-server communication
  • โœ… Updated all dependencies to latest secure versions
  • โœ… Eliminated security vulnerabilities (npm audit clean)

๐Ÿ› Bug Fixes

  • โœ… Branch search results now display correctly in UI
  • โœ… Pull request search functionality restored
  • โœ… OAuth flow improvements with proper error handling
  • โœ… Rate limiting optimized for development and production
  • โœ… GitHub API URL corrections for branch operations

๐Ÿ“– Documentation

  • โœ… Complete README overhaul (this document)
  • โœ… Enterprise deployment guide (docs/DEPLOYMENT.md)
  • โœ… Technical change documentation (MODULE_UPDATES.md)
  • โœ… Architecture documentation with rich diagrams (docs/ARCHITECTURE.md)
  • โœ… Mermaid diagram collection (docs/ARCHITECTURE_MERMAID.md)

๐Ÿ“Š Visual Architecture

All documentation now includes rich Mermaid diagrams that render beautifully in both VS Code and GitHub:

  • ๐Ÿ—๏ธ System Architecture: High-level component overview
  • ๐Ÿ”„ Request Flow: OAuth and API call sequences
  • โšก Error Handling: Comprehensive error management flows
  • ๐Ÿ›ก๏ธ Security Stack: Middleware and protection layers
  • ๐Ÿ”ง Technology Stack: Complete dependency mapping

๐Ÿงช Testing

Manual Testing

  1. OAuth Flow: Login โ†’ Token exchange โ†’ Repository access
  2. Branch Operations: Create, search, delete across multiple repos
  3. Pull Request Search: Find PRs by base branch
  4. Error Handling: Test rate limits, invalid inputs, network errors

Automated Testing

npm test  # Run test suite (when implemented)

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make changes following our coding standards
  4. Test thoroughly
  5. Submit a pull request

Development Guidelines

  • Follow existing code style and patterns
  • Add comments for complex logic
  • Update documentation for new features
  • Ensure security best practices
  • Test across different environments

๐Ÿ“Š Monitoring & Troubleshooting

Health Checks

# Check application status
curl -k https://localhost:3000/health

# View logs
tail -f logs/git-captain-$(date +%Y-%m-%d).log

Common Issues

Issue Solution
Port 3000 in use lsof -i :3000 and kill process
SSL certificate errors Regenerate certificates or check paths
Rate limit 429 errors Wait or increase limits in middleware.js
OAuth callback issues Verify GitHub OAuth app callback URL

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ† Built With


๐Ÿ‘ฅ Authors & Contributors

  • ConfusedDeer โ€” Original creator and maintainer
  • CrunchyFerrett โ€” Early frontend development
  • Community Contributors โ€” Various improvements and bug fixes

๐Ÿ™ Acknowledgments


๐Ÿ”ฎ Roadmap

Upcoming Features

  • Multi-organization support
  • Webhook integration for automated workflows
  • Branch protection rule management
  • Bulk repository creation
  • Advanced filtering and search
  • REST API for external integration
  • Docker Compose for easy deployment
  • Comprehensive test suite

Long-term Goals

  • Mobile-responsive PWA
  • Real-time collaboration features
  • Integration with CI/CD platforms
  • Advanced analytics and reporting

โญ Star this repository if Git-Captain helps you manage your repositories more efficiently!

Report Bug ยท Request Feature ยท Documentation

About

An open-source web-application built with Node.js utilizing GitHub API to find, create, and delete a branch throughout numerous GitHub repositories. Can be setup for organizations or a single user.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •