A production-grade SaaS application that monitors GitHub repository activity to detect inactive or unhealthy repositories. Built with modern web technologies and designed for scalability.
This is a Turbo monorepo that follows enterprise-grade architecture patterns:
repo-ghost-hunter/
├── apps/
│ ├── web/ # Next.js 14 frontend (App Router)
│ └── api/ # NestJS backend API
├── packages/
│ ├── ui/ # Shared UI components
│ ├── database/ # Prisma schema + client
│ ├── config/ # Shared TypeScript/ESLint configs
│ └── types/ # Shared TypeScript types
├── infrastructure/
│ ├── docker/ # Docker configuration
│ └── scripts/ # Development scripts
└── .github/workflows/ # CI/CD pipelines
- Next.js 14 with App Router
- TypeScript (strict mode)
- Tailwind CSS for styling
- React Server Components
- NestJS for API server
- Prisma ORM with PostgreSQL
- JWT authentication
- Redis for caching and queue management
- BullMQ for background job processing
- @nestjs/schedule for cron jobs
- Turbo for monorepo management
- pnpm for package management
- Docker & Docker Compose
- GitHub Actions for CI/CD
- Node.js 18+
- pnpm 8+
- Docker & Docker Compose
- PostgreSQL (or use Docker)
-
Clone the repository
git clone <repository-url> cd repo-ghost-hunter
-
Run the setup script
chmod +x infrastructure/scripts/setup.sh ./infrastructure/scripts/setup.sh
-
Configure environment variables
cp .env.example .env.local # Edit .env.local with your configuration -
Start development servers
pnpm run dev
Or start services individually:
pnpm run dev:web # Frontend at http://localhost:3000 pnpm run dev:api # Backend at http://localhost:3001
For a complete development environment with Docker:
cd infrastructure/docker
docker-compose up -dThis will start:
- PostgreSQL database
- Redis cache
- API server
- Web frontend
The application uses GitHub OAuth for authentication with the following flow:
GET /api/auth/github
- Redirects user to GitHub authorization page
- Includes required scopes and CSRF protection via state parameter
- User authorizes the application on GitHub
- GitHub redirects back to the callback URL
GET /api/auth/github/callback?code=xxx&state=xxx
- Exchange authorization code for access token
- Extract user profile data (id, username, email, avatar)
- Store encrypted access token in database
- Generate JWT token for session management
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "user-uuid",
"username": "github-username",
"avatar": "https://avatars.githubusercontent.com/u/123456?v=4"
}
}Include JWT token in Authorization header:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Create .env.local with the following required variables:
# Database
DATABASE_URL="postgresql://username:password@localhost:5432/repo_ghost_hunter"
# GitHub OAuth
GITHUB_CLIENT_ID="your-github-oauth-client-id"
GITHUB_CLIENT_SECRET="your-github-oauth-client-secret"
# JWT Authentication
JWT_SECRET="your-32-character-minimum-secret-key"
# Application URLs
FRONTEND_URL="http://localhost:3000"
GITHUB_CALLBACK_URL="http://localhost:3001/api/auth/github/callback"# Redis (for caching)
REDIS_URL="redis://localhost:6379"
# Encryption (for access tokens)
ENCRYPTION_KEY="your-32-character-encryption-key"
# Environment
NODE_ENV="development" # development | production | test-
Create GitHub OAuth App
- Go to GitHub Settings → Developer settings → OAuth Apps
- Click "New OAuth App"
- Set Authorization callback URL:
http://localhost:3001/api/auth/github/callback - For production, use your actual domain
-
Configure Environment
GITHUB_CLIENT_ID="your-client-id" GITHUB_CLIENT_SECRET="your-client-secret"
-
Required Scopes The app requests the following GitHub scopes:
user:email- Read user emailread:org- Read organization data (if applicable)read:user- Read user profile data
apps/web- Next.js frontend applicationapps/api- NestJS backend API
packages/ui- Reusable React componentspackages/database- Prisma schema and database clientpackages/config- Shared ESLint, TypeScript configurationspackages/types- Shared TypeScript type definitions
infrastructure/docker/- Docker configuration filesinfrastructure/scripts/- Development and deployment scripts
# Development
pnpm run dev # Start all services
pnpm run dev:web # Start only web app
pnpm run dev:api # Start only API
# Building
pnpm run build # Build all packages
pnpm run build:web # Build only web app
pnpm run build:api # Build only API
# Quality Assurance
pnpm run lint # Lint all packages
pnpm run lint:fix # Fix linting issues
pnpm run type-check # Type check all packages
pnpm run test # Run all tests
pnpm run test:watch # Run tests in watch mode
# Database
pnpm run db:generate # Generate Prisma client
pnpm run db:push # Push schema to database
pnpm run db:migrate # Run database migrations
pnpm run db:studio # Open Prisma Studio
pnpm run db:seed # Seed database with sample data
# Utilities
pnpm run clean # Clean build artifactsCopy .env.example to .env.local and configure:
DATABASE_URL- PostgreSQL connection stringNEXTAUTH_SECRET- Authentication secretNEXTAUTH_URL- Application URLGITHUB_CLIENT_ID- GitHub OAuth app client IDGITHUB_CLIENT_SECRET- GitHub OAuth app client secret
REDIS_URL- Redis connection string for cachingGITHUB_API_TOKEN- GitHub personal access tokenSENTRY_DSN- Sentry error trackingGOOGLE_ANALYTICS_ID- Google Analytics
- Create a feature branch from
develop - Make changes following the established patterns
- Run tests and linting locally
- Submit a pull request to
develop - Code review and automated CI/CD checks
- Merge to
developfor staging - Deploy to production from
main
- Shared Dependencies: Common packages are shared across applications
- Atomic Commits: Changes to multiple packages can be committed together
- Consistent Tooling: Unified linting, formatting, and TypeScript configuration
- Faster CI: Intelligent caching and parallel builds
- Scalability: Easy to add new applications and packages
The application calculates repository health scores based on:
- Commit Frequency - Recent activity and consistency
- Issue Resolution - How quickly issues are addressed
- Pull Request Activity - Community engagement
- Contributor Activity - Number and diversity of contributors
- Documentation Quality - Presence and quality of README, docs
- GitHub OAuth for user authentication
- JWT tokens for session management
- Role-based access control (RBAC) ready
-
Build all applications
pnpm run build
-
Run database migrations
pnpm run db:migrate
-
Deploy with Docker
docker-compose -f docker-compose.prod.yml up -d
- Development: Local development with hot reload
- Staging: Production-like environment for testing
- Production: Optimized builds with security hardening
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions and support:
- Create an issue in the GitHub repository
- Check the documentation in
/docs - Review the FAQ in the wiki
- Real-time repository monitoring
- Advanced health score algorithms
- Team collaboration features
- Custom alert configurations
- Mobile application
- API rate limiting and analytics
- Multi-tenant support
The application uses a robust background sync system powered by BullMQ and Redis to automatically update repository data.
- Queue-Based Processing: All sync operations go through a Redis-backed queue system
- Automated Scheduling: Daily cron job at 2 AM UTC triggers sync for all users
- Rate Limiting: Jobs are staggered to avoid GitHub API rate limits
- Retry Logic: Failed jobs retry up to 3 times with exponential backoff
The system provides several endpoints for monitoring and managing the sync queue:
# Trigger manual sync for current user
POST /queue/trigger
# Get queue statistics
GET /queue/stats
# Pause/resume queue processing
POST /queue/pause
POST /queue/resume
# Trigger sync for all users (admin only)
POST /queue/trigger-all- Queue Stats: Track waiting, active, completed, and failed jobs
- Health Logging: Automatic logging of queue size and failed jobs
- Graceful Shutdown: Workers shut down cleanly on application termination
The background sync system requires Redis for queue management:
REDIS_URL="redis://localhost:6379"Redis is automatically started in the Docker development environment.
- Concurrency: Maximum 3 concurrent jobs to prevent API overload
- Rate Limiting: 10 jobs per minute maximum
- Retry Strategy: 3 attempts with exponential backoff (5s, 10s, 20s)
- Job Retention: Keep last 100 completed and 50 failed jobs
Built with ❤️ for the open-source community
Users sign in with GitHub OAuth and their access tokens are stored securely.
After login, fetch user repositories using GitHub API and store metadata in the database.
Background job runs daily and collects:
- Latest commit
- Open pull requests
- Open issues
- Contributors
- Inactive Repo: No commits in 30 days
- Stale PR: PR open for more than 14 days
- Stale Issue: Issue inactive for 30 days
Calculated from 0 to 100 based on:
- Commit frequency
- PR merge time
- Issue response time
- Active contributors
View:
- List of repositories
- Health scores
- Last commit dates
- Stale pull requests
- Open issues
Automated email summaries with repository health metrics.
# Start all services
npm run dev
# Start frontend only
npm run dev:web
# Start backend only
npm run dev:api
# Run tests
npm test
# Build for production
npm run build- Frontend: Deploy on Vercel
- Backend: Deploy on Node server (Railway, Render, etc.)
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.