Skip to content

Ankitsinghsisodya/Gsoc-espionage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” PR Analyzer

Comprehensive GitHub Pull Request analytics with contributor insights

A modern, frontend-only React application that provides detailed insights into GitHub repository pull requests, contributor activity, and code metrics.

TypeScript React Vite


✨ Features

Feature Description
πŸ“Š Repository Analytics Total PRs, merge rates, contributor counts
πŸ‘₯ Contributor Insights Per-contributor statistics with avatars
πŸ“ˆ Activity Timeline Daily PR activity visualization
🏷️ Label Distribution PR labels breakdown
🌿 Branch Filtering Filter PRs by target branch
⏱️ Time Filters 2 weeks, 1 month, 3 months, 6 months, all time
πŸ“₯ Export Options RFC 4180 compliant CSV and JSON data export
πŸŒ™ Theme Support Light/dark mode with system preference detect
πŸ“ˆ Web Analytics Vercel analytics for visitor insights

πŸ—οΈ Architecture

flowchart TB
    subgraph Client["🌐 Browser Client"]
        UI["React UI<br/>(App.tsx)"]
        Services["Services Layer"]
        Utils["Utilities"]

        UI --> Services
        Services --> Utils
    end

    subgraph Services
        GH["GitHubService"]
        Export["ExportService"]
        Storage["StorageService"]
        Theme["ThemeService"]
    end

    subgraph Utils
        DateUtils["DateUtils"]
        URLParser["URLParser"]
    end

    subgraph External["☁️ External"]
        GitHubAPI["GitHub REST API v3"]
        LocalStorage["localStorage"]
    end

    GH <-->|"HTTPS"| GitHubAPI
    Storage <--> LocalStorage
    Theme <--> LocalStorage
Loading

πŸ“‚ Project Structure

frontend/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/          # React UI components
β”‚   β”‚   β”œβ”€β”€ common/          # Shared: Loader, Toast, ErrorBoundary
β”‚   β”‚   β”œβ”€β”€ contributors/    # ContributorCard, ContributorList, Modal
β”‚   β”‚   β”œβ”€β”€ layout/          # Header, Footer, Sidebar
β”‚   β”‚   └── repository/      # RepositoryStats display
β”‚   β”‚
β”‚   β”œβ”€β”€ services/            # Business logic layer
β”‚   β”‚   β”œβ”€β”€ GitHubService.ts # GitHub API integration
β”‚   β”‚   β”œβ”€β”€ ExportService.ts # CSV/JSON file exports
β”‚   β”‚   β”œβ”€β”€ StorageService.ts# Bookmarks & history
β”‚   β”‚   └── ThemeService.ts  # Dark/light mode
β”‚   β”‚
β”‚   β”œβ”€β”€ utils/               # Utility functions
β”‚   β”‚   β”œβ”€β”€ dateUtils.ts     # Date manipulation
β”‚   β”‚   └── urlParser.ts     # GitHub URL parsing (supports multiple formats)
β”‚   β”‚
β”‚   β”œβ”€β”€ constants/           # Centralized configuration
β”‚   β”‚   └── index.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ types/               # TypeScript interfaces
β”‚   β”‚   └── index.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ styles/              # CSS styles
β”‚   β”‚   └── index.css
β”‚   β”‚
β”‚   └── App.tsx              # Main application component
β”‚
β”œβ”€β”€ public/                  # Static assets
β”œβ”€β”€ index.html               # HTML entry point
β”œβ”€β”€ package.json
β”œβ”€β”€ vite.config.ts
└── tsconfig.json

πŸ”„ Data Flow

sequenceDiagram
    participant User
    participant App
    participant GitHubService
    participant GitHub API
    participant ExportService

    User->>App: Enter repository URL
    App->>GitHubService: fetchRepositoryStats()
    GitHubService->>GitHub API: GET /repos/{owner}/{repo}/pulls
    GitHub API-->>GitHubService: Pull requests data
    GitHubService->>GitHubService: Calculate statistics
    GitHubService-->>App: RepositoryStats
    App->>App: Render charts & contributors

    User->>App: Click "Export CSV"
    App->>ExportService: exportRepositoryCsv(stats)
    ExportService->>ExportService: Generate CSV blob
    ExportService-->>User: Download file
Loading

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

# Clone the repository
git clone https://github.com/your-username/pr-analyzer.git
cd pr-analyzer/frontend

# Install dependencies
npm install

# Start development server
npm run dev

Using Docker

# Build and run with Docker Compose
docker compose up --build -d

# Access at http://localhost:5173

βš™οΈ Configuration

GitHub Token (Optional)

For higher rate limits (5,000/hour vs 60/hour), add a GitHub Personal Access Token:

  1. Go to GitHub Settings β†’ Tokens
  2. Generate a new token (no scopes needed for public repos)
  3. Enter the token in the app's token input section

πŸ”’ The token is stored in your browser's localStorage, never sent to any server.

Supported URL Formats

The URL parser supports multiple GitHub URL formats:

Format Example
Simple facebook/react
Domain github.com/owner/repo
Full URL https://github.com/owner/repo
With .git https://github.com/owner/repo.git
SSH [email protected]:owner/repo.git
PR URLs https://github.com/owner/repo/pull/123
import { GitHubUrlParser, extractPRNumber } from "./utils";

// Parse any format
GitHubUrlParser.parse("[email protected]:facebook/react.git");
// β†’ { owner: 'facebook', repo: 'react' }

// Extract PR number from URL
extractPRNumber("https://github.com/owner/repo/pull/456");
// β†’ 456

πŸ“Š Rate Limits

Auth Status Rate Limit Best For
Without Token 60/hour Quick lookups
With Token 5,000/hour Heavy analysis

🧩 Component Hierarchy

graph TD
    App["App"]

    App --> Hero["Hero Section"]
    App --> Results["Results View"]
    App --> Toast["ToastContainer"]

    Hero --> SearchForm["Search Form"]
    Hero --> TokenInput["Token Input"]

    Results --> RepoStats["RepositoryStats"]
    Results --> ContribList["ContributorList"]
    Results --> Modal["ContributorModal"]

    ContribList --> Card1["ContributorCard"]
    ContribList --> Card2["ContributorCard"]
    ContribList --> CardN["..."]

    RepoStats --> StatCards["Stat Cards"]
    RepoStats --> Labels["Label Distribution"]
    RepoStats --> Timeline["Activity Timeline"]
Loading

πŸ› οΈ Tech Stack

Layer Technology
Framework React 18 with TypeScript
Build Tool Vite
Styling Vanilla CSS with CSS Variables
Icons Lucide React
API GitHub REST API v3
Storage Browser localStorage
Analytics Vercel Web Analytics

πŸ“¦ Scripts

npm run dev      # Start development server
npm run build    # Build for production
npm run preview  # Preview production build
npm run lint     # Run ESLint

🀝 Contributing

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

πŸ“„ License

This project is open source and available under the MIT License.


Made with ❀️ for the open source community

About

A comprehensive GitHub PR analytics dashboard built with TypeScript, React 18, and Vite for deep contributor insights

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published